summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-12 02:44:03 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-12 03:22:38 +0200
commitf8cf65d4271254dd89662cb6190adc5b426c6d2b (patch)
tree3197abaa2f3a7f1fdc4f2edcd1844087780c066a
parent'from time' -> 'import time' and so on... (diff)
downloadpyload-f8cf65d4271254dd89662cb6190adc5b426c6d2b.tar.xz
'from time' -> 'import time' and so on... (2)
-rw-r--r--docs/resources/logo.pngbin39315 -> 39312 bytes
-rw-r--r--locale/pavement.py32
-rwxr-xr-xpyload/Core.py34
-rw-r--r--pyload/Thread/Addon.py2
-rw-r--r--pyload/Thread/Decrypter.py4
-rw-r--r--pyload/Thread/Download.py4
-rw-r--r--pyload/Thread/Info.py2
-rw-r--r--pyload/Thread/Plugin.py4
-rw-r--r--pyload/api/__init__.py5
-rw-r--r--pyload/config/Setup.py4
-rw-r--r--pyload/manager/Plugin.py1
-rw-r--r--pyload/manager/Thread.py6
-rw-r--r--pyload/network/Browser.py4
-rw-r--r--pyload/network/CookieJar.py5
-rw-r--r--pyload/network/HTTPDownload.py5
-rw-r--r--pyload/network/HTTPRequest.py4
-rw-r--r--pyload/plugin/captcha/ReCaptcha.py5
-rw-r--r--pyload/plugin/crypter/DlProtectCom.py5
-rw-r--r--pyload/plugin/hook/Captcha9Kw.py5
-rw-r--r--pyload/plugin/hook/DeathByCaptcha.py6
-rw-r--r--pyload/plugin/hook/ExpertDecoders.py6
-rw-r--r--pyload/plugin/hook/ImageTyperz.py6
-rw-r--r--pyload/plugin/hoster/MegaCoNz.py5
-rw-r--r--pyload/remote/ClickNLoadBackend.py4
-rw-r--r--pyload/utils/__init__.py4
-rw-r--r--pyload/webui/app/cnl.py4
-rw-r--r--pyload/webui/app/pyloadweb.py17
-rw-r--r--tests/test_json.py12
28 files changed, 91 insertions, 104 deletions
diff --git a/docs/resources/logo.png b/docs/resources/logo.png
index d20084847..7265e7f2c 100644
--- a/docs/resources/logo.png
+++ b/docs/resources/logo.png
Binary files differ
diff --git a/locale/pavement.py b/locale/pavement.py
index 2a238a968..4a9b523be 100644
--- a/locale/pavement.py
+++ b/locale/pavement.py
@@ -9,13 +9,13 @@ from paver.doctools import cog
import glob
import os
-import sys
import shutil
+import sys
import re
+import subprocess
+import tempfile
import urllib
-from tempfile import mkdtemp
-from subprocess import call, Popen, PIPE
from zipfile import ZipFile
PROJECT_DIR = path(__file__).dirname()
@@ -105,7 +105,7 @@ def html():
"""Build html documentation"""
module = path("docs") / "pyload"
pyload.rmtree()
- call_task('paver.doctools.html')
+ subprocess.call_task('paver.doctools.html')
@task
@@ -182,7 +182,7 @@ def thrift(options):
print "running", cmd
- p = Popen(cmd)
+ p = subprocess.Popen(cmd)
p.communicate()
(outdir / "thriftgen").rmtree()
@@ -200,8 +200,8 @@ def compile_js():
root = path("pyload") / "web" / "media" / "js"
for f in root.glob("*.coffee"):
print "generate", f
- coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE)
- yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE)
+ coffee = subprocess.Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE)
+ yui = subprocess.Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE)
coffee.stdout.close()
content = yui.communicate()[0]
with open(root / f.name.replace(".coffee", ".js"), "wb") as js:
@@ -257,7 +257,7 @@ def generate_locale():
def upload_translations(options):
""" Uploads the locale files to translation server """
- tmp = path(mkdtemp())
+ tmp = path(tempfile.mkdtemp())
shutil.shutil.copy('locale/crowdin.yaml', tmp)
os.mkdir(tmp / 'pyLoad')
@@ -272,7 +272,7 @@ def upload_translations(options):
with open(config, 'wb') as f:
f.write(content)
- call(['crowdin-cli', '-c', config, 'upload', 'source'])
+ subprocess.call(['crowdin-cli', '-c', config, 'upload', 'source'])
shutil.rmtree(tmp)
@@ -287,7 +287,7 @@ def upload_translations(options):
def download_translations(options):
""" Downloads the translated files from translation server """
- tmp = path(mkdtemp())
+ tmp = path(tempfile.mkdtemp())
shutil.shutil.copy('locale/crowdin.yaml', tmp)
os.mkdir(tmp / 'pyLoad')
@@ -302,7 +302,7 @@ def download_translations(options):
with open(config, 'wb') as f:
f.write(content)
- call(['crowdin-cli', '-c', config, 'download'])
+ subprocess.call(['crowdin-cli', '-c', config, 'download'])
for language in (tmp / 'pyLoad').listdir():
if not language.isdir():
@@ -327,12 +327,12 @@ def compile_translations():
for f in glob.glob(language / 'LC_MESSAGES' / '*.po'):
print "Compiling %s" % f
- call(['msgfmt', '-o', f.replace('.po', '.mo'), f])
+ subprocess.call(['msgfmt', '-o', f.replace('.po', '.mo'), f])
@task
def tests():
- call(["nosetests2"])
+ subprocess.call(["nosetests2"])
@task
@@ -341,7 +341,7 @@ def virtualenv(options):
if path(options.dir).exists():
return
- call([options.virtual, "--no-site-packages", "--python", options.python, options.dir])
+ subprocess.call([options.virtual, "--no-site-packages", "--python", options.python, options.dir])
print "$ source %s/bin/activate" % options.dir
@@ -358,7 +358,7 @@ def clean_env():
def env_install():
"""Install pyLoad into the virtualenv"""
venv = options.virtualenv
- call([path(venv.dir) / "bin" / "easy_install", "."])
+ subprocess.call([path(venv.dir) / "bin" / "easy_install", "."])
@task
@@ -398,7 +398,7 @@ def makepot(domain, p, excludes=[], includes="", endings=[".py"], xxargs=[]):
if p:
f.write(walk_trans(path(p), excludes, endings))
- call(["xgettext", "--files-from=includes.txt", "--default-domain=%s" % domain] + xargs + xxargs)
+ subprocess.call(["xgettext", "--files-from=includes.txt", "--default-domain=%s" % domain] + xargs + xxargs)
# replace charset und move file
with open("%s.po" % domain, "rb") as f:
diff --git a/pyload/Core.py b/pyload/Core.py
index 1e938f01c..eb6a968b4 100755
--- a/pyload/Core.py
+++ b/pyload/Core.py
@@ -4,8 +4,8 @@
from __future__ import with_statement
+import __builtin__
import logging
-import logging.handlers
import os
import signal
import subprocess
@@ -13,14 +13,12 @@ import sys
import time
import traceback
-import __builtin__
import pyload
import pyload.utils.pylgettext as gettext
from codecs import getwriter
from getopt import getopt, GetoptError
from imp import find_module
-from sys import argv, executable, exit
from pyload import remote
from pyload.Database import DatabaseBackend, FileHandler
@@ -63,7 +61,7 @@ class Core(object):
for option, argument in options:
if option in ("-v", "--version"):
print "pyLoad", pyload.__version__
- exit()
+ sys.exit()
elif option in ("-p", "--pidfile"):
self.pidfile = argument
elif option == "--daemon":
@@ -72,7 +70,7 @@ class Core(object):
self.deleteLinks = True
elif option in ("-h", "--help"):
self.print_help()
- exit()
+ sys.exit()
elif option in ("-d", "--debug"):
self.doDebug = True
elif option in ("-u", "--user"):
@@ -81,42 +79,42 @@ class Core(object):
self.config = ConfigParser()
s = Setup(self.config)
s.set_user()
- exit()
+ sys.exit()
elif option in ("-s", "--setup"):
from pyload.config.Setup import SetupAssistant as Setup
self.config = ConfigParser()
s = Setup(self.config)
s.start()
- exit()
+ sys.exit()
elif option == "--changedir":
from pyload.config.Setup import SetupAssistant as Setup
self.config = ConfigParser()
s = Setup(self.config)
s.conf_path(True)
- exit()
+ sys.exit()
elif option in ("-q", "--quit"):
self.quitInstance()
- exit()
+ sys.exit()
elif option == "--status":
pid = self.isAlreadyRunning()
if self.isAlreadyRunning():
print pid
- exit(0)
+ sys.exit(0)
else:
print "false"
- exit(1)
+ sys.exit(1)
elif option == "--clean":
self.cleanTree()
- exit()
+ sys.exit()
elif option == "--no-remote":
self.remote = False
except GetoptError:
print 'Unknown Argument(s) "%s"' % " ".join(argv[1:])
self.print_help()
- exit()
+ sys.exit()
def print_help(self):
@@ -267,7 +265,7 @@ class Core(object):
if not res:
reshutil.move("pyload.conf")
- exit()
+ sys.exit()
try: signal.signal(signal.SIGQUIT, self.quit)
except Exception:
@@ -286,7 +284,7 @@ class Core(object):
pid = self.isAlreadyRunning()
if pid:
print _("pyLoad already running with pid %s") % pid
- exit()
+ sys.exit()
if os.name != "nt" and self.config.get("general", "renice"):
os.system("renice %d %d" % (self.config.get("general", "renice"), os.getpid()))
@@ -455,7 +453,7 @@ class Core(object):
def init_logger(self, level):
- self.log = logging.getLogger("log")
+ self.log = logging.logging.getLogger("log")
self.log.setLevel(level)
date_fmt = "%Y-%m-%d %H:%M:%S"
@@ -531,7 +529,7 @@ class Core(object):
except Exception:
if essential:
self.log.info(_("Install %s") % legend)
- exit()
+ sys.exit()
return False
@@ -571,7 +569,7 @@ class Core(object):
else:
print _("could not create %(desc)s: %(name)s") % {"desc": description, "name": tmp_name}
if essential:
- exit()
+ sys.exit()
def isClientConnected(self):
diff --git a/pyload/Thread/Addon.py b/pyload/Thread/Addon.py
index 0b46345e8..35168f615 100644
--- a/pyload/Thread/Addon.py
+++ b/pyload/Thread/Addon.py
@@ -2,13 +2,13 @@
# @author: RaNaN
import os
+import sys
import time
import traceback
from Queue import Queue
from copy import copy
from pprint import pformat
-from sys import exc_info, exc_clear
from types import MethodType
from pyload.Thread.Plugin import PluginThread
diff --git a/pyload/Thread/Decrypter.py b/pyload/Thread/Decrypter.py
index 83403e8fa..b0c4d44e8 100644
--- a/pyload/Thread/Decrypter.py
+++ b/pyload/Thread/Decrypter.py
@@ -2,13 +2,13 @@
# @author: RaNaN
import os
+import sys
import time
import traceback
from Queue import Queue
from copy import copy
from pprint import pformat
-from sys import exc_info, exc_clear
from types import MethodType
from pyload.Thread.Plugin import PluginThread
@@ -98,7 +98,7 @@ class DecrypterThread(PluginThread):
self.active = False
self.m.core.files.save()
self.m.localThreads.remove(self)
- exc_clear()
+ sys.exc_clear()
if not retry:
pyfile.delete()
diff --git a/pyload/Thread/Download.py b/pyload/Thread/Download.py
index d7a55ad24..c7c2470dd 100644
--- a/pyload/Thread/Download.py
+++ b/pyload/Thread/Download.py
@@ -2,6 +2,7 @@
# @author: RaNaN
import os
+import sys
import time
import traceback
@@ -10,7 +11,6 @@ import pycurl
from Queue import Queue
from copy import copy
from pprint import pformat
-from sys import exc_info, exc_clear
from types import MethodType
from pyload.Thread.Plugin import PluginThread
@@ -193,7 +193,7 @@ class DownloadThread(PluginThread):
finally:
self.m.core.files.save()
pyfile.checkIfProcessed()
- exc_clear()
+ sys.exc_clear()
# pyfile.plugin.req.clean()
diff --git a/pyload/Thread/Info.py b/pyload/Thread/Info.py
index 09b562659..36779a962 100644
--- a/pyload/Thread/Info.py
+++ b/pyload/Thread/Info.py
@@ -2,13 +2,13 @@
# @author: RaNaN
import os
+import sys
import time
import traceback
from Queue import Queue
from copy import copy
from pprint import pformat
-from sys import exc_info, exc_clear
from types import MethodType
from pyload.api import OnlineStatus
diff --git a/pyload/Thread/Plugin.py b/pyload/Thread/Plugin.py
index 9d61c9a12..c7350a735 100644
--- a/pyload/Thread/Plugin.py
+++ b/pyload/Thread/Plugin.py
@@ -4,6 +4,7 @@
from __future__ import with_statement
import os
+import sys
import threading
import time
import traceback
@@ -11,7 +12,6 @@ import traceback
from Queue import Queue
from copy import copy
from pprint import pformat
-from sys import exc_info, exc_clear
from types import MethodType
from pyload.api import OnlineStatus
@@ -74,7 +74,7 @@ class PluginThread(threading.Thread):
dump = "pyLoad %s Debug Report of %s %s \n\nTRACEBACK:\n %s \n\nFRAMESTACK:\n" % (
self.m.core.api.getServerVersion(), pyfile.pluginname, pyfile.plugin.__version, traceback.format_exc())
- tb = exc_info()[2]
+ tb = sys.exc_info()[2]
stack = []
while tb:
stack.append(tb.tb_frame)
diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py
index 01586bc4a..55c21572f 100644
--- a/pyload/api/__init__.py
+++ b/pyload/api/__init__.py
@@ -3,13 +3,12 @@
from __future__ import with_statement
+import base64
import os
import re
import time
import urlparse
-from base64 import standard_b64encode
-
from pyload.Datatype import PyFile
from pyload.utils.packagetools import parseNames
from pyload.network.RequestFactory import getURL
@@ -821,7 +820,7 @@ class Api(Iface):
if task:
task.setWatingForUser(exclusive=exclusive)
data, type, result = task.getCaptcha()
- ctask = CaptchaTask(int(task.id), standard_b64encode(data), type, result)
+ ctask = CaptchaTask(int(task.id), base64.standard_b64encode(data), type, result)
return ctask
return CaptchaTask(-1)
diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py
index 7e3fbffec..1486eadca 100644
--- a/pyload/config/Setup.py
+++ b/pyload/config/Setup.py
@@ -5,10 +5,10 @@ from __future__ import with_statement
import __builtin__
import os
+import subprocess
import sys
from getpass import getpass
-from subprocess import PIPE, call
from pyload.network.JsEngine import JsEngine
from pyload.utils import get_console_encoding, load_translation, fs_join, versiontuple
@@ -481,7 +481,7 @@ class SetupAssistant(object):
def check_prog(self, command):
pipe = PIPE
try:
- call(command, stdout=pipe, stderr=pipe)
+ subprocess.call(command, stdout=pipe, stderr=pipe)
return True
except Exception:
return False
diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py
index 36213eb7a..02ecc89a5 100644
--- a/pyload/manager/Plugin.py
+++ b/pyload/manager/Plugin.py
@@ -9,7 +9,6 @@ import traceback
import urllib
from itertools import chain
-from sys import version_info
from SafeEval import const_eval as literal_eval
diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py
index 0acfd4751..b80c5594a 100644
--- a/pyload/manager/Thread.py
+++ b/pyload/manager/Thread.py
@@ -4,15 +4,13 @@
import os
import random
import re
+import subprocess
import threading
import time
import traceback
import pycurl
-from random import choice
-from subprocess import Popen
-
from pyload.Datatype import PyFile
from pyload.Thread import DecrypterThread, DownloadThread, InfoThread
from pyload.network.RequestFactory import getURL
@@ -181,7 +179,7 @@ class ThreadManager(object):
self.core.log.debug("Old IP: %s" % ip)
try:
- reconn = Popen(self.core.config.get("reconnect", "method"), bufsize=-1, shell=True) # , stdout=subprocess.PIPE)
+ reconn = subprocess.Popen(self.core.config.get("reconnect", "method"), bufsize=-1, shell=True) # , stdout=subprocess.PIPE)
except Exception:
self.core.log.warning(_("Failed executing reconnect script!"))
self.core.config.set("reconnect", "activated", False)
diff --git a/pyload/network/Browser.py b/pyload/network/Browser.py
index 482c2320a..77524c26f 100644
--- a/pyload/network/Browser.py
+++ b/pyload/network/Browser.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from logging import getLogger
+import logging
from pyload.network.HTTPRequest import HTTPRequest
from pyload.network.HTTPDownload import HTTPDownload
@@ -11,7 +11,7 @@ class Browser(object):
def __init__(self, bucket=None, options={}):
- self.log = getLogger("log")
+ self.log = logging.getLogger("log")
self.options = options #: holds pycurl options
self.bucket = bucket
diff --git a/pyload/network/CookieJar.py b/pyload/network/CookieJar.py
index 8c8d4c87b..e4d3424d8 100644
--- a/pyload/network/CookieJar.py
+++ b/pyload/network/CookieJar.py
@@ -2,14 +2,13 @@
# @author: RaNaN
import Cookie
+import datetime
import time
-from datetime import datetime, timedelta
-
# monkey patch for 32 bit systems
def _getdate(future=0, weekdayname=Cookie._weekdayname, monthname=Cookie._monthname):
- dt = datetime.now() + timedelta(seconds=int(future))
+ dt = datetime.datetime.now() + datetime.timedelta(seconds=int(future))
return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \
(weekdayname[dt.weekday()], dt.day, monthname[dt.month], dt.year, dt.hour, dt.minute, dt.second)
diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py
index 959ffd111..e5917aa1f 100644
--- a/pyload/network/HTTPDownload.py
+++ b/pyload/network/HTTPDownload.py
@@ -3,14 +3,13 @@
from __future__ import with_statement
+import logging
import os
import shutil
import time
import pycurl
-from logging import getLogger
-
from pyload.network.HTTPChunk import ChunkInfo, HTTPChunk
from pyload.network.HTTPRequest import BadHeader
from pyload.plugin.Plugin import Abort
@@ -39,7 +38,7 @@ class HTTPDownload(object):
self.chunks = []
- self.log = getLogger("log")
+ self.log = logging.getLogger("log")
try:
self.info = ChunkInfo.load(filename)
diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py
index 14c5b8cb6..a27c59ff2 100644
--- a/pyload/network/HTTPRequest.py
+++ b/pyload/network/HTTPRequest.py
@@ -3,13 +3,13 @@
from __future__ import with_statement
+import logging
import urllib
import pycurl
from codecs import getincrementaldecoder, lookup, BOM_UTF8
from httplib import responses
-from logging import getLogger
from cStringIO import StringIO
from pyload.plugin.Plugin import Abort, Fail
@@ -59,7 +59,7 @@ class HTTPRequest(object):
self.c.setopt(pycurl.WRITEFUNCTION, self.write)
self.c.setopt(pycurl.HEADERFUNCTION, self.writeHeader)
- self.log = getLogger("log")
+ self.log = logging.getLogger("log")
def initHandle(self):
diff --git a/pyload/plugin/captcha/ReCaptcha.py b/pyload/plugin/captcha/ReCaptcha.py
index dc431f2ea..37da91a58 100644
--- a/pyload/plugin/captcha/ReCaptcha.py
+++ b/pyload/plugin/captcha/ReCaptcha.py
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
+import base64
import random
import re
import time
import urlparse
-from base64 import b64encode
-
from pyload.plugin.Captcha import Captcha
@@ -176,7 +175,7 @@ class ReCaptcha(Captcha):
get={'c':token3.group(1), 'k':key},
cookies=True,
forceUser=True)
- response = b64encode('{"response":"%s"}' % captcha_response)
+ response = base64.b64encode('{"response":"%s"}' % captcha_response)
self.logDebug("Result: %s" % response)
diff --git a/pyload/plugin/crypter/DlProtectCom.py b/pyload/plugin/crypter/DlProtectCom.py
index eae6d1d83..757f7d592 100644
--- a/pyload/plugin/crypter/DlProtectCom.py
+++ b/pyload/plugin/crypter/DlProtectCom.py
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
+import base64
import re
import time
-from base64 import urlsafe_b64encode
-
from pyload.plugin.internal.SimpleCrypter import SimpleCrypter
@@ -42,7 +41,7 @@ class DlProtectCom(SimpleCrypter):
else:
mstime = int(round(time.time() * 1000))
- b64time = "_" + urlsafe_b64encode(str(mstime)).replace("=", "%3D")
+ b64time = "_" + base64.urlsafe_b64encode(str(mstime)).replace("=", "%3D")
post_req.update({'i' : b64time,
'submitform': "Decrypt+link"})
diff --git a/pyload/plugin/hook/Captcha9Kw.py b/pyload/plugin/hook/Captcha9Kw.py
index 9ceab4b2b..32aaba0f5 100644
--- a/pyload/plugin/hook/Captcha9Kw.py
+++ b/pyload/plugin/hook/Captcha9Kw.py
@@ -2,11 +2,10 @@
from __future__ import with_statement
+import base64
import re
import time
-from base64 import b64encode
-
from pyload.network.HTTPRequest import BadHeader
from pyload.network.RequestFactory import getURL
@@ -121,7 +120,7 @@ class Captcha9Kw(Hook):
'source' : "pyload",
'base64' : "1",
'mouse' : 1 if task.isPositional() else 0,
- 'file-upload-01': b64encode(data),
+ 'file-upload-01': base64.b64encode(data),
'action' : "usercaptchaupload"}
for _i in xrange(5):
diff --git a/pyload/plugin/hook/DeathByCaptcha.py b/pyload/plugin/hook/DeathByCaptcha.py
index 670807bf5..ddcdeae8a 100644
--- a/pyload/plugin/hook/DeathByCaptcha.py
+++ b/pyload/plugin/hook/DeathByCaptcha.py
@@ -2,11 +2,11 @@
from __future__ import with_statement
-import pycurl
+import base64
import re
import time
-from base64 import b64encode
+import pycurl
from pyload.utils import json_loads
from pyload.network.HTTPRequest import BadHeader
@@ -139,7 +139,7 @@ class DeathByCaptcha(Hook):
multipart = False
with open(captcha, 'rb') as f:
data = f.read()
- data = "base64:" + b64encode(data)
+ data = "base64:" + base64.b64encode(data)
res = self.api_response("captcha", {"captchafile": data}, multipart)
diff --git a/pyload/plugin/hook/ExpertDecoders.py b/pyload/plugin/hook/ExpertDecoders.py
index 0727c0407..2e05e7386 100644
--- a/pyload/plugin/hook/ExpertDecoders.py
+++ b/pyload/plugin/hook/ExpertDecoders.py
@@ -2,10 +2,10 @@
from __future__ import with_statement
-import pycurl
+import base64
import uuid
-from base64 import b64encode
+import pycurl
from pyload.network.HTTPRequest import BadHeader
from pyload.network.RequestFactory import getURL, getRequest
@@ -62,7 +62,7 @@ class ExpertDecoders(Hook):
result = req.load(self.API_URL,
post={'action' : "upload",
'key' : self.getConfig('passkey'),
- 'file' : b64encode(data),
+ 'file' : base64.b64encode(data),
'gen_task_id': ticket})
finally:
req.close()
diff --git a/pyload/plugin/hook/ImageTyperz.py b/pyload/plugin/hook/ImageTyperz.py
index 3f0147776..039710436 100644
--- a/pyload/plugin/hook/ImageTyperz.py
+++ b/pyload/plugin/hook/ImageTyperz.py
@@ -2,10 +2,10 @@
from __future__ import with_statement
-import pycurl
+import base64
import re
-from base64 import b64encode
+import pycurl
from pyload.network.RequestFactory import getURL, getRequest
from pyload.plugin.Hook import Hook, threaded
@@ -81,7 +81,7 @@ class ImageTyperz(Hook):
multipart = False
with open(captcha, 'rb') as f:
data = f.read()
- data = b64encode(data)
+ data = base64.b64encode(data)
res = req.load(self.SUBMIT_URL,
post={'action': "UPLOADCAPTCHA",
diff --git a/pyload/plugin/hoster/MegaCoNz.py b/pyload/plugin/hoster/MegaCoNz.py
index 2d7b40d98..2e6735ee6 100644
--- a/pyload/plugin/hoster/MegaCoNz.py
+++ b/pyload/plugin/hoster/MegaCoNz.py
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
import array
+import base64
import os
# import pycurl
import random
import re
-from base64 import standard_b64decode
-
from Crypto.Cipher import AES
from Crypto.Util import Counter
@@ -64,7 +63,7 @@ class MegaCoNz(Hoster):
def b64_decode(self, data):
data = data.replace("-", "+").replace("_", "/")
- return standard_b64decode(data + '=' * (-len(data) % 4))
+ return base64.standard_b64decode(data + '=' * (-len(data) % 4))
def getCipherKey(self, key):
diff --git a/pyload/remote/ClickNLoadBackend.py b/pyload/remote/ClickNLoadBackend.py
index f0c988d73..d9db5b845 100644
--- a/pyload/remote/ClickNLoadBackend.py
+++ b/pyload/remote/ClickNLoadBackend.py
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# @author: RaNaN
+import base64
import re
import urllib
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from cgi import FieldStorage
-from base64 import standard_b64decode
from binascii import unhexlify
try:
@@ -131,7 +131,7 @@ class CNLHandler(BaseHTTPRequestHandler):
crypted = self.get_post("crypted")
jk = self.get_post("jk")
- crypted = standard_b64decode(urllib.unquote(crypted.replace(" ", "+")))
+ crypted = base64.standard_b64decode(urllib.unquote(crypted.replace(" ", "+")))
jk = "%s f()" % jk
jk = js.eval(jk)
Key = unhexlify(jk)
diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py
index 99c470048..864a214cc 100644
--- a/pyload/utils/__init__.py
+++ b/pyload/utils/__init__.py
@@ -6,6 +6,7 @@
import bitmath
import os
import re
+import string
import sys
import time
import urllib
@@ -13,7 +14,6 @@ import urllib
# from gettext import gettext
import pylgettext as gettext
from htmlentitydefs import name2codepoint
-from string import maketrans
# abstraction layer for json operations
try:
@@ -56,7 +56,7 @@ def remove_chars(string, repl):
return string
else:
if type(string) == str:
- return string.translate(maketrans("", ""), repl)
+ return string.translate(string.maketrans("", ""), repl)
elif type(string) == unicode:
return string.translate(dict((ord(s), None) for s in repl))
diff --git a/pyload/webui/app/cnl.py b/pyload/webui/app/cnl.py
index c02e0d1ff..7202a2db4 100644
--- a/pyload/webui/app/cnl.py
+++ b/pyload/webui/app/cnl.py
@@ -2,11 +2,11 @@
from __future__ import with_statement
+import base64
import os
import re
import urllib
-from base64 import standard_b64decode
from binascii import unhexlify
from bottle import route, request, HTTPError
@@ -80,7 +80,7 @@ def addcrypted2():
crypted = request.forms['crypted']
jk = request.forms['jk']
- crypted = standard_b64decode(urllib.unquote(crypted.replace(" ", "+")))
+ crypted = base64.standard_b64decode(urllib.unquote(crypted.replace(" ", "+")))
if JS:
jk = "%s f()" % jk
jk = JS.eval(jk)
diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py
index 316717b26..8974e0896 100644
--- a/pyload/webui/app/pyloadweb.py
+++ b/pyload/webui/app/pyloadweb.py
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
# @author: RaNaN
+import datetime
import os
import sys
import time
import urllib
-from datetime import datetime
from operator import itemgetter, attrgetter
-from sys import getfilesystemencoding
from bottle import route, static_file, request, response, redirect, error
@@ -348,10 +347,10 @@ def os.path(file="", path=""):
for f in folders:
try:
- f = f.decode(getfilesystemencoding())
+ f = f.decode(sys.getfilesystemencoding())
data = {'name': f, 'fullpath': os.path.join(cwd, f)}
data['sort'] = data['fullpath'].lower()
- data['modified'] = datetime.fromtimestamp(int(os.path.getmtime(os.path.join(cwd, f))))
+ data['modified'] = datetime.datetime.fromtimestamp(int(os.path.getmtime(os.path.join(cwd, f))))
data['ext'] = os.path.splitext(f)[1]
except Exception:
continue
@@ -401,7 +400,7 @@ def logs(item=-1):
if request.environ.get('REQUEST_METHOD', "GET") == "POST":
try:
- fro = datetime.strptime(request.forms['from'], '%d.%m.%Y %H:%M:%S')
+ fro = datetime.datetime.strptime(request.forms['from'], '%d.%m.%Y %H:%M:%S')
except Exception:
pass
try:
@@ -427,7 +426,7 @@ def logs(item=-1):
if item < 1 or type(item) is not int:
item = 1 if len(log) - perpage + 1 < 1 else len(log) - perpage + 1
- if type(fro) is datetime: #: we will search for datetime
+ if type(fro) is datetime.datetime: #: we will search for datetime.datetime
item = -1
data = []
@@ -439,7 +438,7 @@ def logs(item=-1):
if counter >= item:
try:
date, time, level, message = l.decode("utf8", "ignore").split(" ", 3)
- dtime = datetime.strptime(date + ' ' + time, '%Y-%m-%d %H:%M:%S')
+ dtime = datetime.datetime.strptime(date + ' ' + time, '%Y-%m-%d %H:%M:%S')
except Exception:
dtime = None
date = '?'
@@ -447,7 +446,7 @@ def logs(item=-1):
level = '?'
message = l
if item == -1 and dtime is not None and fro <= dtime:
- item = counter #: found our datetime
+ item = counter #: found our datetime.datetime
if item >= 0:
data.append({'line': counter, 'date': date + " " + time, 'level': level, 'message': message})
perpagecheck += 1
@@ -457,7 +456,7 @@ def logs(item=-1):
break
if fro is None: #: still not set, empty log?
- fro = datetime.now()
+ fro = datetime.datetime.now()
if reversed:
data.reverse()
return render_to_response('logs.html', {'warning': warning, 'log': data, 'from': fro.strftime('%d.%m.%Y %H:%M:%S'),
diff --git a/tests/test_json.py b/tests/test_json.py
index 82a2a3d07..de2914182 100644
--- a/tests/test_json.py
+++ b/tests/test_json.py
@@ -1,11 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+import json
+import logging
import urllib
import urllib2
-from json import loads
-from logging import log
url = "http://localhost:8001/api/%s"
@@ -16,18 +16,18 @@ class TestJson(object):
if not post: post = {}
post['session'] = self.key
u = urllib2.urlopen(url % name, data=urlencode(post))
- return loads(u.read())
+ return json.loads(u.read())
def setUp(self):
u = urllib2.urlopen(url % "login", data=urlencode({"username": "TestUser", "password": "pwhere"}))
- self.key = loads(u.read())
+ self.key = json.loads(u.read())
assert self.key is not False
def test_wronglogin(self):
u = urllib2.urlopen(url % "login", data=urlencode({"username": "crap", "password": "wrongpw"}))
- assert loads(u.read()) is False
+ assert json.loads(u.read()) is False
def test_access(self):
@@ -41,7 +41,7 @@ class TestJson(object):
def test_status(self):
ret = self.call("statusServer")
- log(1, str(ret))
+ logging.log(1, str(ret))
assert "pause" in ret
assert "queue" in ret