mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-31 03:50:06 -07:00
Fix imports for Python 3
This commit is contained in:
parent
f5f6562fe9
commit
8cd4b56891
3 changed files with 16 additions and 14 deletions
|
@ -10,7 +10,8 @@ import stat
|
|||
import subprocess
|
||||
import tarfile
|
||||
import traceback
|
||||
import urllib
|
||||
|
||||
from six.moves.urllib.request import urlretrieve
|
||||
|
||||
import core
|
||||
from core import gh_api as github, logger
|
||||
|
@ -451,7 +452,7 @@ class SourceUpdateManager(UpdateManager):
|
|||
# retrieve file
|
||||
logger.log(u"Downloading update from {url!r}".format(url=tar_download_url))
|
||||
tar_download_path = os.path.join(sb_update_dir, u'nzbtomedia-update.tar')
|
||||
urllib.urlretrieve(tar_download_url, tar_download_path)
|
||||
urlretrieve(tar_download_url, tar_download_path)
|
||||
|
||||
if not os.path.isfile(tar_download_path):
|
||||
logger.log(u"Unable to retrieve new version from {url}, can't update".format
|
||||
|
|
|
@ -28,12 +28,14 @@ class DelugeClient(object):
|
|||
if platform.system() in ('Windows', 'Microsoft'):
|
||||
appDataPath = os.environ.get("APPDATA")
|
||||
if not appDataPath:
|
||||
import _winreg
|
||||
hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")
|
||||
appDataReg = _winreg.QueryValueEx(hkey, "AppData")
|
||||
from six.moves import winreg
|
||||
hkey = winreg.OpenKey(
|
||||
winreg.HKEY_CURRENT_USER,
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
)
|
||||
appDataReg = winreg.QueryValueEx(hkey, "AppData")
|
||||
appDataPath = appDataReg[0]
|
||||
_winreg.CloseKey(hkey)
|
||||
winreg.CloseKey(hkey)
|
||||
|
||||
auth_file = os.path.join(appDataPath, "deluge", "auth")
|
||||
else:
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# coding=utf8
|
||||
import re
|
||||
import urllib
|
||||
|
||||
from six import StringIO
|
||||
from six import StringIO, iteritems
|
||||
from six.moves.http_cookiejar import CookieJar
|
||||
from six.moves.urllib.request import (
|
||||
HTTPBasicAuthHandler,
|
||||
|
@ -11,7 +10,7 @@ from six.moves.urllib.request import (
|
|||
build_opener,
|
||||
install_opener,
|
||||
)
|
||||
from six.moves.urllib_parse import urljoin
|
||||
from six.moves.urllib_parse import urlencode, urljoin
|
||||
|
||||
from .upload import MultiPartForm
|
||||
|
||||
|
@ -94,7 +93,7 @@ class UTorrentClient(object):
|
|||
|
||||
def setprops(self, hash, **kvpairs):
|
||||
params = [('action', 'setprops'), ('hash', hash)]
|
||||
for k, v in kvpairs.iteritems():
|
||||
for k, v in iteritems(kvpairs):
|
||||
params.append( ("s", k) )
|
||||
params.append( ("v", v) )
|
||||
|
||||
|
@ -114,7 +113,7 @@ class UTorrentClient(object):
|
|||
if filepath is not None:
|
||||
file_handler = open(filepath,'rb')
|
||||
else:
|
||||
file_handler = StringIO.StringIO(bytes)
|
||||
file_handler = StringIO(bytes)
|
||||
|
||||
form.add_file('torrent_file', filename.encode('utf-8'), file_handler)
|
||||
|
||||
|
@ -138,11 +137,11 @@ class UTorrentClient(object):
|
|||
|
||||
def _action(self, params, body=None, content_type=None):
|
||||
#about token, see https://github.com/bittorrent/webui/wiki/TokenSystem
|
||||
url = self.base_url + '?token=' + self.token + '&' + urllib.urlencode(params)
|
||||
url = self.base_url + '?token=' + self.token + '&' + urlencode(params)
|
||||
request = Request(url)
|
||||
|
||||
if body:
|
||||
request.add_data(body)
|
||||
request.data = body
|
||||
request.add_header('Content-length', len(body))
|
||||
if content_type:
|
||||
request.add_header('Content-type', content_type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue