diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-06-14 17:43:31 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-06-14 17:43:31 +0200 |
commit | ea27af7361bb75d665c29120d9cdc254a209afa8 (patch) | |
tree | d45867d45c4022e5739935948819272608793e47 /module/plugins | |
parent | Merge branch 'pr/n1485_EvolutionClip' into stable (diff) | |
download | pyload-ea27af7361bb75d665c29120d9cdc254a209afa8.tar.xz |
Move new log functions to Plugin
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/internal/Plugin.py | 35 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 41 |
2 files changed, 28 insertions, 48 deletions
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 228685ee5..aef8fd450 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -31,8 +31,8 @@ if os.name != "nt": from itertools import islice -from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload -from module.utils import save_join, save_path, fs_encode, fs_decode +from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload #@TODO: Remove in 0.4.10 +from module.utils import decode, save_join, save_path, fs_encode, fs_decode def chunks(iterable, size): it = iter(iterable) @@ -55,18 +55,35 @@ class Base(object): #: core config self.config = core.config - #log functions + # Log functions + def _log(self, level, args): + log = getattr(self.core.log, level) + msg = " | ".join((fs_encode(a) if isinstance(a, unicode) else #@NOTE: `fs_encode` -> `encode` in 0.4.10 + str(a)).strip() for a in args if a) + log("%(plugin)s[%(id)s]: %(msg)s" % {'plugin': self.__name__, + 'id' : self.pyfile.id, + 'msg' : msg or _(level.upper() + " MARK")}) + + + def logDebug(self, *args): + if self.core.debug: + return self._log("debug", args) + + def logInfo(self, *args): - self.log.info("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args]))) + return self._log("info", args) + def logWarning(self, *args): - self.log.warning("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args]))) + return self._log("warning", args) + def logError(self, *args): - self.log.error("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args]))) + return self._log("error", args) - def logDebug(self, *args): - self.log.debug("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args]))) + + def logCritical(self, *args): + return self._log("critical", args) def setConf(self, option, value): @@ -123,7 +140,7 @@ class Plugin(Base): Overwrite `process` / `decrypt` in your subclassed plugin. """ __name__ = "Plugin" - __version__ = "0.05" + __version__ = "0.06" __pattern__ = None __type__ = "hoster" __config__ = [("name", "type", "desc", "default")] diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 4a3b7dcf7..d1563ac89 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -16,7 +16,7 @@ from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL from module.plugins.internal.Hoster import Hoster from module.plugins.internal.Plugin import Fail, Retry -from module.utils import decode, fixup, fs_encode, html_unescape, parseFileSize +from module.utils import fixup, fs_encode, html_unescape, parseFileSize #@TODO: Adapt and move to PyFile in 0.4.10 @@ -241,7 +241,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.66" + __version__ = "1.67" __pattern__ = r'^unmatchable$' __config__ = [("use_premium", "bool", "Use premium account if available" , True), @@ -428,43 +428,6 @@ class SimpleHoster(Hoster): return info - #@TODO: Move to Hoster in 0.4.10 - def _log(self, level, args): - log = getattr(self.core.log, level) - msg = " | ".join((fs_encode(a) if isinstance(a, unicode) else #@NOTE: `fs_encode` -> `encode` in 0.4.10 - decode(a) if isinstance(a, str) else - str(a)).strip() for a in args if a) - log("%(plugin)s[%(id)s]: %(msg)s" % {'plugin': self.__name__, - 'id' : self.pyfile.id, - 'msg' : msg or _(level.upper() + " MARK")}) - - - #@TODO: Move to Hoster in 0.4.10 - def logDebug(self, *args): - if self.core.debug: - return self._log("debug", args) - - - #@TODO: Move to Hoster in 0.4.10 - def logInfo(self, *args): - return self._log("info", args) - - - #@TODO: Move to Hoster in 0.4.10 - def logWarning(self, *args): - return self._log("warning", args) - - - #@TODO: Move to Hoster in 0.4.10 - def logError(self, *args): - return self._log("error", args) - - - #@TODO: Move to Hoster in 0.4.10 - def logCritical(self, *args): - return self._log("critical", args) - - def setup(self): self.resumeDownload = self.multiDL = self.premium |