summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-12-31 15:40:01 +0100
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-12-31 15:40:01 +0100
commit3f4a19e7869afb0c856ccffc1124339899fd464b (patch)
treebb07fdc01379ff977f5c8843accaa4749d29bad5 /module
parent[Addon] Fix download_finished call (diff)
downloadpyload-3f4a19e7869afb0c856ccffc1124339899fd464b.tar.xz
Spare code fixed + isdownload -> isresource
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hooks/DeathByCaptcha.py6
-rw-r--r--module/plugins/hooks/TransmissionRPC.py2
-rw-r--r--module/plugins/hoster/GoogledriveCom.py2
-rw-r--r--module/plugins/hoster/Http.py2
-rw-r--r--module/plugins/hoster/TusfilesNet.py2
-rw-r--r--module/plugins/internal/Base.py2
-rw-r--r--module/plugins/internal/Hoster.py2
-rw-r--r--module/plugins/internal/Plugin.py44
-rw-r--r--module/plugins/internal/SimpleHoster.py2
9 files changed, 35 insertions, 29 deletions
diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py
index 62cfe7d16..7e50a97f3 100644
--- a/module/plugins/hooks/DeathByCaptcha.py
+++ b/module/plugins/hooks/DeathByCaptcha.py
@@ -94,13 +94,13 @@ class DeathByCaptcha(Addon):
raise DeathByCaptchaException(str(res))
except BadHeader, e:
- if e.code is 403:
+ if e.code == 403:
raise DeathByCaptchaException('not-logged-in')
- elif e.code is 413:
+ elif e.code == 413:
raise DeathByCaptchaException('invalid-captcha')
- elif e.code is 503:
+ elif e.code == 503:
raise DeathByCaptchaException('service-overload')
elif e.code in (400, 405):
diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py
index f0ef2e9b1..0e71941ef 100644
--- a/module/plugins/hooks/TransmissionRPC.py
+++ b/module/plugins/hooks/TransmissionRPC.py
@@ -53,7 +53,7 @@ class TransmissionRPC(Addon):
req=req)
except Exception, e:
- if isinstance(e, BadHeader) and e.code is 409:
+ if isinstance(e, BadHeader) and e.code == 409:
headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header))
session_id = headers['X-Transmission-Session-Id']
req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id])
diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py
index 659b088c2..617a56c54 100644
--- a/module/plugins/hoster/GoogledriveCom.py
+++ b/module/plugins/hoster/GoogledriveCom.py
@@ -48,7 +48,7 @@ class GoogledriveCom(SimpleHoster):
return
link = self.fixurl(m.group(1), "https://docs.google.com/")
- dl = self.isdownload(link)
+ dl = self.isresource(link)
if dl:
self.link = dl
diff --git a/module/plugins/hoster/Http.py b/module/plugins/hoster/Http.py
index f324ee986..9d03b189b 100644
--- a/module/plugins/hoster/Http.py
+++ b/module/plugins/hoster/Http.py
@@ -29,7 +29,7 @@ class Http(Hoster):
url = re.sub(r'^(jd|py)', "http", pyfile.url)
netloc = urlparse.urlparse(url).netloc
- link = self.isdownload(url)
+ link = self.isresource(url)
if not link:
return
diff --git a/module/plugins/hoster/TusfilesNet.py b/module/plugins/hoster/TusfilesNet.py
index cbab4e856..3bc5b104a 100644
--- a/module/plugins/hoster/TusfilesNet.py
+++ b/module/plugins/hoster/TusfilesNet.py
@@ -40,6 +40,6 @@ class TusfilesNet(XFSHoster):
return super(TusfilesNet, self).download(url, *args, **kwargs)
except BadHeader, e:
- if e.code is 503:
+ if e.code == 503:
self.multiDL = False
raise Retry("503")
diff --git a/module/plugins/internal/Base.py b/module/plugins/internal/Base.py
index b2c4acd0a..9c355d5de 100644
--- a/module/plugins/internal/Base.py
+++ b/module/plugins/internal/Base.py
@@ -459,7 +459,7 @@ class Base(Plugin):
try:
id = frame.f_back.f_lineno
finally:
- del frame
+ del frame #: Delete the frame or it wont be cleaned
if id not in self.retries:
self.retries[id] = 0
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index 428313ef8..d164a9557 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -158,7 +158,7 @@ class Hoster(Base):
self.check_status()
- def isdownload(self, url, redirect=True, resumable=None):
+ def isresource(self, url, redirect=True, resumable=None):
resource = False
maxredirs = 5
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 689573682..f43bf240a 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -117,8 +117,10 @@ class Plugin(object):
def _print_exc(self):
frame = inspect.currentframe()
- print format_exc(frame.f_back)
- del frame
+ try:
+ print format_exc(frame.f_back)
+ finally:
+ del frame
def remove(self, path, trash=False): #@TODO: Change to `trash=True` in 0.4.10
@@ -220,23 +222,7 @@ class Plugin(object):
self.last_html = html
if self.pyload.debug:
- frame = inspect.currentframe()
-
- try:
- framefile = fsjoin("tmp", self.classname, "%s_line%s.dump.html"
- % (frame.f_back.f_code.co_name, frame.f_back.f_lineno))
-
- if not exists(os.path.join("tmp", self.classname)):
- os.makedirs(os.path.join("tmp", self.classname))
-
- with open(framefile, "wb") as f:
- f.write(encode(html))
-
- except IOError, e:
- self.log_error(e)
-
- finally:
- del frame #: Delete the frame or it wont be cleaned
+ self.dump_html()
#@TODO: Move to network in 0.4.10
header = {'code': req.code}
@@ -250,6 +236,26 @@ class Plugin(object):
return html
+ def dump_html(self):
+ frame = inspect.currentframe()
+
+ try:
+ framefile = fsjoin("tmp", self.classname, "%s_line%s.dump.html"
+ % (frame.f_back.f_code.co_name, frame.f_back.f_lineno))
+
+ if not exists(os.path.join("tmp", self.classname)):
+ os.makedirs(os.path.join("tmp", self.classname))
+
+ with open(framefile, "wb") as f:
+ f.write(encode(self.last_html))
+
+ except IOError, e:
+ self.log_error(e)
+
+ finally:
+ del frame #: Delete the frame or it wont be cleaned
+
+
def clean(self):
"""
Remove references
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index dc4adfc5d..a00b6e3fb 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -437,7 +437,7 @@ class SimpleHoster(Hoster):
def handle_direct(self, pyfile):
- self.link = pyfile.url if self.isdownload(pyfile.url) else None
+ self.link = pyfile.url if self.isresource(pyfile.url) else None
def handle_multi(self, pyfile): #: Multi-hoster handler