summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-18 18:57:22 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-18 18:57:22 +0200
commit06246da1b087cc99d99ac9e8e3642273971e904c (patch)
treefbbb998f4594a26b32f4aa109d0a6caaeebd3d84 /module/plugins
parentUpdate crypters (diff)
downloadpyload-06246da1b087cc99d99ac9e8e3642273971e904c.tar.xz
Update addons
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/hooks/AntiStandby.py10
-rw-r--r--module/plugins/hooks/AntiVirus.py16
-rw-r--r--module/plugins/hooks/Checksum.py14
-rw-r--r--module/plugins/hooks/DeathByCaptcha.py18
-rw-r--r--module/plugins/hooks/DeleteFinished.py6
-rw-r--r--module/plugins/hooks/HotFolder.py6
-rw-r--r--module/plugins/hooks/MergeFiles.py12
-rw-r--r--module/plugins/hooks/RestartFailed.py2
-rw-r--r--module/plugins/hooks/TransmissionRPC.py8
-rw-r--r--module/plugins/hooks/UpdateManager.py24
10 files changed, 56 insertions, 60 deletions
diff --git a/module/plugins/hooks/AntiStandby.py b/module/plugins/hooks/AntiStandby.py
index aa7a028a5..54db858a3 100644
--- a/module/plugins/hooks/AntiStandby.py
+++ b/module/plugins/hooks/AntiStandby.py
@@ -13,7 +13,7 @@ except ImportError:
pass
from module.plugins.internal.Addon import Addon, Expose
-from module.utils import fs_encode, save_join as fs_join
+from module.plugins.internal.utils import encode, fs_join
class Kernel32(object):
@@ -43,8 +43,6 @@ class AntiStandby(Addon):
TMP_FILE = ".antistandby"
- PERIODICAL_INTERVAL = 5
-
def init(self):
self.pid = None
@@ -155,7 +153,7 @@ class AntiStandby(Addon):
def max_mtime(self, path):
return max(0, 0,
*(os.path.getmtime(fs_join(root, file))
- for root, dirs, files in os.walk(fs_encode(path), topdown=False)
+ for root, dirs, files in os.walk(encode(path), topdown=False)
for file in files))
@@ -168,8 +166,8 @@ class AntiStandby(Addon):
not self.pyload.threadManager.getActiveFiles()):
return
- download_folder = self.pyload.config.get("general", "download_folder")
- if (self.max_mtime(download_folder) - self.mtime) < self.interval:
+ dl_folder = self.pyload.config.get("general", "download_folder")
+ if (self.max_mtime(dl_folder) - self.mtime) < self.interval:
return
self.touch(self.TMP_FILE)
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py
index c68e86c77..e65790d32 100644
--- a/module/plugins/hooks/AntiVirus.py
+++ b/module/plugins/hooks/AntiVirus.py
@@ -11,7 +11,7 @@ except ImportError:
from module.plugins.internal.Addon import Addon, Expose, threaded
from module.plugins.internal.Plugin import exists
-from module.utils import fs_encode, save_join as fs_join
+from module.plugins.internal.utils import encode, fs_join
class AntiVirus(Addon):
@@ -39,8 +39,8 @@ class AntiVirus(Addon):
@Expose
@threaded
def scan(self, pyfile, thread):
- avfile = fs_encode(self.get_config('avfile'))
- avargs = fs_encode(self.get_config('avargs').strip())
+ avfile = encode(self.get_config('avfile'))
+ avargs = encode(self.get_config('avargs').strip())
if not os.path.isfile(avfile):
self.fail(_("Antivirus executable not found"))
@@ -48,12 +48,12 @@ class AntiVirus(Addon):
scanfolder = self.get_config('avtarget') is "folder"
if scanfolder:
- download_folder = self.pyload.config.get("general", "download_folder")
- package_folder = pyfile.package().folder if self.pyload.config.get("general", "folder_per_package") else ""
- target = fs_join(download_folder, package_folder, pyfile.name)
- target_repr = "Folder: " + package_folder or download_folder
+ dl_folder = self.pyload.config.get("general", "download_folder")
+ package_folder = pyfile.package().folder if self.pyload.config.get("general", "folder_per_package") else ""
+ target = fs_join(dl_folder, package_folder, pyfile.name)
+ target_repr = "Folder: " + package_folder or dl_folder
else:
- target = fs_encode(pyfile.plugin.last_download)
+ target = encode(pyfile.plugin.last_download)
target_repr = "File: " + os.path.basename(pyfile.plugin.last_download)
if not exists(target):
diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py
index 4d0493212..3bfd529d8 100644
--- a/module/plugins/hooks/Checksum.py
+++ b/module/plugins/hooks/Checksum.py
@@ -8,7 +8,7 @@ import re
import zlib
from module.plugins.internal.Addon import Addon
-from module.utils import save_join as fs_join, fs_encode
+from module.plugins.internal.utils import encode, fs_join
def compute_checksum(local_file, algorithm):
@@ -103,9 +103,9 @@ class Checksum(Addon):
if not pyfile.plugin.last_download:
self.check_failed(pyfile, None, "No file downloaded")
- local_file = fs_encode(pyfile.plugin.last_download)
- # download_folder = self.pyload.config.get("general", "download_folder")
- # local_file = fs_encode(fs_join(download_folder, pyfile.package().folder, pyfile.name))
+ local_file = encode(pyfile.plugin.last_download)
+ # dl_folder = self.pyload.config.get("general", "download_folder")
+ # local_file = encode(fs_join(dl_folder, pyfile.package().folder, pyfile.name))
if not os.path.isfile(local_file):
self.check_failed(pyfile, None, "File does not exist")
@@ -166,7 +166,7 @@ class Checksum(Addon):
def package_finished(self, pypack):
- download_folder = fs_join(self.pyload.config.get("general", "download_folder"), pypack.folder, "")
+ dl_folder = fs_join(self.pyload.config.get("general", "download_folder"), pypack.folder, "")
for link in pypack.getChildren().values():
file_type = os.path.splitext(link['name'])[1][1:].lower()
@@ -174,7 +174,7 @@ class Checksum(Addon):
if file_type not in self.formats:
continue
- hash_file = fs_encode(fs_join(download_folder, link['name']))
+ hash_file = encode(fs_join(dl_folder, link['name']))
if not os.path.isfile(hash_file):
self.log_warning(_("File not found"), link['name'])
continue
@@ -186,7 +186,7 @@ class Checksum(Addon):
data = m.groupdict()
self.log_debug(link['name'], data)
- local_file = fs_encode(fs_join(download_folder, data['NAME']))
+ local_file = encode(fs_join(dl_folder, data['NAME']))
algorithm = self.methods.get(file_type, file_type)
checksum = compute_checksum(local_file, algorithm)
diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py
index 00d6453a4..02c867c1f 100644
--- a/module/plugins/hooks/DeathByCaptcha.py
+++ b/module/plugins/hooks/DeathByCaptcha.py
@@ -8,7 +8,7 @@ import time
from base64 import b64encode
-from module.common.json_layer import json_loads
+from module.plugins.internal.utils import json
from module.network.HTTPRequest import BadHeader
from module.network.RequestFactory import getRequest as get_request
from module.plugins.internal.Addon import Addon, threaded
@@ -80,13 +80,13 @@ class DeathByCaptcha(Addon):
res = None
try:
- json = self.load("%s%s" % (self.API_URL, api),
+ html = self.load("%s%s" % (self.API_URL, api),
post=post,
multipart=multipart,
req=req)
- self.log_debug(json)
- res = json_loads(json)
+ self.log_debug(html)
+ res = json.loads(html)
if "error" in res:
raise DeathByCaptchaException(res['error'])
@@ -94,14 +94,18 @@ class DeathByCaptcha(Addon):
raise DeathByCaptchaException(str(res))
except BadHeader, e:
- if 403 is e.code:
+ if e.code is 403:
raise DeathByCaptchaException('not-logged-in')
- elif 413 is e.code:
+
+ elif e.code is 413:
raise DeathByCaptchaException('invalid-captcha')
- elif 503 is e.code:
+
+ elif e.code is 503:
raise DeathByCaptchaException('service-overload')
+
elif e.code in (400, 405):
raise DeathByCaptchaException('invalid-request')
+
else:
raise
diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py
index e72439c0a..923d79201 100644
--- a/module/plugins/hooks/DeleteFinished.py
+++ b/module/plugins/hooks/DeleteFinished.py
@@ -22,10 +22,6 @@ class DeleteFinished(Addon):
PERIODICAL_INTERVAL = 1 * 60 * 60 #: 1 hour
- def activate(self):
- self.start_periodical()
-
-
def periodical(self):
if not self.info['sleep']:
deloffline = self.get_config('deloffline')
@@ -43,7 +39,7 @@ class DeleteFinished(Addon):
def activate(self):
self.info['sleep'] = True
- self.interval = max(self.PERIODICAL_INTERVAL, self.get_config('interval') * 60 * 60)
+ self.set_interval(self.get_config('interval') * 60 * 60)
self.add_event('package_finished', self.wakeup)
diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py
index c7631a1fc..07e46e163 100644
--- a/module/plugins/hooks/HotFolder.py
+++ b/module/plugins/hooks/HotFolder.py
@@ -7,7 +7,7 @@ import shutil
import time
from module.plugins.internal.Addon import Addon
-from module.utils import fs_encode, save_join as fs_join
+from module.plugins.internal.utils import encode, fs_join
class HotFolder(Addon):
@@ -32,8 +32,8 @@ class HotFolder(Addon):
def periodical(self):
- folder = fs_encode(self.get_config('folder'))
- file = fs_encode(self.get_config('file'))
+ folder = encode(self.get_config('folder'))
+ file = encode(self.get_config('file'))
try:
if not os.path.isdir(os.path.join(folder, "finished")):
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
index a7d6fc7ba..98f10aa00 100644
--- a/module/plugins/hooks/MergeFiles.py
+++ b/module/plugins/hooks/MergeFiles.py
@@ -6,7 +6,7 @@ import os
import re
from module.plugins.internal.Addon import Addon, threaded
-from module.utils import save_join as fs_join
+from module.plugins.internal.utils import fs_join
class MergeFiles(Addon):
@@ -37,15 +37,15 @@ class MergeFiles(Addon):
files[data['name'][:-4]].sort()
fid_dict[data['name']] = fid
- download_folder = self.pyload.config.get("general", "download_folder")
+ dl_folder = self.pyload.config.get("general", "download_folder")
if self.pyload.config.get("general", "folder_per_package"):
- download_folder = fs_join(download_folder, pack.folder)
+ dl_folder = fs_join(dl_folder, pack.folder)
for name, file_list in files.items():
self.log_info(_("Starting merging of"), name)
- with open(fs_join(download_folder, name), "wb") as final_file:
+ with open(fs_join(dl_folder, name), "wb") as final_file:
for splitted_file in file_list:
self.log_debug("Merging part", splitted_file)
@@ -54,9 +54,9 @@ class MergeFiles(Addon):
pyfile.setStatus("processing")
try:
- with open(fs_join(download_folder, splitted_file), "rb") as s_file:
+ with open(fs_join(dl_folder, splitted_file), "rb") as s_file:
size_written = 0
- s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file)))
+ s_file_size = int(os.path.getsize(os.path.join(dl_folder, splitted_file)))
while True:
f_buffer = s_file.read(self.BUFFER_SIZE)
if f_buffer:
diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py
index 74d570425..8e9a5900d 100644
--- a/module/plugins/hooks/RestartFailed.py
+++ b/module/plugins/hooks/RestartFailed.py
@@ -26,4 +26,4 @@ class RestartFailed(Addon):
def activate(self):
- self.start_periodical(self.get_config('interval') * 60)
+ self.set_interval(self.get_config('interval') * 60)
diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py
index 9df19e320..d0c7271a7 100644
--- a/module/plugins/hooks/TransmissionRPC.py
+++ b/module/plugins/hooks/TransmissionRPC.py
@@ -5,7 +5,7 @@ import re
import pycurl
-from module.common.json_layer import json_loads, json_dumps
+from module.plugins.internal.utils import json
from module.network.HTTPRequest import BadHeader
from module.network.RequestFactory import getRequest as get_request
from module.plugins.internal.Addon import Addon
@@ -47,7 +47,7 @@ class TransmissionRPC(Addon):
try:
response = self.load(transmission_rpc_url,
- post=json_dumps({'arguments': {'filename': url},
+ post=json.dumps({'arguments': {'filename': url},
'method' : 'torrent-add',
'tag' : client_request_id}),
req=req)
@@ -59,7 +59,7 @@ class TransmissionRPC(Addon):
req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id])
try:
response = self.load(transmission_rpc_url,
- post=json_dumps({'arguments': {'filename': url},
+ post=json.dumps({'arguments': {'filename': url},
'method' : 'torrent-add',
'tag' : client_request_id}),
req=req)
@@ -77,7 +77,7 @@ class TransmissionRPC(Addon):
return
try:
- res = json_loads(response)
+ res = json.loads(response)
if "result" in res:
self.log_debug("Result: %s" % res['result'])
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index caebdaa9b..c93288060 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -10,7 +10,7 @@ import time
from module.plugins.internal.Addon import Expose, Addon, threaded
from module.plugins.internal.Plugin import exists
-from module.utils import fs_encode, save_join as fs_join
+from module.plugins.internal.utils import encode, fs_join
class UpdateManager(Addon):
@@ -34,9 +34,8 @@ class UpdateManager(Addon):
_VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)')
- SERVER_URL = "http://updatemanager.pyload.org"
-
- PERIODICAL_INTERVAL = 3 * 60 * 60 #: 3 hours
+ SERVER_URL = "http://updatemanager.pyload.org"
+ CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours
def activate(self):
@@ -66,7 +65,6 @@ class UpdateManager(Addon):
def all_downloads_processed(self):
if self.do_restart is True:
- self.log_warning(_("Downloads are done, restarting pyLoad to reload the updated plugins"))
self.pyload.api.restart()
@@ -79,7 +77,7 @@ class UpdateManager(Addon):
return
if self.get_config('checkperiod') and \
- time.time() - max(self.PERIODICAL_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']:
+ time.time() - max(self.CHECK_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']:
self.update()
@@ -129,7 +127,7 @@ class UpdateManager(Addon):
get={'v': self.pyload.api.getServerVersion()})
except Exception:
- self.log_warning(_("Unable to retrieve server to get updates"))
+ self.log_warning(_("Unable to connect to the server to retrieve updates"))
else:
res = html.splitlines()
@@ -156,7 +154,7 @@ class UpdateManager(Addon):
self.pyload.api.restart()
else:
self.do_restart = True
- self.log_warning(_("Downloads are active, will restart once the download is done"))
+ self.log_warning(_("pyLoad restart scheduled"), _("Downloads are active, pyLoad restart postponed once the download is done"))
self.pyload.api.pauseServer()
@@ -170,11 +168,11 @@ class UpdateManager(Addon):
exitcode = 0
elif newversion == "None":
- self.log_info(_("No new pyLoad version available"))
+ self.log_info(_("pyLoad is up to date!"))
exitcode = self.update_plugins()
else:
- self.log_info(_("*** New pyLoad Version %s available ***") % newversion)
+ self.log_info(_("*** New pyLoad %s available ***") % newversion)
self.log_info(_("*** Get it here: https://github.com/pyload/pyload/releases ***"))
self.info['pyload'] = True
exitcode = 3
@@ -202,13 +200,13 @@ class UpdateManager(Addon):
if self.pyload.pluginManager.reloadPlugins(updated):
exitcode = 1
else:
- self.log_warning(_("You have to restart pyLoad to reload the updated plugins"))
+ self.log_warning(_("You have to restart pyLoad to use the updated plugins"))
self.info['plugins'] = True
exitcode = 2
self.manager.dispatchEvent("plugin_updated", updated)
else:
- self.log_info(_("*** No plugin updates available ***"))
+ self.log_info(_("All plugins are up to date!"))
exitcode = 0
#: Exit codes:
@@ -311,7 +309,7 @@ class UpdateManager(Addon):
folder = type
with open(fs_join("userplugins", folder, name + ".py"), "wb") as f:
- f.write(fs_encode(content))
+ f.write(encode(content))
updated.append((type, name))
else: