summaryrefslogtreecommitdiffstats
path: root/pyload/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugin')
-rw-r--r--pyload/plugin/Account.py31
-rw-r--r--pyload/plugin/Addon.py4
-rw-r--r--pyload/plugin/Plugin.py29
-rw-r--r--pyload/plugin/account/TusfilesNet.py2
-rw-r--r--pyload/plugin/addon/ClickNLoad.py5
-rw-r--r--pyload/plugin/addon/HotFolder.py5
-rw-r--r--pyload/plugin/addon/IRCInterface.py4
-rw-r--r--pyload/plugin/extractor/UnRar.py6
-rw-r--r--pyload/plugin/hoster/FilerNet.py1
-rw-r--r--pyload/plugin/hoster/GigapetaCom.py1
-rw-r--r--pyload/plugin/hoster/QuickshareCz.py1
-rw-r--r--pyload/plugin/hoster/UnibytesCom.py1
-rw-r--r--pyload/plugin/internal/XFSHoster.py1
13 files changed, 40 insertions, 51 deletions
diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py
index bb8f7d59a..e4bfd76e8 100644
--- a/pyload/plugin/Account.py
+++ b/pyload/plugin/Account.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-from random import choice
-from time import time
-from traceback import print_exc
-from threading import RLock
+import random
+import threading
+import time
+import traceback
from pyload.plugin.Plugin import Base
from pyload.utils import compare_time, parseFileSize, lock
@@ -40,7 +40,7 @@ class Account(Base):
self.manager = manager
self.accounts = {}
self.infos = {} #: cache for account information
- self.lock = RLock()
+ self.lock = threading.RLock()
self.timestamps = {}
self.init()
@@ -65,7 +65,7 @@ class Account(Base):
@lock
def _login(self, user, data):
# set timestamp for login
- self.timestamps[user] = time()
+ self.timestamps[user] = time.time()
req = self.getAccountRequest(user)
try:
@@ -81,7 +81,7 @@ class Account(Base):
"msg": e})
success = data['valid'] = False
if self.core.debug:
- print_exc()
+ traceback.print_exc()
else:
success = True
finally:
@@ -157,16 +157,16 @@ class Account(Base):
raise Exception("Wrong return format")
except Exception, e:
infos = {"error": str(e)}
- print_exc()
+ traceback.print_exc()
if req:
req.close()
self.logDebug("Account Info: %s" % infos)
- infos['timestamp'] = time()
+ infos['timestamp'] = time.time()
self.infos[name] = infos
- elif "timestamp" in self.infos[name] and self.infos[name]['timestamp'] + self.info_threshold * 60 < time():
+ elif "timestamp" in self.infos[name] and self.infos[name]['timestamp'] + self.info_threshold * 60 < time.time():
self.logDebug("Reached timeout for account data")
self.scheduleRefresh(name)
@@ -239,14 +239,14 @@ class Account(Base):
try:
time_data = data['options']['time'][0]
start, end = time_data.split("-")
- if not compare_time(start.split(":"), end.split(":")):
+ if not compare_time.time(start.split(":"), end.split(":")):
continue
except Exception:
self.logWarning(_("Your Time %s has wrong format, use: 1:22-3:44") % time_data)
if user in self.infos:
if "validuntil" in self.infos[user]:
- if self.infos[user]['validuntil'] > 0 and time() > self.infos[user]['validuntil']:
+ if self.infos[user]['validuntil'] > 0 and time.time() > self.infos[user]['validuntil']:
continue
if "trafficleft" in self.infos[user]:
if self.infos[user]['trafficleft'] == 0:
@@ -256,7 +256,8 @@ class Account(Base):
if not usable:
return None, None
- return choice(usable)
+
+ return random.choice(usable)
def canUse(self):
@@ -285,7 +286,7 @@ class Account(Base):
if user in self.infos:
self.logWarning(_("Account %s is expired, checking again in 1h") % user)
- self.infos[user].update({"validuntil": time() - 1})
+ self.infos[user].update({"validuntil": time.time() - 1})
self.scheduleRefresh(user, 60 * 60)
@@ -299,7 +300,7 @@ class Account(Base):
def checkLogin(self, user):
""" checks if user is still logged in """
if user in self.timestamps:
- if self.login_timeout > 0 and self.timestamps[user] + self.login_timeout * 60 < time():
+ if self.login_timeout > 0 and self.timestamps[user] + self.login_timeout * 60 < time.time():
self.logDebug("Reached login timeout for %s" % user)
return self.relogin(user)
else:
diff --git a/pyload/plugin/Addon.py b/pyload/plugin/Addon.py
index 66f2c6379..cf3397002 100644
--- a/pyload/plugin/Addon.py
+++ b/pyload/plugin/Addon.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from traceback import print_exc
+import traceback
from pyload.plugin.Plugin import Base
from pyload.utils import has_method
@@ -94,7 +94,7 @@ class Addon(Base):
except Exception, e:
self.logError(_("Error executing addon: %s") % e)
if self.core.debug:
- print_exc()
+ traceback.print_exc()
self.cb = self.core.scheduler.addJob(self.interval, self._periodical, [threaded], threaded=threaded)
diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py
index a14bb1e9c..26590c9da 100644
--- a/pyload/plugin/Plugin.py
+++ b/pyload/plugin/Plugin.py
@@ -2,14 +2,16 @@
from __future__ import with_statement
-from time import time, sleep
-from random import randint
+import traceback
import os
+import random
import re
+import time
import urllib
import urlparse
+from itertools import islice
from os import remove, makedirs, chmod, stat
from os.path import exists, join
@@ -18,9 +20,6 @@ if os.name != "nt":
from pwd import getpwnam
from grp import getgrnam
-from itertools import islice
-from traceback import print_exc
-
from pyload.utils import fs_decode, fs_encode, safe_filename, fs_join, encode
@@ -198,7 +197,7 @@ class Plugin(Base):
self.chunkLimit = 1
self.resumeDownload = False
- #: time() + wait in seconds
+ #: time.time() + wait in seconds
self.waitUntil = 0
self.waiting = False
@@ -326,7 +325,7 @@ class Plugin(Base):
:param reconnect: True if a reconnect would avoid wait time
"""
wait_time = int(seconds) + 1
- wait_until = time() + wait_time
+ wait_until = time.time() + wait_time
self.logDebug("Set waitUntil to: %f (previous: %f)" % (wait_until, self.pyfile.waitUntil),
"Wait: %d seconds" % wait_time)
@@ -353,19 +352,19 @@ class Plugin(Base):
status = pyfile.status
pyfile.setStatus("waiting")
- self.logInfo(_("Wait: %d seconds") % (pyfile.waitUntil - time()),
+ self.logInfo(_("Wait: %d seconds") % (pyfile.waitUntil - time.time()),
_("Reconnect: %s") % self.wantReconnect)
if self.account:
self.logDebug("Ignore reconnection due account logged")
- while pyfile.waitUntil > time():
+ while pyfile.waitUntil > time.time():
if pyfile.abort:
self.abort()
- sleep(1)
+ time.sleep(1)
else:
- while pyfile.waitUntil > time():
+ while pyfile.waitUntil > time.time():
self.thread.m.reconnecting.wait(2)
if pyfile.abort:
@@ -376,7 +375,7 @@ class Plugin(Base):
self.wantReconnect = False
raise Reconnect
- sleep(1)
+ time.sleep(1)
self.waiting = False
@@ -467,7 +466,7 @@ class Plugin(Base):
img = self.load(url, get=get, post=post, cookies=cookies)
- id = ("%.2f" % time())[-6:].replace(".", "")
+ id = ("%.2f" % time.time())[-6:].replace(".", "")
with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.getClassName(), id, imgtype)), "wb") as tmpCaptcha:
tmpCaptcha.write(img)
@@ -480,7 +479,7 @@ class Plugin(Base):
Ocr = None
if Ocr and not forceUser:
- sleep(randint(3000, 5000) / 1000.0)
+ time.sleep(random.randint(3000, 5000) / 1000.0)
if self.pyfile.abort:
self.abort()
@@ -496,7 +495,7 @@ class Plugin(Base):
if self.pyfile.abort:
captchaManager.removeTask(task)
self.abort()
- sleep(1)
+ time.sleep(1)
captchaManager.removeTask(task)
diff --git a/pyload/plugin/account/TusfilesNet.py b/pyload/plugin/account/TusfilesNet.py
index f651fa0e1..df22a36e6 100644
--- a/pyload/plugin/account/TusfilesNet.py
+++ b/pyload/plugin/account/TusfilesNet.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-import time
-
from pyload.plugin.internal.XFSAccount import XFSAccount
diff --git a/pyload/plugin/addon/ClickNLoad.py b/pyload/plugin/addon/ClickNLoad.py
index 4e1be807d..9e62072ba 100644
--- a/pyload/plugin/addon/ClickNLoad.py
+++ b/pyload/plugin/addon/ClickNLoad.py
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
import socket
+import threading
import time
-from threading import Lock
-
from pyload.plugin.Addon import Addon, threaded
@@ -55,7 +54,7 @@ class ClickNLoad(Addon):
self._server(ip, webport, cnlport)
- lock = Lock()
+ lock = threading.Lock()
lock.acquire()
lock.acquire()
diff --git a/pyload/plugin/addon/HotFolder.py b/pyload/plugin/addon/HotFolder.py
index 14d0a7ce3..f7f543c3a 100644
--- a/pyload/plugin/addon/HotFolder.py
+++ b/pyload/plugin/addon/HotFolder.py
@@ -3,10 +3,9 @@
from __future__ import with_statement
import os
+import shutil
import time
-from shutil import move
-
from pyload.plugin.Addon import Addon
from pyload.utils import fs_encode, fs_join
@@ -65,7 +64,7 @@ class HotFolder(Addon):
continue
newpath = os.path.join(folder, "finished", f if self.getConfig('keep') else "tmp_" + f)
- move(path, newpath)
+ shutil.move(path, newpath)
self.logInfo(_("Added %s from HotFolder") % f)
self.core.api.addPackage(f, [newpath], 1)
diff --git a/pyload/plugin/addon/IRCInterface.py b/pyload/plugin/addon/IRCInterface.py
index 051d30aa9..3cf21b409 100644
--- a/pyload/plugin/addon/IRCInterface.py
+++ b/pyload/plugin/addon/IRCInterface.py
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
-import pycurl
import re
import socket
import ssl
import time
import traceback
+import pycurl
+
from select import select
-from threading import Thread
from pyload.api import PackageDoesNotExists, FileDoesNotExists
from pyload.network.RequestFactory import getURL
diff --git a/pyload/plugin/extractor/UnRar.py b/pyload/plugin/extractor/UnRar.py
index 83821cdc1..2efba9cd4 100644
--- a/pyload/plugin/extractor/UnRar.py
+++ b/pyload/plugin/extractor/UnRar.py
@@ -2,11 +2,9 @@
import os
import re
+import string
import subprocess
-from glob import glob
-from string import digits
-
from pyload.plugin.Extractor import Extractor, ArchiveError, CRCError, PasswordError
from pyload.utils import fs_decode, fs_encode, fs_join
@@ -136,7 +134,7 @@ class UnRar(Extractor):
self.notifyProgress(int(s))
s = ""
# not reading a digit -> therefore restart
- elif c not in digits:
+ elif c not in string.digits:
s = ""
# add digit to progressstring
else:
diff --git a/pyload/plugin/hoster/FilerNet.py b/pyload/plugin/hoster/FilerNet.py
index be8445fad..106dd2ade 100644
--- a/pyload/plugin/hoster/FilerNet.py
+++ b/pyload/plugin/hoster/FilerNet.py
@@ -4,7 +4,6 @@
# http://filer.net/get/ivgf5ztw53et3ogd
# http://filer.net/get/hgo14gzcng3scbvv
-import pycurl
import re
import urlparse
diff --git a/pyload/plugin/hoster/GigapetaCom.py b/pyload/plugin/hoster/GigapetaCom.py
index a85074e79..6314a17c8 100644
--- a/pyload/plugin/hoster/GigapetaCom.py
+++ b/pyload/plugin/hoster/GigapetaCom.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-import pycurl
import random
import re
diff --git a/pyload/plugin/hoster/QuickshareCz.py b/pyload/plugin/hoster/QuickshareCz.py
index 57b419688..9d66147f6 100644
--- a/pyload/plugin/hoster/QuickshareCz.py
+++ b/pyload/plugin/hoster/QuickshareCz.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-import pycurl
import re
from pyload.plugin.internal.SimpleHoster import SimpleHoster
diff --git a/pyload/plugin/hoster/UnibytesCom.py b/pyload/plugin/hoster/UnibytesCom.py
index d8092ae08..4a2592941 100644
--- a/pyload/plugin/hoster/UnibytesCom.py
+++ b/pyload/plugin/hoster/UnibytesCom.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-import pycurl
import re
import urlparse
from pyload.plugin.internal.SimpleHoster import SimpleHoster
diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py
index 06d91f4d6..3f7aeeee8 100644
--- a/pyload/plugin/internal/XFSHoster.py
+++ b/pyload/plugin/internal/XFSHoster.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-import pycurl
import random
import re
from pyload.plugin.captcha.ReCaptcha import ReCaptcha