Merge branch 'refs/heads/develop' into tv
Conflicts: couchpotato/core/media/_base/searcher/main.py couchpotato/core/plugins/renamer/main.py
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Backport of importlib.import_module from 3.x."""
|
||||
# While not critical (and in no way guaranteed!), it would be nice to keep this
|
||||
# code compatible with Python 2.3.
|
||||
import sys
|
||||
|
||||
def _resolve_name(name, package, level):
|
||||
"""Return the absolute name of the module to be imported."""
|
||||
if not hasattr(package, 'rindex'):
|
||||
raise ValueError("'package' not set to a string")
|
||||
dot = len(package)
|
||||
for x in xrange(level, 1, -1):
|
||||
try:
|
||||
dot = package.rindex('.', 0, dot)
|
||||
except ValueError:
|
||||
raise ValueError("attempted relative import beyond top-level "
|
||||
"package")
|
||||
return "%s.%s" % (package[:dot], name)
|
||||
|
||||
|
||||
def import_module(name, package=None):
|
||||
"""Import a module.
|
||||
|
||||
The 'package' argument is required when performing a relative import. It
|
||||
specifies the package to use as the anchor point from which to resolve the
|
||||
relative import to an absolute import.
|
||||
|
||||
"""
|
||||
if name.startswith('.'):
|
||||
if not package:
|
||||
raise TypeError("relative imports require the 'package' argument")
|
||||
level = 0
|
||||
for character in name:
|
||||
if character != '.':
|
||||
break
|
||||
level += 1
|
||||
name = _resolve_name(name[level:], package, level)
|
||||
__import__(name)
|
||||
return sys.modules[name]
|
||||
@@ -71,12 +71,10 @@ class RTorrent:
|
||||
|
||||
def _verify_conn(self):
|
||||
# check for rpc methods that should be available
|
||||
assert {"system.client_version",
|
||||
"system.library_version"}.issubset(set(self._get_rpc_methods())),\
|
||||
"Required RPC methods not available."
|
||||
assert "system.client_version" in self._get_rpc_methods(), "Required RPC method not available."
|
||||
assert "system.library_version" in self._get_rpc_methods(), "Required RPC method not available."
|
||||
|
||||
# minimum rTorrent version check
|
||||
|
||||
assert self._meets_version_requirement() is True,\
|
||||
"Error: Minimum rTorrent version required is {0}".format(
|
||||
MIN_RTORRENT_VERSION_STR)
|
||||
|
||||
@@ -90,9 +90,10 @@ class TorrentParser():
|
||||
def _calc_info_hash(self):
|
||||
self.info_hash = None
|
||||
if "info" in self._torrent_decoded.keys():
|
||||
info_dict = self._torrent_decoded["info"]
|
||||
self.info_hash = hashlib.sha1(bencode.encode(
|
||||
info_dict)).hexdigest().upper()
|
||||
info_encoded = bencode.encode(self._torrent_decoded["info"])
|
||||
|
||||
if info_encoded:
|
||||
self.info_hash = hashlib.sha1(info_encoded).hexdigest().upper()
|
||||
|
||||
return(self.info_hash)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import platform
|
||||
|
||||
from collections import defaultdict
|
||||
from itertools import imap
|
||||
@@ -23,22 +24,48 @@ class DelugeClient(object):
|
||||
self._request_counter = 0
|
||||
|
||||
def _get_local_auth(self):
|
||||
xdg_config = os.path.expanduser(os.environ.get("XDG_CONFIG_HOME", "~/.config"))
|
||||
config_home = os.path.join(xdg_config, "deluge")
|
||||
auth_file = os.path.join(config_home, "auth")
|
||||
|
||||
auth_file = ""
|
||||
username = password = ""
|
||||
with open(auth_file) as fd:
|
||||
for line in fd:
|
||||
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")
|
||||
appDataPath = appDataReg[0]
|
||||
_winreg.CloseKey(hkey)
|
||||
|
||||
auth_file = os.path.join(appDataPath, "deluge", "auth")
|
||||
else:
|
||||
from xdg.BaseDirectory import save_config_path
|
||||
try:
|
||||
auth_file = os.path.join(save_config_path("deluge"), "auth")
|
||||
except OSError, e:
|
||||
return username, password
|
||||
|
||||
|
||||
if os.path.exists(auth_file):
|
||||
for line in open(auth_file):
|
||||
if line.startswith("#"):
|
||||
# This is a comment line
|
||||
continue
|
||||
line = line.strip()
|
||||
try:
|
||||
lsplit = line.split(":")
|
||||
except Exception, e:
|
||||
continue
|
||||
|
||||
auth = line.split(":")
|
||||
if len(auth) >= 2 and auth[0] == "localclient":
|
||||
username, password = auth[0], auth[1]
|
||||
break
|
||||
if len(lsplit) == 2:
|
||||
username, password = lsplit
|
||||
elif len(lsplit) == 3:
|
||||
username, password, level = lsplit
|
||||
else:
|
||||
continue
|
||||
|
||||
return username, password
|
||||
if username == "localclient":
|
||||
return (username, password)
|
||||
|
||||
return ("", "")
|
||||
|
||||
def _create_module_method(self, module, method):
|
||||
fullname = "{0}.{1}".format(module, method)
|
||||
|
||||
Reference in New Issue
Block a user