diff options
| author | 2014-11-09 03:12:41 +0100 | |
|---|---|---|
| committer | 2014-11-09 03:12:41 +0100 | |
| commit | 59f72bfc5ed721c80c821bd0ca1bc8daf0d49880 (patch) | |
| tree | 05d0159405f2059bc89b3a55eab8ee4a94871aac /module/plugins | |
| parent | [PluginManager] Fix parse method (diff) | |
| download | pyload-59f72bfc5ed721c80c821bd0ca1bc8daf0d49880.tar.xz | |
Code cosmetics
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/Hook.py | 4 | ||||
| -rw-r--r-- | module/plugins/Hoster.py | 3 | ||||
| -rw-r--r-- | module/plugins/PluginManager.py | 12 | ||||
| -rw-r--r-- | module/plugins/accounts/MegaRapidCz.py | 4 | ||||
| -rw-r--r-- | module/plugins/captcha/captcha.py | 2 | ||||
| -rw-r--r-- | module/plugins/hooks/BypassCaptcha.py | 2 | ||||
| -rw-r--r-- | module/plugins/hooks/CaptchaBrotherhood.py | 2 | ||||
| -rw-r--r-- | module/plugins/hooks/DeathByCaptcha.py | 2 | ||||
| -rw-r--r-- | module/plugins/hooks/ExpertDecoders.py | 2 | ||||
| -rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 8 | ||||
| -rw-r--r-- | module/plugins/hooks/HotFolder.py | 6 | ||||
| -rw-r--r-- | module/plugins/hooks/ImageTyperz.py | 2 | ||||
| -rw-r--r-- | module/plugins/hooks/WindowsPhoneToastNotify.py | 2 | ||||
| -rw-r--r-- | module/plugins/hoster/MegaCoNz.py | 2 | ||||
| -rw-r--r-- | module/plugins/hoster/MegacrypterCom.py | 6 | ||||
| -rw-r--r-- | module/plugins/internal/CaptchaService.py | 6 | 
16 files changed, 31 insertions, 34 deletions
| diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 18b54d8c0..424417752 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -26,7 +26,7 @@ class Hook(Base):      """      __name__    = "Hook"      __type__    = "hook" -    __version__ = "0.02" +    __version__ = "0.03"      __config__ = []  #: [("name", "type", "desc", "default")] @@ -51,7 +51,7 @@ class Hook(Base):          Base.__init__(self, core)          #: Provide information in dict here, usable by API `getInfo` -        self.info = None +        self.info = {}          #: Callback of periodical job task, used by hookmanager          self.cb = None diff --git a/module/plugins/Hoster.py b/module/plugins/Hoster.py index 86e26dfae..be7d75bb9 100644 --- a/module/plugins/Hoster.py +++ b/module/plugins/Hoster.py @@ -19,6 +19,3 @@ class Hoster(Plugin):      __description__ = """Base hoster plugin"""      __license__     = "GPLv3"      __authors__     = [("mkaay", "mkaay@mkaay.de")] - - -    html = None  #: last html loaded diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py index 3085c87e3..43e9f9ad4 100644 --- a/module/plugins/PluginManager.py +++ b/module/plugins/PluginManager.py @@ -67,29 +67,29 @@ class PluginManager:          """          plugins = {} -         +          try:              try:                  pfolder = save_join("userplugins", folder)                  if not exists(pfolder):                      makedirs(pfolder) -                     +                  ifile = join(pfolder, "__init__.py")                  if not exists(ifile):                      f = open(ifile, "a")                      f.close() -                     +              except IOError, e:                  pfolder = join(pypath, "module", "plugins", folder) -                 +          except Exception, e:              self.logCritical(str(e))              return plugins -         +          for f in listdir(pfolder):              if (isfile(join(pfolder, f)) and f.endswith(".py") or f.endswith("_25.pyc") or f.endswith(                  "_26.pyc") or f.endswith("_27.pyc")) and not f.startswith("_"): -                 +                  with open(join(pfolder, f)) as data:                      content = data.read() diff --git a/module/plugins/accounts/MegaRapidCz.py b/module/plugins/accounts/MegaRapidCz.py index 83b1bf86b..440eba8da 100644 --- a/module/plugins/accounts/MegaRapidCz.py +++ b/module/plugins/accounts/MegaRapidCz.py @@ -46,7 +46,7 @@ class MegaRapidCz(Account):      def login(self, user, data, req): -        htm = req.load("http://megarapid.cz/prihlaseni/", cookies=True) +        htm = req.load("http://megarapid.cz/prihlaseni/")          if "Heslo:" in htm:              start = htm.index('id="inp_hash" name="hash" value="')              htm = htm[start + 33:] @@ -56,4 +56,4 @@ class MegaRapidCz(Account):                                   "login": user,                                   "pass1": data['password'],                                   "remember": 0, -                                 "sbmt": u"Přihlásit"}, cookies=True) +                                 "sbmt": u"Přihlásit"}) diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index e0cd7d31c..418c11ffe 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -64,7 +64,7 @@ class OCR(object):              #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt")              tmpTxt = open(join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb")              tmpTxt.close() -             +          except IOError, e:              self.logError(str(e))              return diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 4e287668b..b8b55ac63 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -49,7 +49,7 @@ class BypassCaptcha(Hook):      def setup(self): -        self.info = {} +        self.info = {}  #@TODO: Remove in 0.4.10      def getCredits(self): diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 8033ad544..eb0bd9e67 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -55,7 +55,7 @@ class CaptchaBrotherhood(Hook):      def setup(self): -        self.info = {} +        self.info = {}  #@TODO: Remove in 0.4.10      def getCredits(self): diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 0b584c632..42495f5fb 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -68,7 +68,7 @@ class DeathByCaptcha(Hook):      def setup(self): -        self.info = {} +        self.info = {}  #@TODO: Remove in 0.4.10      def call_api(self, api="captcha", post=False, multipart=False): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index a4ae6fa89..faaba6906 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -30,7 +30,7 @@ class ExpertDecoders(Hook):      def setup(self): -        self.info = {} +        self.info = {}  #@TODO: Remove in 0.4.10      def getCredits(self): diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 39da1ee7b..f5f30fc52 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -309,16 +309,16 @@ class ExtractArchive(Hook):      def reloadPasswords(self):          passwordfile = self.getConfig("passwordfile") -         +          try:              passwords = []              with open(passwordfile, "a+") as f:                  for pw in f.read().splitlines():                      passwords.append(pw) -                     +          except IOError, e:              self.logError(str(e)) -             +          else:              self.passwords = passwords @@ -330,7 +330,7 @@ class ExtractArchive(Hook):          if pw in self.passwords:              self.passwords.remove(pw) -             +          self.passwords.insert(0, pw)          try: diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 5e9dd9547..15a8f43d5 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -31,7 +31,7 @@ class HotFolder(Hook):      def periodical(self):          folder = fs_encode(self.getConfig("folder")) -         +          try:              if not exists(join(folder, "finished")):                  makedirs(join(folder, "finished")) @@ -39,7 +39,7 @@ class HotFolder(Hook):              if self.getConfig("watch_file"):                  with open(fs_encode(self.getConfig("file")), "a+") as f:                      content = f.read().strip() -                     +                  if content:                      name = "%s_%s.txt" % (self.getConfig("file"), time.strftime("%H-%M-%S_%d%b%Y")) @@ -59,6 +59,6 @@ class HotFolder(Hook):                  self.logInfo(_("Added %s from HotFolder") % f)                  self.core.api.addPackage(f, [newpath], 1) -                 +          except IOError, e:              self.logError(str(e)) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index c0a573c5c..8d253c249 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -51,7 +51,7 @@ class ImageTyperz(Hook):      def setup(self): -        self.info = {} +        self.info = {}  #@TODO: Remove in 0.4.10      def getCredits(self): diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index 746aa188d..053ea47d0 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -22,7 +22,7 @@ class WindowsPhoneToastNotify(Hook):      def setup(self): -        self.info = {} +        self.info = {}  #@TODO: Remove in 0.4.10      def getXmlData(self): diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py index 9b120827c..2129fbfc8 100644 --- a/module/plugins/hoster/MegaCoNz.py +++ b/module/plugins/hoster/MegaCoNz.py @@ -78,7 +78,7 @@ class MegaCoNz(Hoster):          file_crypted = self.lastDownload          file_decrypted = file_crypted.rsplit(self.FILE_SUFFIX)[0] -         +          try:              f = open(file_crypted, "rb")              df = open(file_decrypted, "wb") diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py index a097ca506..4034f7d32 100644 --- a/module/plugins/hoster/MegacrypterCom.py +++ b/module/plugins/hoster/MegacrypterCom.py @@ -26,9 +26,9 @@ class MegacrypterCom(MegaCoNz):      def callApi(self, **kwargs):          """ Dispatch a call to the api, see megacrypter.com/api_doc """          self.logDebug("JSON request: " + json_dumps(kwargs)) -        resp = self.load(self.API_URL, post=json_dumps(kwargs)) -        self.logDebug("API Response: " + resp) -        return json_loads(resp) +        res = self.load(self.API_URL, post=json_dumps(kwargs)) +        self.logDebug("API Response: " + res) +        return json_loads(res)      def process(self, pyfile): diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 2143e23df..38775f519 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -91,7 +91,7 @@ class ReCaptcha(CaptchaService):                  self.plugin.fail(errmsg)                  raise TypeError(errmsg) -        js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) +        js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key})          try:              challenge = re.search("challenge : '(.+?)',", js).group(1) @@ -153,7 +153,7 @@ class AdsCaptcha(CaptchaService):          CaptchaId, PublicKey = key -        js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) +        js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey})          try:              challenge = re.search("challenge: '(.+?)',", js).group(1) @@ -192,7 +192,7 @@ class SolveMedia(CaptchaService):                  self.plugin.fail(errmsg)                  raise TypeError(errmsg) -        html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) +        html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key})          try:              challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">',                                    html).group(1) | 
