summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-14 02:58:43 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-14 02:58:43 +0200
commitbfe66d14090586ff79a1ccac0e37a5dad99c5601 (patch)
treef89a3b6038344aad70a8abdd178af6af89c9a5a3
parentCleanup (2) (diff)
parentfix: assignJob (diff)
downloadpyload-bfe66d14090586ff79a1ccac0e37a5dad99c5601.tar.xz
Merge pull request #4 from ardi69/0.4.10
fix: assignJob and typos (__name vs. __name__)
-rw-r--r--pyload/manager/Plugin.py2
-rw-r--r--pyload/manager/Thread.py8
-rw-r--r--pyload/plugin/Account.py7
-rw-r--r--pyload/plugin/Plugin.py11
-rw-r--r--pyload/plugin/addon/ExternalScripts.py55
-rw-r--r--pyload/plugin/addon/ExtractArchive.py18
-rw-r--r--pyload/plugin/addon/UpdateManager.py8
-rw-r--r--pyload/plugin/hoster/KingfilesNet.py1
-rw-r--r--pyload/plugin/internal/SimpleHoster.py18
-rw-r--r--pyload/plugin/internal/XFSHoster.py1
-rw-r--r--pyload/webui/app/pyloadweb.py17
11 files changed, 73 insertions, 73 deletions
diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py
index 10abbc2ea..69a77fdf8 100644
--- a/pyload/manager/Plugin.py
+++ b/pyload/manager/Plugin.py
@@ -365,7 +365,7 @@ class PluginManager(object):
for type in as_dict.iterkeys():
if type in ("addon", "internal"): # : do not reload them because would cause to much side effects
- self.core.log.debug("Skipping reload for plugin: [%(type)s] %(name)s" % {'name': plugin, 'type': type})
+ self.core.log.debug("Skipping reload for plugins from type: %(type)s" % {'type': type})
continue
for plugin in as_dict[type]:
diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py
index 147dff31f..dd1582eb7 100644
--- a/pyload/manager/Thread.py
+++ b/pyload/manager/Thread.py
@@ -257,11 +257,11 @@ class ThreadManager(object):
free = [x for x in self.threads if not x.active]
- inuse = set([(x.active.pluginname, self.getLimit(x)) for x in self.threads if x.active and x.active.hasPlugin() and x.active.plugin.account])
- inuse = map(lambda x: (x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])), inuse)
+ inuse = set([((x.active.plugintype, x.active.pluginname), self.getLimit(x)) for x in self.threads if x.active and x.active.hasPlugin() and x.active.plugin.account])
+ inuse = map(lambda x: ('.'.join(x[0]), x[1], len([y for y in self.threads if y.active and y.active.plugintype == x[0][0] and y.active.pluginname == x[0][1]])), inuse)
onlimit = [x[0] for x in inuse if x[1] > 0 and x[2] >= x[1]]
- occ = [x.active.pluginname for x in self.threads if x.active and x.active.hasPlugin() and not x.active.plugin.multiDL] + onlimit
+ occ = [x.active.plugintype + '.' + x.active.pluginname for x in self.threads if x.active and x.active.hasPlugin() and not x.active.plugin.multiDL] + onlimit
occ.sort()
occ = tuple(set(occ))
@@ -277,7 +277,7 @@ class ThreadManager(object):
job.release()
return
- if job.plugin.grtPluginType() == "hoster":
+ if job.plugin.getPluginType() == "hoster":
spaceLeft = freeSpace(self.core.config["general"]["download_folder"]) / 1024 / 1024
if spaceLeft < self.core.config["general"]["min_free_space"]:
self.core.log.warning(_("Not enough space left on device"))
diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py
index 6a3eddc5b..23f15e8fd 100644
--- a/pyload/plugin/Account.py
+++ b/pyload/plugin/Account.py
@@ -96,7 +96,7 @@ class Account(Base):
req.cj.clear()
req.close()
if user in self.infos:
- del self.infos[user] #delete old information
+ del self.infos[user] # delete old information
return self._login(user, self.accounts[user])
@@ -112,7 +112,7 @@ class Account(Base):
""" updates account and return true if anything changed """
if user in self.accounts:
- self.accounts[user]['valid'] = True #do not remove or accounts will not login
+ self.accounts[user]['valid'] = True # do not remove or accounts will not login
if password:
self.accounts[user]['password'] = password
self.relogin(user)
@@ -166,8 +166,7 @@ class Account(Base):
infos['timestamp'] = time()
self.infos[name] = infos
- elif "timestamp" in self.infos[name] and self.infos[name][
- "timestamp"] + self.info_threshold * 60 < time():
+ elif "timestamp" in self.infos[name] and self.infos[name]["timestamp"] + self.info_threshold * 60 < time():
self.logDebug("Reached timeout for account data")
self.scheduleRefresh(name)
diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py
index cedab3b4f..9e5f1e55b 100644
--- a/pyload/plugin/Plugin.py
+++ b/pyload/plugin/Plugin.py
@@ -89,10 +89,15 @@ class Base(object):
return self._log("critical", args)
- def grtPluginType(self):
+ def getPluginType(self):
return getattr(self, "_%s__type" % self.__class__.__name__)
+ @classmethod
+ def getClassName(cls):
+ return cls.__name__
+
+
def getPluginConfSection(self):
return "%s_%s" % (self.__class__.__name__, getattr(self, "_%s__type" % self.__class__.__name__))
@@ -239,7 +244,7 @@ class Plugin(Base):
#: captcha task
self.cTask = None
- self.html = None #@TODO: Move to hoster class in 0.4.10
+ self.html = None # @TODO: Move to hoster class in 0.4.10
self.retries = 0
self.init()
@@ -533,7 +538,7 @@ class Plugin(Base):
if not url:
self.fail(_("No url given"))
- url = urllib.unquote(encode(url).strip()) #@NOTE: utf8 vs decode -> please use decode attribute in all future plugins
+ url = urllib.unquote(encode(url).strip()) # @NOTE: utf8 vs decode -> please use decode attribute in all future plugins
if self.core.debug:
self.logDebug("Load url: " + url, *["%s=%s" % (key, val) for key, val in locals().iteritems() if key not in ("self", "url")])
diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py
index 519023603..75c9ae810 100644
--- a/pyload/plugin/addon/ExternalScripts.py
+++ b/pyload/plugin/addon/ExternalScripts.py
@@ -12,16 +12,15 @@ class ExternalScripts(Addon):
__type = "addon"
__version = "0.39"
- __config = [("activated", "bool", "Activated" , True ),
- ("waitend" , "bool", "Wait script ending", False)]
+ __config = [("activated", "bool", "Activated" , True),
+ ("waitend" , "bool", "Wait script ending", False)]
__description = """Run external scripts"""
__license = "GPLv3"
- __authors = [("mkaay" , "mkaay@mkaay.de" ),
- ("RaNaN" , "ranan@pyload.org" ),
- ("spoob" , "spoob@pyload.org" ),
- ("Walter Purcaro", "vuolter@gmail.com")]
-
+ __authors = [("mkaay" , "mkaay@mkaay.de"),
+ ("RaNaN" , "ranan@pyload.org"),
+ ("spoob" , "spoob@pyload.org"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
event_list = ["archive_extract_failed", "archive_extracted" ,
"package_extract_failed", "package_extracted" ,
@@ -39,7 +38,7 @@ class ExternalScripts(Addon):
"download_preparing", "download_failed", "download_finished",
"archive_extract_failed", "archive_extracted",
"package_finished", "package_deleted", "package_extract_failed", "package_extracted",
- "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10
+ "all_downloads_processed", "all_downloads_finished", # @TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10
"all_archives_extracted", "all_archives_processed"]
for folder in folders:
@@ -85,7 +84,7 @@ class ExternalScripts(Addon):
self.logDebug("Executing: %s" % os.path.abspath(script), "Args: " + ' '.join(cmd_args))
- p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload
+ p = subprocess.Popen(cmd, bufsize=-1) # @NOTE: output goes to pyload
if self.getConfig('waitend'):
p.communicate()
@@ -114,7 +113,7 @@ class ExternalScripts(Addon):
def afterReconnecting(self, ip):
for script in self.scripts['after_reconnect']:
- self.callScript(script, ip, self.info['oldip']) #@TODO: Use built-in oldip in 0.4.10
+ self.callScript(script, ip, self.info['oldip']) # @TODO: Use built-in oldip in 0.4.10
def downloadPreparing(self, pyfile):
@@ -123,10 +122,10 @@ class ExternalScripts(Addon):
def downloadFailed(self, pyfile):
- if self.config['general']['folder_per_package']:
- download_folder = fs_join(self.config['general']['download_folder'], pyfile.package().folder)
+ if self.core.config['general']['folder_per_package']:
+ download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder)
else:
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
for script in self.scripts['download_failed']:
file = fs_join(download_folder, pyfile.name)
@@ -134,10 +133,10 @@ class ExternalScripts(Addon):
def downloadFinished(self, pyfile):
- if self.config['general']['folder_per_package']:
- download_folder = fs_join(self.config['general']['download_folder'], pyfile.package().folder)
+ if self.core.config['general']['folder_per_package']:
+ download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder)
else:
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
for script in self.scripts['download_finished']:
file = fs_join(download_folder, pyfile.name)
@@ -155,10 +154,10 @@ class ExternalScripts(Addon):
def packageFinished(self, pypack):
- if self.config['general']['folder_per_package']:
- download_folder = fs_join(self.config['general']['download_folder'], pypack.folder)
+ if self.core.config['general']['folder_per_package']:
+ download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
else:
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
for script in self.scripts['package_finished']:
self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
@@ -167,30 +166,30 @@ class ExternalScripts(Addon):
def packageDeleted(self, pid):
pack = self.core.api.getPackageInfo(pid)
- if self.config['general']['folder_per_package']:
- download_folder = fs_join(self.config['general']['download_folder'], pack.folder)
+ if self.core.config['general']['folder_per_package']:
+ download_folder = fs_join(self.core.config['general']['download_folder'], pack.folder)
else:
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
for script in self.scripts['package_deleted']:
self.callScript(script, pack.id, pack.name, download_folder, pack.password)
def package_extract_failed(self, pypack):
- if self.config['general']['folder_per_package']:
- download_folder = fs_join(self.config['general']['download_folder'], pypack.folder)
+ if self.core.config['general']['folder_per_package']:
+ download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
else:
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
for script in self.scripts['package_extract_failed']:
self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
def package_extracted(self, pypack):
- if self.config['general']['folder_per_package']:
- download_folder = fs_join(self.config['general']['download_folder'], pypack.folder)
+ if self.core.config['general']['folder_per_package']:
+ download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
else:
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
for script in self.scripts['package_extracted']:
self.callScript(script, pypack.id, pypack.name, download_folder)
diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py
index b2eeec1a3..ce67cbcaf 100644
--- a/pyload/plugin/addon/ExtractArchive.py
+++ b/pyload/plugin/addon/ExtractArchive.py
@@ -186,7 +186,7 @@ class ExtractArchive(Addon):
traceback.print_exc()
if self.extractors:
- self.logDebug(*["Found %s %s" % (Extractor.__name, Extractor.VERSION) for Extractor in self.extractors])
+ self.logDebug(*["Found %s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors])
self.extractQueued() #: Resume unfinished extractions
else:
self.logInfo(_("No Extract plugins activated"))
@@ -198,11 +198,11 @@ class ExtractArchive(Addon):
while packages:
if self.lastPackage: #: called from allDownloadsProcessed
self.lastPackage = False
- if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now
+ if self.extract(packages, thread): # @NOTE: check only if all gone fine, no failed reporting for now
self.manager.dispatchEvent("all_archives_extracted")
self.manager.dispatchEvent("all_archives_processed")
else:
- if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now
+ if self.extract(packages, thread): # @NOTE: check only if all gone fine, no failed reporting for now
pass
packages = self.queue.get() #: check for packages added during extraction
@@ -234,7 +234,7 @@ class ExtractArchive(Addon):
@Expose
- def extract(self, ids, thread=None): #@TODO: Use pypack, not pid to improve method usability
+ def extract(self, ids, thread=None): # @TODO: Use pypack, not pid to improve method usability
if not ids:
return False
@@ -287,15 +287,15 @@ class ExtractArchive(Addon):
matched = False
success = True
- files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \
- in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates
+ files_ids = dict((pylink['name'], ((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink
+ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates
# check as long there are unseen files
while files_ids:
new_files_ids = []
if extensions:
- files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \
+ files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids
if filter(lambda ext: fname.lower().endswith(ext), extensions)]
for Extractor in self.extractors:
@@ -341,8 +341,8 @@ class ExtractArchive(Addon):
continue
# remove processed file and related multiparts from list
- files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \
- if fname not in archive.getDeleteFiles()]
+ files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids
+ if fname not in archive.getDeleteFiles()]
self.logDebug("Extracted files: %s" % new_files)
self.setPermissions(new_files)
diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py
index c7fb27a3d..60fc71d0a 100644
--- a/pyload/plugin/addon/UpdateManager.py
+++ b/pyload/plugin/addon/UpdateManager.py
@@ -87,15 +87,15 @@ class UpdateManager(Addon):
def autoreloadPlugins(self):
""" reload and reindex all modified plugins """
modules = filter(
- lambda m: m and (m.__name.startswith("pyload.plugin.") or
- m.__name.startswith("userplugins.")) and
- m.__name.count(".") >= 2, sys.modules.itervalues()
+ lambda m: m and (m.__name__.startswith("pyload.plugin.") or
+ m.__name__.startswith("userplugins.")) and
+ m.__name__.count(".") >= 2, sys.modules.itervalues()
)
reloads = []
for m in modules:
- root, type, name = m.__name.rsplit(".", 2)
+ root, type, name = m.__name__.rsplit(".", 2)
id = (type, name)
if type in self.core.pluginManager.plugins:
f = m.__file__.replace(".pyc", ".py")
diff --git a/pyload/plugin/hoster/KingfilesNet.py b/pyload/plugin/hoster/KingfilesNet.py
index 5f4207d11..557f1f836 100644
--- a/pyload/plugin/hoster/KingfilesNet.py
+++ b/pyload/plugin/hoster/KingfilesNet.py
@@ -19,6 +19,7 @@ class KingfilesNet(SimpleHoster):
__authors = [("zapp-brannigan", "fuerst.reinje@web.de"),
("Walter Purcaro", "vuolter@gmail.com")]
+
NAME_PATTERN = r'name="fname" value="(?P<N>.+?)">'
SIZE_PATTERN = r'>Size: .+?">(?P<S>[\d.,]+) (?P<U>[\w^_]+)'
diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py
index 9fe5b1260..09f49af18 100644
--- a/pyload/plugin/internal/SimpleHoster.py
+++ b/pyload/plugin/internal/SimpleHoster.py
@@ -307,11 +307,11 @@ class SimpleHoster(Hoster):
LOGIN_ACCOUNT = False #: Set to True to require account login
DISPOSITION = True #: Set to True to use any content-disposition value in http header as file name
- directLink = getFileURL #@TODO: Remove in 0.4.10
+ directLink = getFileURL # @TODO: Remove in 0.4.10
@classmethod
- def parseInfos(cls, urls): #@TODO: Built-in in 0.4.10 core (remove from plugins)
+ def parseInfos(cls, urls): # @TODO: Built-in in 0.4.10 core (remove from plugins)
for url in urls:
url = replace_patterns(url, cls.URL_REPLACEMENTS)
yield cls.getInfo(url)
@@ -414,13 +414,13 @@ class SimpleHoster(Hoster):
def prepare(self):
- self.pyfile.error = "" #@TODO: Remove in 0.4.10
+ self.pyfile.error = "" # @TODO: Remove in 0.4.10
self.info = {}
self.html = ""
- self.link = "" #@TODO: Move to hoster class in 0.4.10
- self.directDL = False #@TODO: Move to hoster class in 0.4.10
- self.multihost = False #@TODO: Move to hoster class in 0.4.10
+ self.link = "" # @TODO: Move to hoster class in 0.4.10
+ self.directDL = False # @TODO: Move to hoster class in 0.4.10
+ self.multihost = False # @TODO: Move to hoster class in 0.4.10
if not self.getConfig('use_premium', True):
self.retryFree()
@@ -486,7 +486,7 @@ class SimpleHoster(Hoster):
self.downloadLink(self.link, self.DISPOSITION)
self.checkFile()
- except Fail, e: #@TODO: Move to PluginThread in 0.4.10
+ except Fail, e: # @TODO: Move to PluginThread in 0.4.10
if self.premium:
self.logWarning(_("Premium download failed"))
self.retryFree()
@@ -733,7 +733,7 @@ class SimpleHoster(Hoster):
return size <= traffic
- def getConfig(self, option, default=''): #@TODO: Remove in 0.4.10
+ def getConfig(self, option, default=''): # @TODO: Remove in 0.4.10
"""getConfig with default value - sublass may not implements all config options"""
try:
return self.getConf(option)
@@ -747,7 +747,7 @@ class SimpleHoster(Hoster):
return
self.premium = False
self.account = None
- self.req = self.core.requestFactory.getRequest(self.__name)
+ self.req = self.core.requestFactory.getRequest(self.__class__.__name__)
self.retries = 0
raise Retry(_("Fallback to free download"))
diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py
index 4cef261df..92ec020a6 100644
--- a/pyload/plugin/internal/XFSHoster.py
+++ b/pyload/plugin/internal/XFSHoster.py
@@ -25,6 +25,7 @@ class XFSHoster(SimpleHoster):
("stickell" , "l.stickell@yahoo.it"),
("Walter Purcaro", "vuolter@gmail.com")]
+
HOSTER_DOMAIN = None
TEXT_ENCODING = False
diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py
index fd7caf46f..f04c6906b 100644
--- a/pyload/webui/app/pyloadweb.py
+++ b/pyload/webui/app/pyloadweb.py
@@ -239,33 +239,28 @@ def get_download(path):
return static_file(fs_encode(path), fs_encode(root))
-__TYPES = ("account", "addon", "container", "crypter", "extractor", "hook", "hoster", "internal", "ocr")
-__TYPE_REPLACES = (('_account', ' (Account)'), ('_addon', ' (Addon)'), ('_container', ''), ('_crypter', ' (Crypter)'), ('_extractor', ''), ('_hook', ' (Hook)'), ('_hoster', ' (Hoster)'))
-
-
@route('/settings')
@login_required('SETTINGS')
def config():
conf = PYLOAD.getConfig()
plugin = PYLOAD.getPluginConfig()
-
conf_menu = []
plugin_menu = []
for entry in sorted(conf.keys()):
conf_menu.append((entry, conf[entry].description))
+ last_name = None
for entry in sorted(plugin.keys()):
desc = plugin[entry].description
name, none, type = desc.partition("_")
- if type in __TYPES:
- if len([a for a, b in plugin.iteritems() if b.description.startswith(name + "_")]) > 1:
- for search, repl in __TYPE_REPLACES:
- if desc.endswith(search):
- desc = desc.replace(search, repl)
- break
+
+ if type in PYLOAD.core.pluginManager.TYPES:
+ if name != last_name or len([a for a, b in plugin.iteritems() if b.description.startswith(name + "_")]) > 1:
+ desc = name + " (" + type.title() + ")"
else:
desc = name
+ last_name = name
plugin_menu.append((entry, desc))
accs = PYLOAD.getAccounts(False)