From e1baccf1ec914563d3b2b845906cce024e7cd3b1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 13 Jan 2015 23:14:50 +0100 Subject: Replace 'except' with 'except Exception' --- module/plugins/accounts/AlldebridCom.py | 2 +- module/plugins/accounts/CatShareNet.py | 4 ++-- module/plugins/accounts/NoPremiumPl.py | 4 ++-- module/plugins/accounts/RapideoPl.py | 4 ++-- module/plugins/accounts/RehostTo.py | 8 ++++---- module/plugins/captcha/LinksaveIn.py | 2 +- module/plugins/captcha/captcha.py | 6 +++--- module/plugins/container/LinkList.py | 4 ++-- module/plugins/crypter/ChipDe.py | 2 +- module/plugins/crypter/Go4UpCom.py | 2 +- module/plugins/crypter/LinkCryptWs.py | 2 +- module/plugins/crypter/NCryptIn.py | 2 +- module/plugins/crypter/RelinkUs.py | 4 ++-- module/plugins/crypter/ShareLinksBiz.py | 2 +- module/plugins/hooks/ExternalScripts.py | 2 +- module/plugins/hooks/IRCInterface.py | 8 ++++---- module/plugins/hooks/ImageTyperz.py | 2 +- module/plugins/hooks/UpdateManager.py | 4 ++-- module/plugins/hooks/XMPPInterface.py | 6 +++--- module/plugins/hoster/DepositfilesCom.py | 2 +- module/plugins/hoster/FilesMailRu.py | 2 +- module/plugins/hoster/FourSharedCom.py | 2 +- module/plugins/hoster/Ftp.py | 2 +- module/plugins/hoster/MediafireCom.py | 2 +- module/plugins/hoster/ShareonlineBiz.py | 2 +- module/plugins/hoster/YibaishiwuCom.py | 2 +- module/plugins/internal/UnRar.py | 2 +- 27 files changed, 43 insertions(+), 43 deletions(-) diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 1f2371e28..c830f0c09 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -37,7 +37,7 @@ class AlldebridCom(Account): exp_data[1]) * 60 * 60 + (int(exp_data[2]) - 1) * 60 #Get expiration date from API - except: + except Exception: data = self.getAccountData(user) html = req.load("http://www.alldebrid.com/api.php", get={'action': "info_user", 'login': user, 'pw': data['password']}) diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py index bcb14bee3..90cdfe013 100644 --- a/module/plugins/accounts/CatShareNet.py +++ b/module/plugins/accounts/CatShareNet.py @@ -31,7 +31,7 @@ class CatShareNet(Account): m = re.search(self.PREMIUM_PATTERN, html) if "Premium" in m.group(1): premium = True - except: + except Exception: pass try: @@ -39,7 +39,7 @@ class CatShareNet(Account): expiredate = m.group(1) if "-" not in expiredate: validuntil = mktime(strptime(expiredate, "%d.%m.%Y")) - except: + except Exception: pass return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py index f2223b7d9..a36b114eb 100644 --- a/module/plugins/accounts/NoPremiumPl.py +++ b/module/plugins/accounts/NoPremiumPl.py @@ -35,7 +35,7 @@ class NoPremiumPl(Account): self._req = req try: result = loads(self.runAuthQuery()) - except: + except Exception: # todo: return or let it be thrown? return @@ -60,7 +60,7 @@ class NoPremiumPl(Account): try: response = loads(self.runAuthQuery()) - except: + except Exception: self.wrongPassword() if "errno" in response.keys(): diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 438ce7ad3..426c680a6 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -35,7 +35,7 @@ class RapideoPl(Account): self._req = req try: result = loads(self.runAuthQuery()) - except: + except Exception: # todo: return or let it be thrown? return @@ -59,7 +59,7 @@ class RapideoPl(Account): self._req = req try: response = loads(self.runAuthQuery()) - except: + except Exception: self.wrongPassword() if "errno" in response.keys(): diff --git a/module/plugins/accounts/RehostTo.py b/module/plugins/accounts/RehostTo.py index 897f888b0..04e71c9ad 100644 --- a/module/plugins/accounts/RehostTo.py +++ b/module/plugins/accounts/RehostTo.py @@ -18,13 +18,13 @@ class RehostTo(Account): trafficleft = None validuntil = -1 session = "" - + html = req.load("http://rehost.to/api.php", get={'cmd' : "login", 'user': user, 'pass': self.getAccountData(user)['password']}) try: session = html.split(",")[1].split("=")[1] - + html = req.load("http://rehost.to/api.php", get={'cmd': "get_premium_credits", 'long_ses': session}) @@ -32,11 +32,11 @@ class RehostTo(Account): self.logDebug(html) else: traffic, valid = html.split(",") - + premium = True trafficleft = self.parseTraffic(traffic + "MB") validuntil = float(valid) - + finally: return {'premium' : premium, 'trafficleft': trafficleft, diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index 56cbd58a0..de6b0e7ff 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -79,7 +79,7 @@ class LinksaveIn(OCR): rgb_c = lut[pix[x, y]] try: cstat[rgb_c] += 1 - except: + except Exception: cstat[rgb_c] = 1 if rgb_bg == rgb_c: stat[bgpath] += 1 diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index 0f233ec00..e89ec2e81 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -102,7 +102,7 @@ class OCR(object): try: with open(tmpTxt.name, 'r') as f: self.result_captcha = f.read().replace("\n", "") - except: + except Exception: self.result_captcha = "" self.logger.debug(self.result_captcha) @@ -111,7 +111,7 @@ class OCR(object): os.remove(tmpTxt.name) if subset and (digits or lowercase or uppercase): os.remove(tmpSub.name) - except: + except Exception: pass @@ -166,7 +166,7 @@ class OCR(object): count += 1 if pixels[x, y-1] != 255: count += 1 - except: + except Exception: pass # not enough neighbors are dark pixels so mark this pixel diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py index c6173ad73..69461249e 100644 --- a/module/plugins/container/LinkList.py +++ b/module/plugins/container/LinkList.py @@ -23,7 +23,7 @@ class LinkList(Container): def decrypt(self, pyfile): try: file_enc = codecs.lookup(self.getConfig("encoding")).name - except: + except Exception: file_enc = "utf-8" file_name = fs_encode(pyfile.url) @@ -64,7 +64,7 @@ class LinkList(Container): try: txt = open(file_name, 'wb') txt.close() - except: + except Exception: self.logWarning(_("LinkList could not be cleared")) for name, links in packages.iteritems(): diff --git a/module/plugins/crypter/ChipDe.py b/module/plugins/crypter/ChipDe.py index 133e5a005..2fc36c355 100644 --- a/module/plugins/crypter/ChipDe.py +++ b/module/plugins/crypter/ChipDe.py @@ -22,7 +22,7 @@ class ChipDe(Crypter): self.html = self.load(pyfile.url) try: f = re.search(r'"(http://video\.chip\.de/.+)"', self.html) - except: + except Exception: self.fail(_("Failed to find the URL")) else: self.urls = [f.group(1)] diff --git a/module/plugins/crypter/Go4UpCom.py b/module/plugins/crypter/Go4UpCom.py index 102bc32b5..a7e16c0ab 100644 --- a/module/plugins/crypter/Go4UpCom.py +++ b/module/plugins/crypter/Go4UpCom.py @@ -40,7 +40,7 @@ class Go4UpCom(SimpleCrypter): for html in pages: try: links.append(re.search(r' 1: args = temp[1:] - except: + except Exception: pass handler = getattr(self, "event_%s" % trigger, self.event_pass) @@ -347,7 +347,7 @@ class IRCInterface(Thread, Hook): return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] - except: + except Exception: # create new package id = self.core.api.addPackage(pack, links, 1) return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))] diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index d448d1be9..768129e4a 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -69,7 +69,7 @@ class ImageTyperz(Hook): try: balance = float(res) - except: + except Exception: raise ImageTyperzException("Invalid response") self.logInfo(_("Account balance: $%s left") % res) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index c72699228..03b9ba6a4 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -117,7 +117,7 @@ class UpdateManager(Hook): def server_request(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() - except: + except Exception: self.logWarning(_("Unable to contact server to get updates")) @@ -192,7 +192,7 @@ class UpdateManager(Hook): # Protect UpdateManager from self-removing try: blacklisted.remove(("hook", "UpdateManager")) - except: + except Exception: pass for t, n in blacklisted: diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index bbeab4341..b8e9fc1ad 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -69,7 +69,7 @@ class XMPPInterface(IRCInterface, JabberClient): try: if self.getConfig("info_pack"): self.announce(_("Package finished: %s") % pypack.name) - except: + except Exception: pass @@ -78,7 +78,7 @@ class XMPPInterface(IRCInterface, JabberClient): if self.getConfig("info_file"): self.announce( _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) - except: + except Exception: pass @@ -152,7 +152,7 @@ class XMPPInterface(IRCInterface, JabberClient): trigger = temp[0] if len(temp) > 1: args = temp[1:] - except: + except Exception: pass handler = getattr(self, "event_%s" % trigger, self.event_pass) diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index 9d060e75d..6e7f2909c 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -95,7 +95,7 @@ class DepositfilesCom(SimpleHoster): try: self.download(link, disposition=True) - except: + except Exception: self.retry(wait_time=60) diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py index 18fca7176..7bd099282 100644 --- a/module/plugins/hoster/FilesMailRu.py +++ b/module/plugins/hoster/FilesMailRu.py @@ -21,7 +21,7 @@ def getInfo(urls): url_pattern = '(.+?)' file_name = re.search(url_pattern, html).group(0).split(', event)">')[1].split('')[0] result.append((file_name, 0, 2, url)) - except: + except Exception: pass # status 1=OFFLINE, 2=OK, 3=UNKNOWN diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 78aeece44..a3f53ac5e 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -53,7 +53,7 @@ class FourSharedCom(SimpleHoster): m = re.search(self.ID_PATTERN, self.html) res = self.load('http://www.4shared.com/web/d2/getFreeDownloadLimitInfo?fileId=%s' % m.group(1)) self.logDebug(res) - except: + except Exception: pass self.wait(20) diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 8562778c4..22fc5f67a 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -35,7 +35,7 @@ class Ftp(Hoster): pyfile.name = parsed_url.path.rpartition('/')[2] try: pyfile.name = unquote(str(pyfile.name)).decode('utf8') - except: + except Exception: pass if not "@" in netloc: diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 81bd36f73..d404498f3 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -33,7 +33,7 @@ def checkHTMLHeader(url): return url, 2 else: break - except: + except Exception: return url, 3 else: return url, 0 diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 636e5824d..5918726f5 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -164,7 +164,7 @@ class ShareonlineBiz(SimpleHoster): try: self.logError(errmsg, re.search(self.ERROR_PATTERN, self.html).group(1)) - except: + except Exception: self.logError("Unknown error occurred", errmsg) if errmsg is "invalid": diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py index adc403de4..cf1550ebc 100644 --- a/module/plugins/hoster/YibaishiwuCom.py +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -50,7 +50,7 @@ class YibaishiwuCom(SimpleHoster): self.logDebug("Trying URL: " + url) self.download(url) break - except: + except Exception: continue else: self.fail(_("No working link found")) diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 572fe95b9..296405101 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -16,7 +16,7 @@ def renice(pid, value): if os.name != "nt" and value: try: Popen(["renice", str(value), str(pid)], stdout=PIPE, stderr=PIPE, bufsize=-1) - except: + except Exception: print "Renice failed" -- cgit v1.2.3