summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-02 04:22:19 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-02 04:22:19 +0200
commitab695d17397e101447102877cdd282d825051035 (patch)
tree28f9f62ffc57888b76ca32540dbf5af3a4cfc8d0 /module/plugins/internal
parent[UptoboxCom] Fix https://github.com/pyload/pyload/issues/1530 and https://git... (diff)
downloadpyload-ab695d17397e101447102877cdd282d825051035.tar.xz
[Account] Improve parse_traffic method + code cosmetics
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Account.py14
-rw-r--r--module/plugins/internal/OCR.py2
-rw-r--r--module/plugins/internal/Plugin.py10
-rw-r--r--module/plugins/internal/SevenZip.py2
-rw-r--r--module/plugins/internal/SimpleHoster.py10
-rw-r--r--module/plugins/internal/UnRar.py6
6 files changed, 21 insertions, 23 deletions
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index 123241be3..ad78403de 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -5,14 +5,14 @@ import time
import threading
from module.plugins.Plugin import SkipDownload as Skip
-from module.plugins.internal.Plugin import Plugin
-from module.utils import compare_time, lock, parseFileSize as parse_size
+from module.plugins.internal.Plugin import Plugin, parse_size
+from module.utils import compare_time, lock
class Account(Plugin):
__name__ = "Account"
__type__ = "account"
- __version__ = "0.52"
+ __version__ = "0.53"
__status__ = "testing"
__description__ = """Base account plugin"""
@@ -391,11 +391,9 @@ class Account(Plugin):
###########################################################################
- def parse_traffic(self, value, unit=None): #@NOTE: Returns kilobytes in 0.4.9
- if not isinstance(unit, basestring):
- unit = "KB"
-
- return parse_size(value, unit) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
+ def parse_traffic(self, size, unit="KB"): #@NOTE: Returns kilobytes in 0.4.9
+ size = re.search(r'(\d*[\.,]?\d+)', size).group(1) #@TODO: Recjeck in 0.4.10
+ return parse_size(size, unit) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
def fail_login(self, msg=_("Login handshake has failed")):
diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py
index 3e5afae69..884639b6b 100644
--- a/module/plugins/internal/OCR.py
+++ b/module/plugins/internal/OCR.py
@@ -94,7 +94,7 @@ class OCR(Plugin):
self.pyload.log_debug("Saving tiff...")
self.image.save(tmpTif.name, 'TIFF')
- if os.name == "nt":
+ if os.name is "nt":
tessparams = [os.path.join(pypath, "tesseract", "tesseract.exe")]
else:
tessparams = ["tesseract"]
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 24cff70c3..6d94ca1e4 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -11,12 +11,12 @@ import traceback
import urllib
import urlparse
-if os.name != "nt":
+if os.name is not "nt":
import grp
import pwd
from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload as Skip #@TODO: Remove in 0.4.10
-from module.utils import fs_encode, fs_decode, html_unescape, save_join as fs_join
+from module.utils import fs_encode, fs_decode, html_unescape, parseFileSize as parse_size, save_join as fs_join
#@TODO: Move to utils in 0.4.10
@@ -45,7 +45,7 @@ def encode(string, encoding='utf8'):
#@TODO: Move to utils in 0.4.10
def exists(path):
if os.path.exists(path):
- if os.name == "nt":
+ if os.name is "nt":
dir, name = os.path.split(path.rstrip(os.sep))
return name in os.listdir(dir)
else:
@@ -228,7 +228,7 @@ def chunks(iterable, size):
class Plugin(object):
__name__ = "Plugin"
__type__ = "plugin"
- __version__ = "0.43"
+ __version__ = "0.44"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -314,7 +314,7 @@ class Plugin(object):
self.log_warning(_("Setting path mode failed"), e)
try:
- if os.name != "nt" and self.pyload.config.get("permission", "change_dl"):
+ if os.name is not "nt" and self.pyload.config.get("permission", "change_dl"):
uid = pwd.getpwnam(self.pyload.config.get("permission", "user"))[2]
gid = grp.getgrnam(self.pyload.config.get("permission", "group"))[2]
os.chown(path, uid, gid)
diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py
index 7ed64ecdf..f73e935e8 100644
--- a/module/plugins/internal/SevenZip.py
+++ b/module/plugins/internal/SevenZip.py
@@ -38,7 +38,7 @@ class SevenZip(UnRar):
@classmethod
def find(cls):
try:
- if os.name == "nt":
+ if os.name is "nt":
cls.CMD = os.path.join(pypath, "7z.exe")
p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 5d6892ec5..e5526a7bd 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -16,7 +16,7 @@ from module.utils import fixup, fs_encode, parseFileSize as parse_size
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.92"
+ __version__ = "1.93"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -314,8 +314,8 @@ class SimpleHoster(Hoster):
pass
self.log_warning(_("Check result: ") + errmsg, _("Waiting 1 minute and retry"))
- self.wantReconnect = True
- self.retry(wait=60, msg=errmsg)
+ self.wait(60, reconnect=True)
+ self.restart(errmsg, premium=True)
else:
if self.CHECK_FILE:
self.log_debug("Using custom check rules...")
@@ -401,8 +401,8 @@ class SimpleHoster(Hoster):
self.fail(_("File can be downloaded by premium users only"))
else:
- self.wantReconnect = True
- self.retry(wait=60, msg=errmsg)
+ self.wait(60, reconnect=True)
+ self.restart(errmsg, premium=True)
elif self.WAIT_PATTERN:
m = re.search(self.WAIT_PATTERN, self.html)
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 7efecc5ef..908689109 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -12,7 +12,7 @@ from module.utils import fs_decode, save_join as fs_join
def renice(pid, value):
- if value and os.name != "nt":
+ if value and os.name is not "nt":
try:
subprocess.Popen(["renice", str(value), str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1)
@@ -49,7 +49,7 @@ class UnRar(Extractor):
@classmethod
def find(cls):
try:
- if os.name == "nt":
+ if os.name is "nt":
cls.CMD = os.path.join(pypath, "RAR.exe")
else:
cls.CMD = "rar"
@@ -61,7 +61,7 @@ class UnRar(Extractor):
except OSError:
try:
- if os.name == "nt":
+ if os.name is "nt":
cls.CMD = os.path.join(pypath, "UnRAR.exe")
else:
cls.CMD = "unrar"