diff options
Diffstat (limited to 'pyload/manager')
-rw-r--r-- | pyload/manager/Account.py | 11 | ||||
-rw-r--r-- | pyload/manager/Addon.py | 4 | ||||
-rw-r--r-- | pyload/manager/Captcha.py | 9 | ||||
-rw-r--r-- | pyload/manager/Plugin.py | 4 | ||||
-rw-r--r-- | pyload/manager/Remote.py | 7 | ||||
-rw-r--r-- | pyload/manager/Thread.py | 30 | ||||
-rw-r--r-- | pyload/manager/event/Scheduler.py | 9 | ||||
-rw-r--r-- | pyload/manager/thread/Addon.py | 10 | ||||
-rw-r--r-- | pyload/manager/thread/Decrypter.py | 16 | ||||
-rw-r--r-- | pyload/manager/thread/Download.py | 22 | ||||
-rw-r--r-- | pyload/manager/thread/Info.py | 16 | ||||
-rw-r--r-- | pyload/manager/thread/Plugin.py | 14 |
12 files changed, 74 insertions, 78 deletions
diff --git a/pyload/manager/Account.py b/pyload/manager/Account.py index ac9944134..ad770a1a8 100644 --- a/pyload/manager/Account.py +++ b/pyload/manager/Account.py @@ -2,14 +2,15 @@ from __future__ import with_statement -from os.path import exists -from shutil import copy +import shutil +import threading -from threading import Lock +from os.path import exists from pyload.manager.Event import AccountUpdateEvent from pyload.utils import chmod, lock + ACC_VERSION = 1 @@ -20,7 +21,7 @@ class AccountManager(object): """Constructor""" self.core = core - self.lock = Lock() + self.lock = threading.Lock() self.initPlugins() self.saveAccounts() #: save to add categories to conf @@ -73,7 +74,7 @@ class AccountManager(object): version = content[0].split(":")[1].strip() if content else "" if not version or int(version) < ACC_VERSION: - copy("accounts.conf", "accounts.backup") + shutil.copy("accounts.conf", "accounts.backup") f.seek(0) f.write("version: " + str(ACC_VERSION)) diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py index 2a3bc4318..2b3d1c456 100644 --- a/pyload/manager/Addon.py +++ b/pyload/manager/Addon.py @@ -4,8 +4,8 @@ import __builtin__ +import threading import traceback -from threading import RLock, Thread from types import MethodType @@ -59,7 +59,7 @@ class AddonManager(object): self.addEvent("pluginConfigChanged", self.manageAddon) - self.lock = RLock() + self.lock = threading.RLock() self.createIndex() diff --git a/pyload/manager/Captcha.py b/pyload/manager/Captcha.py index ab9f79b37..748f2e425 100644 --- a/pyload/manager/Captcha.py +++ b/pyload/manager/Captcha.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- # @author: RaNaN, mkaay +import threading +import traceback + from time import time -from traceback import print_exc -from threading import Lock from pyload.utils import encode @@ -11,7 +12,7 @@ from pyload.utils import encode class CaptchaManager(object): def __init__(self, core): - self.lock = Lock() + self.lock = threading.Lock() self.core = core self.tasks = [] #: task store, for outgoing tasks only self.ids = 0 #: only for internal purpose @@ -61,7 +62,7 @@ class CaptchaManager(object): plugin.captchaTask(task) except Exception: if self.core.debug: - print_exc() + traceback.print_exc() if task.handler or cli: #: the captcha was handled self.tasks.append(task) diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index c6ba5e81b..0efd238b6 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -4,12 +4,12 @@ from __future__ import with_statement import re import sys +import traceback from itertools import chain from os import listdir, makedirs from os.path import isdir, isfile, join, exists, abspath from sys import version_info -from traceback import print_exc from urllib import unquote from SafeEval import const_eval as literal_eval @@ -287,7 +287,7 @@ class PluginManager(object): self.core.log.error(_("Error importing plugin: [%(type)s] %(name)s (v%(version).2f) | %(errmsg)s") % {'name': name, 'type': type, 'version': plugins[name]['version'], "errmsg": str(e)}) if self.core.debug: - print_exc() + traceback.print_exc() else: plugins[name]['module'] = module # : cache import, maybe unneeded diff --git a/pyload/manager/Remote.py b/pyload/manager/Remote.py index c2d254932..3c6dabefa 100644 --- a/pyload/manager/Remote.py +++ b/pyload/manager/Remote.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- # @author: RaNaN -from threading import Thread -from traceback import print_exc +import traceback class BackendBase(Thread): @@ -22,7 +21,7 @@ class BackendBase(Thread): except Exception, e: self.core.log.error(_("Remote backend error: %s") % e) if self.core.debug: - print_exc() + traceback.print_exc() finally: self.running = False @@ -77,7 +76,7 @@ class RemoteManager(object): except Exception, e: self.core.log.error(_("Failed loading backend %(name)s | %(error)s") % {"name": b, "error": str(e)}) if self.core.debug: - print_exc() + traceback.print_exc() else: backend.start() self.backends.append(backend) diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py index a2a64c38d..ecfcb3e26 100644 --- a/pyload/manager/Thread.py +++ b/pyload/manager/Thread.py @@ -1,20 +1,22 @@ # -*- coding: utf-8 -*- # @author: RaNaN -from os.path import exists, join +import random import re -from subprocess import Popen -from threading import Event, Lock -from time import sleep, time -from traceback import print_exc -from random import choice +import threading +import traceback import pycurl +from os.path import exists, join +from random import choice +from subprocess import Popen +from time import sleep, time + +from pyload.datatype.File import PyFile from pyload.manager.thread.Decrypter import DecrypterThread from pyload.manager.thread.Download import DownloadThread from pyload.manager.thread.Info import InfoThread -from pyload.datatype.File import PyFile from pyload.network.RequestFactory import getURL from pyload.utils import freeSpace, lock @@ -31,11 +33,11 @@ class ThreadManager(object): self.pause = True - self.reconnecting = Event() + self.reconnecting = threading.Event() self.reconnecting.clear() self.downloaded = 0 #: number of files downloaded since last cleanup - self.lock = Lock() + self.lock = threading.Lock() # some operations require to fetch url info from hoster, so we caching them so it wont be done twice # contains a timestamp and will be purged after timeout @@ -125,7 +127,7 @@ class ThreadManager(object): self.core.log.error(_("Reconnect Failed: %s") % str(e)) self.reconnecting.clear() if self.core.debug: - print_exc() + traceback.print_exc() self.checkThreadCount() try: @@ -133,7 +135,7 @@ class ThreadManager(object): except Exception, e: self.core.log.warning("Assign job error", e) if self.core.debug: - print_exc() + traceback.print_exc() sleep(0.5) self.assignJob() @@ -187,7 +189,7 @@ class ThreadManager(object): self.core.config.set("reconnect", "activated", False) self.reconnecting.clear() if self.core.debug: - print_exc() + traceback.print_exc() return reconn.wait() @@ -208,7 +210,7 @@ class ThreadManager(object): ip = "" for _i in xrange(10): try: - sv = choice(services) + sv = random.choice(services) ip = getURL(sv[0]) ip = re.match(sv[1], ip).group(1) break @@ -273,7 +275,7 @@ class ThreadManager(object): job.initPlugin() except Exception, e: self.core.log.critical(str(e)) - print_exc() + traceback.print_exc() job.setStatus("failed") job.error = str(e) job.release() diff --git a/pyload/manager/event/Scheduler.py b/pyload/manager/event/Scheduler.py index d67d9063a..d7098ae10 100644 --- a/pyload/manager/event/Scheduler.py +++ b/pyload/manager/event/Scheduler.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- # @author: mkaay -from time import time +import threading + from heapq import heappop, heappush -from threading import Lock, Thread +from time import time class AlreadyCalled(Exception): @@ -99,7 +100,7 @@ class Job(object): def start(self): if self.threaded: - t = Thread(target=self.run) + t = threading.Thread(target=self.run) t.setDaemon(True) t.start() else: @@ -111,7 +112,7 @@ class PriorityQueue(object): def __init__(self): self.queue = [] - self.lock = Lock() + self.lock = threading.Lock() def __iter__(self): diff --git a/pyload/manager/thread/Addon.py b/pyload/manager/thread/Addon.py index b176e4e0c..3cda99950 100644 --- a/pyload/manager/thread/Addon.py +++ b/pyload/manager/thread/Addon.py @@ -1,19 +1,17 @@ # -*- coding: utf-8 -*- # @author: RaNaN +import traceback + from Queue import Queue -from threading import Thread +from copy import copy from os import listdir, stat from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc from pprint import pformat from sys import exc_info, exc_clear -from copy import copy +from time import sleep, time, strftime, gmtime from types import MethodType -from pycurl import error - from pyload.manager.thread.Plugin import PluginThread diff --git a/pyload/manager/thread/Decrypter.py b/pyload/manager/thread/Decrypter.py index 308e94f10..3554feac4 100644 --- a/pyload/manager/thread/Decrypter.py +++ b/pyload/manager/thread/Decrypter.py @@ -1,19 +1,17 @@ # -*- coding: utf-8 -*- # @author: RaNaN +import traceback + from Queue import Queue -from threading import Thread +from copy import copy from os import listdir, stat from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc from pprint import pformat from sys import exc_info, exc_clear -from copy import copy +from time import sleep, time, strftime, gmtime from types import MethodType -from pycurl import error - from pyload.manager.thread.Plugin import PluginThread from pyload.plugin.Plugin import Abort, Fail, Retry @@ -67,7 +65,7 @@ class DecrypterThread(PluginThread): pyfile.error = msg if self.m.core.debug: - print_exc() + traceback.print_exc() return except Abort: @@ -75,7 +73,7 @@ class DecrypterThread(PluginThread): pyfile.setStatus("aborted") if self.m.core.debug: - print_exc() + traceback.print_exc() return except Retry: @@ -90,7 +88,7 @@ class DecrypterThread(PluginThread): pyfile.error = str(e) if self.m.core.debug: - print_exc() + traceback.print_exc() self.writeDebugReport(pyfile) return diff --git a/pyload/manager/thread/Download.py b/pyload/manager/thread/Download.py index 293014a2e..04f73b2ed 100644 --- a/pyload/manager/thread/Download.py +++ b/pyload/manager/thread/Download.py @@ -1,19 +1,19 @@ # -*- coding: utf-8 -*- # @author: RaNaN +import traceback + +import pycurl + from Queue import Queue -from threading import Thread +from copy import copy from os import listdir, stat from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc from pprint import pformat from sys import exc_info, exc_clear -from copy import copy +from time import sleep, time, strftime, gmtime from types import MethodType -from pycurl import error - from pyload.manager.thread.Plugin import PluginThread from pyload.plugin.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload @@ -81,7 +81,7 @@ class DownloadThread(PluginThread): pyfile.setStatus("aborted") if self.m.core.debug: - print_exc() + traceback.print_exc() self.clean(pyfile) continue @@ -116,13 +116,13 @@ class DownloadThread(PluginThread): pyfile.error = msg if self.m.core.debug: - print_exc() + traceback.print_exc() self.m.core.addonManager.downloadFailed(pyfile) self.clean(pyfile) continue - except error, e: + except pycurl.error, e: if len(e.args) == 2: code, msg = e.args else: @@ -156,7 +156,7 @@ class DownloadThread(PluginThread): pyfile.setStatus("failed") self.m.core.log.error("pycurl error %s: %s" % (code, msg)) if self.m.core.debug: - print_exc() + traceback.print_exc() self.writeDebugReport(pyfile) self.m.core.addonManager.downloadFailed(pyfile) @@ -184,7 +184,7 @@ class DownloadThread(PluginThread): pyfile.error = str(e) if self.m.core.debug: - print_exc() + traceback.print_exc() self.writeDebugReport(pyfile) self.m.core.addonManager.downloadFailed(pyfile) diff --git a/pyload/manager/thread/Info.py b/pyload/manager/thread/Info.py index 9d8a3ef5b..856c8facf 100644 --- a/pyload/manager/thread/Info.py +++ b/pyload/manager/thread/Info.py @@ -1,22 +1,20 @@ # -*- coding: utf-8 -*- # @author: RaNaN +import traceback + from Queue import Queue -from threading import Thread +from copy import copy from os import listdir, stat from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc from pprint import pformat from sys import exc_info, exc_clear -from copy import copy +from time import sleep, time, strftime, gmtime from types import MethodType -from pycurl import error - +from pyload.api import OnlineStatus from pyload.datatype.File import PyFile from pyload.manager.thread.Plugin import PluginThread -from pyload.api import OnlineStatus class InfoThread(PluginThread): @@ -90,7 +88,7 @@ class InfoThread(PluginThread): try: data = self.decryptContainer(name, url) except Exception: - print_exc() + traceback.print_exc() self.m.log.error("Could not decrypt container.") data = [] @@ -182,7 +180,7 @@ class InfoThread(PluginThread): except Exception, e: self.m.log.warning(_("Info Fetching for %(name)s failed | %(err)s") % {"name": pluginname, "err": str(e)}) if self.m.core.debug: - print_exc() + traceback.print_exc() # generate default results if err: diff --git a/pyload/manager/thread/Plugin.py b/pyload/manager/thread/Plugin.py index d8319a2ce..2621bc861 100644 --- a/pyload/manager/thread/Plugin.py +++ b/pyload/manager/thread/Plugin.py @@ -3,24 +3,22 @@ from __future__ import with_statement +import traceback + from Queue import Queue -from threading import Thread +from copy import copy from os import listdir, stat from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc from pprint import pformat from sys import exc_info, exc_clear -from copy import copy +from time import sleep, time, strftime, gmtime from types import MethodType -from pycurl import error - +from pyload.api import OnlineStatus from pyload.datatype.File import PyFile from pyload.plugin.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload from pyload.utils.packagetools import parseNames from pyload.utils import fs_join -from pyload.api import OnlineStatus class PluginThread(Thread): @@ -74,7 +72,7 @@ class PluginThread(Thread): def getDebugDump(self, pyfile): dump = "pyLoad %s Debug Report of %s %s \n\nTRACEBACK:\n %s \n\nFRAMESTACK:\n" % ( - self.m.core.api.getServerVersion(), pyfile.pluginname, pyfile.plugin.__version, format_exc()) + self.m.core.api.getServerVersion(), pyfile.pluginname, pyfile.plugin.__version, traceback.format_exc()) tb = exc_info()[2] stack = [] |