mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
The setup package now imports under python 3
This commit is contained in:
parent
5c6ba41cca
commit
a9e07efecd
@ -6,10 +6,11 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, subprocess, hashlib, shutil, glob, stat, sys, time, urllib2, urllib, json, httplib
|
import os, subprocess, hashlib, shutil, glob, stat, sys, time, json
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
from tempfile import NamedTemporaryFile, mkdtemp, gettempdir
|
from tempfile import NamedTemporaryFile, mkdtemp, gettempdir
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
from polyglot.urllib import urlopen, urlencode
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
d = os.path.dirname
|
d = os.path.dirname
|
||||||
@ -180,14 +181,14 @@ def upload_to_fosshub():
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
# print(json.dumps(jq, indent=2))
|
# print(json.dumps(jq, indent=2))
|
||||||
rq = urllib2.urlopen(
|
rq = urlopen(
|
||||||
'https://www.fosshub.com/JSTools/uploadJson',
|
'https://www.fosshub.com/JSTools/uploadJson',
|
||||||
urllib.urlencode({
|
urlencode({
|
||||||
'content': json.dumps(jq)
|
'content': json.dumps(jq)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
resp = rq.read()
|
resp = rq.read()
|
||||||
if rq.getcode() != httplib.OK:
|
if rq.getcode() != 200:
|
||||||
raise SystemExit(
|
raise SystemExit(
|
||||||
'Failed to upload to fosshub, with HTTP error code: %d and response: %s'
|
'Failed to upload to fosshub, with HTTP error code: %d and response: %s'
|
||||||
% (rq.getcode(), resp)
|
% (rq.getcode(), resp)
|
||||||
|
15
src/polyglot/urllib.py
Normal file
15
src/polyglot/urllib.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
# vim:fileencoding=utf-8
|
||||||
|
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
|
||||||
|
from polyglot.builtins import is_py3
|
||||||
|
|
||||||
|
if is_py3:
|
||||||
|
from urllib.request import urlopen # noqa
|
||||||
|
from urllib.parse import urlencode # noqa
|
||||||
|
else:
|
||||||
|
from urllib import urlencode # noqa
|
||||||
|
from urllib2 import urlopen # noqa
|
Loading…
x
Reference in New Issue
Block a user