diff options
Diffstat (limited to 'pyload')
34 files changed, 83 insertions, 106 deletions
diff --git a/pyload/Database/User.py b/pyload/Database/User.py index dc60ce23a..a91e16cc6 100644 --- a/pyload/Database/User.py +++ b/pyload/Database/User.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # @author: mkaay -from hashlib import sha1 +import hashlib import random from pyload.Database import DatabaseBackend, style @@ -20,7 +20,7 @@ class UserMethods(object): salt = r[2][:5] pw = r[2][5:] - h = sha1(salt + password) + h = hashlib.sha1(salt + password) if h.hexdigest() == pw: return {"id": r[0], "name": r[1], "role": r[3], "permission": r[4], "template": r[5], "email": r[6]} @@ -31,7 +31,7 @@ class UserMethods(object): @style.queue def addUser(db, user, password): salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in xrange(0, 5)]) - h = sha1(salt + password) + h = hashlib.sha1(salt + password) password = salt + h.hexdigest() c = db.c @@ -51,10 +51,10 @@ class UserMethods(object): salt = r[2][:5] pw = r[2][5:] - h = sha1(salt + oldpw) + h = hashlib.sha1(salt + oldpw) if h.hexdigest() == pw: salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in xrange(0, 5)]) - h = sha1(salt + newpw) + h = hashlib.sha1(salt + newpw) password = salt + h.hexdigest() db.c.execute("UPDATE users SET password=? WHERE name=?", (password, user)) diff --git a/pyload/Thread/Addon.py b/pyload/Thread/Addon.py index e28fafd29..24a2fc26a 100644 --- a/pyload/Thread/Addon.py +++ b/pyload/Thread/Addon.py @@ -8,9 +8,6 @@ import sys import time import traceback -from pprint import pformat -from types import MethodType - from pyload.Thread.Plugin import PluginThread diff --git a/pyload/Thread/Decrypter.py b/pyload/Thread/Decrypter.py index d4afac730..5a8cff7c1 100644 --- a/pyload/Thread/Decrypter.py +++ b/pyload/Thread/Decrypter.py @@ -7,9 +7,6 @@ import sys import time import traceback -from pprint import pformat -from types import MethodType - from pyload.Thread.Plugin import PluginThread from pyload.plugin.Plugin import Abort, Fail, Retry diff --git a/pyload/Thread/Download.py b/pyload/Thread/Download.py index c20c7277e..49f6145ce 100644 --- a/pyload/Thread/Download.py +++ b/pyload/Thread/Download.py @@ -9,9 +9,6 @@ import traceback import pycurl -from pprint import pformat -from types import MethodType - from pyload.Thread.Plugin import PluginThread from pyload.plugin.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload diff --git a/pyload/Thread/Info.py b/pyload/Thread/Info.py index 780a384bb..cf76fda4b 100644 --- a/pyload/Thread/Info.py +++ b/pyload/Thread/Info.py @@ -7,9 +7,6 @@ import sys import time import traceback -from pprint import pformat -from types import MethodType - from pyload.Api import OnlineStatus from pyload.Datatype import PyFile from pyload.Thread.Plugin import PluginThread diff --git a/pyload/Thread/Plugin.py b/pyload/Thread/Plugin.py index ee1418a7d..cba82946d 100644 --- a/pyload/Thread/Plugin.py +++ b/pyload/Thread/Plugin.py @@ -9,9 +9,8 @@ import sys import threading import time import traceback - -from pprint import pformat -from types import MethodType +import pprint +import types from pyload.Api import OnlineStatus from pyload.Datatype import PyFile @@ -87,7 +86,7 @@ class PluginThread(threading.Thread): for key, value in frame.f_locals.items(): dump += "\t%20s = " % key try: - dump += pformat(value) + "\n" + dump += pprint.pformat(value) + "\n" except Exception, e: dump += "<ERROR WHILE PRINTING VALUE> " + str(e) + "\n" @@ -99,10 +98,10 @@ class PluginThread(threading.Thread): for name in dir(pyfile.plugin): attr = getattr(pyfile.plugin, name) - if not name.endswith("__") and type(attr) != MethodType: + if not name.endswith("__") and type(attr) != types.MethodType: dump += "\t%20s = " % name try: - dump += pformat(attr) + "\n" + dump += pprint.pformat(attr) + "\n" except Exception, e: dump += "<ERROR WHILE PRINTING VALUE> " + str(e) + "\n" @@ -110,16 +109,16 @@ class PluginThread(threading.Thread): for name in dir(pyfile): attr = getattr(pyfile, name) - if not name.endswith("__") and type(attr) != MethodType: + if not name.endswith("__") and type(attr) != types.MethodType: dump += "\t%20s = " % name try: - dump += pformat(attr) + "\n" + dump += pprint.pformat(attr) + "\n" except Exception, e: dump += "<ERROR WHILE PRINTING VALUE> " + str(e) + "\n" if pyfile.pluginname in self.m.core.config.plugin: dump += "\n\nCONFIG: \n\n" - dump += pformat(self.m.core.config.plugin[pyfile.pluginname]) + "\n" + dump += pprint.pformat(self.m.core.config.plugin[pyfile.pluginname]) + "\n" return dump diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py index 1486eadca..fdf2524f5 100644 --- a/pyload/config/Setup.py +++ b/pyload/config/Setup.py @@ -4,12 +4,11 @@ from __future__ import with_statement import __builtin__ +import getpass import os import subprocess import sys -from getpass import getpass - from pyload.network.JsEngine import JsEngine from pyload.utils import get_console_encoding, load_translation, fs_join, versiontuple @@ -510,7 +509,7 @@ class SetupAssistant(object): pwlen = 8 while p1 != p2: sys.stdout.write(_("Password: ")) - p1 = getpass("").strip("\n\r") + p1 = getpass.getpass("").strip("\n\r") if len(p1) < pwlen: print @@ -524,7 +523,7 @@ class SetupAssistant(object): continue sys.stdout.write(_("Password (again): ")) - p2 = getpass("").strip("\n\r") + p2 = getpass.getpass("").strip("\n\r") if p1 == p2: print diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py index 98b66189a..a632111ea 100644 --- a/pyload/manager/Addon.py +++ b/pyload/manager/Addon.py @@ -6,8 +6,7 @@ import __builtin__ import threading import traceback - -from types import MethodType +import types from pyload.Thread import AddonThread from pyload.manager.Plugin import literal_eval @@ -55,7 +54,7 @@ class AddonManager(object): self.events = {} #: contains events # registering callback for config event - self.core.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) #@TODO: Rename event pluginConfigChanged + self.core.config.pluginCB = types.MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) #@TODO: Rename event pluginConfigChanged self.addEvent("pluginConfigChanged", self.manageAddon) diff --git a/pyload/manager/Scheduler.py b/pyload/manager/Scheduler.py index 630e43022..b82768aff 100644 --- a/pyload/manager/Scheduler.py +++ b/pyload/manager/Scheduler.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- # @author: mkaay +import heapq import threading import time -from heapq import heappop, heappush - class AlreadyCalled(Exception): pass @@ -125,7 +124,7 @@ class PriorityQueue(object): def put(self, element): self.lock.acquire() - heappush(self.queue, element) + heapq.heappush(self.queue, element) self.lock.release() @@ -133,7 +132,7 @@ class PriorityQueue(object): """ return element or None """ self.lock.acquire() try: - el = heappop(self.queue) + el = heapq.heappop(self.queue) return el except IndexError: return None, None diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py index 22a4cc604..e450cacfe 100644 --- a/pyload/network/HTTPRequest.py +++ b/pyload/network/HTTPRequest.py @@ -3,15 +3,14 @@ from __future__ import with_statement +import cStringIO import codecs +import httplib import logging import urllib import pycurl -from httplib import responses -from cStringIO import StringIO - from pyload.plugin.Plugin import Abort, Fail from pyload.utils import encode @@ -31,7 +30,7 @@ bad_headers = range(400, 404) + range(405, 418) + range(500, 506) class BadHeader(Exception): def __init__(self, code, content=""): - Exception.__init__(self, "Bad server response: %s %s" % (code, responses[int(code)])) + Exception.__init__(self, "Bad server response: %s %s" % (code, httplib.responses[int(code)])) self.code = code self.content = content @@ -40,7 +39,7 @@ class HTTPRequest(object): def __init__(self, cookies=None, options=None): self.c = pycurl.Curl() - self.rep = StringIO() + self.rep = cStringIO.StringIO() self.cj = cookies #: cookiejar @@ -244,7 +243,7 @@ class HTTPRequest(object): else: value = self.rep.getvalue() self.rep.close() - self.rep = StringIO() + self.rep = cStringIO.StringIO() return value diff --git a/pyload/plugin/account/AlldebridCom.py b/pyload/plugin/account/AlldebridCom.py index efc5753f8..6ba7a80f9 100644 --- a/pyload/plugin/account/AlldebridCom.py +++ b/pyload/plugin/account/AlldebridCom.py @@ -4,7 +4,7 @@ import re import time import xml.dom.minidom as dom -from BeautifulSoup import BeautifulSoup +import BeautifulSoup from pyload.plugin.Account import Account @@ -22,7 +22,7 @@ class AlldebridCom(Account): def loadAccountInfo(self, user, req): data = self.getAccountData(user) html = req.load("http://www.alldebrid.com/account/") - soup = BeautifulSoup(html) + soup = BeautifulSoup.BeautifulSoup(html) # Try to parse expiration date directly from the control panel page (better accuracy) try: diff --git a/pyload/plugin/addon/SkipRev.py b/pyload/plugin/addon/SkipRev.py index b54e66af5..b19650710 100644 --- a/pyload/plugin/addon/SkipRev.py +++ b/pyload/plugin/addon/SkipRev.py @@ -3,8 +3,7 @@ import re import urllib import urlparse - -from types import MethodType +import types from pyload.datatype.File import PyFile from pyload.plugin.Addon import Addon @@ -75,7 +74,7 @@ class SkipRev(Addon): if not hasattr(pyfile.plugin, "_setup"): # Work-around: inject status checker inside the preprocessing routine of the plugin pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) + pyfile.plugin.setup = types.MethodType(self._setup, pyfile.plugin) def downloadFailed(self, pyfile): diff --git a/pyload/plugin/container/DLC.py b/pyload/plugin/container/DLC.py index b2bfea30e..39b1597b0 100644 --- a/pyload/plugin/container/DLC.py +++ b/pyload/plugin/container/DLC.py @@ -5,7 +5,7 @@ from __future__ import with_statement import re import xml.dom.minidom -from Crypto.Cipher import AES +import Crypto from pyload.plugin.Container import Container from pyload.utils import decode, fs_encode @@ -49,9 +49,9 @@ class DLC(Container): except AttributeError: self.fail(_("Container is corrupted")) - key = iv = AES.new(self.KEY, AES.MODE_CBC, self.IV).decrypt(rc) + key = iv = Crypto.Cipher.AES.new(self.KEY, Crypto.Cipher.AES.MODE_CBC, self.IV).decrypt(rc) - self.data = AES.new(key, AES.MODE_CBC, iv).decrypt(dlc_data).decode('base64') + self.data = Crypto.Cipher.AES.new(key, Crypto.Cipher.AES.MODE_CBC, iv).decrypt(dlc_data).decode('base64') self.packages = [(name or pyfile.name, links, name or pyfile.name) \ for name, links in self.getPackages()] diff --git a/pyload/plugin/container/RSDF.py b/pyload/plugin/container/RSDF.py index 6f56ec06a..1de8ad8d4 100644 --- a/pyload/plugin/container/RSDF.py +++ b/pyload/plugin/container/RSDF.py @@ -5,7 +5,7 @@ from __future__ import with_statement import binascii import re -from Crypto.Cipher import AES +import Crypto from pyload.plugin.Container import Container from pyload.utils import fs_encode @@ -33,8 +33,8 @@ class RSDF(Container): KEY = binascii.unhexlify(self.KEY) IV = binascii.unhexlify(self.IV) - iv = AES.new(KEY, AES.MODE_ECB).encrypt(IV) - cipher = AES.new(KEY, AES.MODE_CFB, iv) + iv = Crypto.Cipher.AES.new(KEY, Crypto.Cipher.AES.MODE_ECB).encrypt(IV) + cipher = Crypto.Cipher.AES.new(KEY, Crypto.Cipher.AES.MODE_CFB, iv) try: fs_filename = fs_encode(pyfile.url.strip()) diff --git a/pyload/plugin/crypter/DuckCryptInfo.py b/pyload/plugin/crypter/DuckCryptInfo.py index 3463d44f9..64d6568ce 100644 --- a/pyload/plugin/crypter/DuckCryptInfo.py +++ b/pyload/plugin/crypter/DuckCryptInfo.py @@ -2,7 +2,7 @@ import re -from BeautifulSoup import BeautifulSoup +import BeautifulSoup from pyload.plugin.Crypter import Crypter @@ -41,7 +41,7 @@ class DuckCryptInfo(Crypter): m = re.match(self.__pattern, html) self.logDebug("Redirectet to " + str(m.group(0))) html = self.load(str(m.group(0))) - soup = BeautifulSoup(html) + soup = BeautifulSoup.BeautifulSoup(html) cryptlinks = soup.findAll("div", attrs={"class": "folderbox"}) self.logDebug("Redirectet to " + str(cryptlinks)) if not cryptlinks: @@ -53,7 +53,7 @@ class DuckCryptInfo(Crypter): def handleLink(self, url): html = self.load(url) - soup = BeautifulSoup(html) + soup = BeautifulSoup.BeautifulSoup(html) self.urls = [soup.find("iframe")['src']] if not self.urls: self.logInfo(_("No link found")) diff --git a/pyload/plugin/crypter/FilecryptCc.py b/pyload/plugin/crypter/FilecryptCc.py index db939357a..0507a580b 100644 --- a/pyload/plugin/crypter/FilecryptCc.py +++ b/pyload/plugin/crypter/FilecryptCc.py @@ -7,7 +7,7 @@ import binascii import re import urlparse -from Crypto.Cipher import AES +import Crypto from pyload.plugin.Crypter import Crypter from pyload.plugin.captcha.ReCaptcha import ReCaptcha @@ -169,7 +169,7 @@ class FilecryptCc(Crypter): # Decrypt Key = key IV = key - obj = AES.new(Key, AES.MODE_CBC, IV) + obj = Crypto.Cipher.AES.new(Key, Crypto.Cipher.AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) # Extract links diff --git a/pyload/plugin/crypter/HoerbuchIn.py b/pyload/plugin/crypter/HoerbuchIn.py index 500dad8cc..455d0abdf 100644 --- a/pyload/plugin/crypter/HoerbuchIn.py +++ b/pyload/plugin/crypter/HoerbuchIn.py @@ -2,7 +2,7 @@ import re -from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup +import BeautifulSoup, BeautifulStoneSoup from pyload.plugin.Crypter import Crypter @@ -31,7 +31,7 @@ class HoerbuchIn(Crypter): if self.article.match(pyfile.url): html = self.load(pyfile.url) - soup = BeautifulSoup(html, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) + soup = BeautifulSoup.BeautifulSoup(html, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) abookname = soup.find("a", attrs={"rel": "bookmark"}).text for a in soup.findAll("a", attrs={"href": self.protection}): diff --git a/pyload/plugin/crypter/LinkCryptWs.py b/pyload/plugin/crypter/LinkCryptWs.py index c997cbf9f..98a796aed 100644 --- a/pyload/plugin/crypter/LinkCryptWs.py +++ b/pyload/plugin/crypter/LinkCryptWs.py @@ -5,7 +5,7 @@ import re import pycurl -from Crypto.Cipher import AES +import Crypto from pyload.plugin.Crypter import Crypter from pyload.utils import html_unescape @@ -309,7 +309,7 @@ class LinkCryptWs(Crypter): # Decrypt Key = key IV = key - obj = AES.new(Key, AES.MODE_CBC, IV) + obj = Crypto.Cipher.AES.new(Key, Crypto.Cipher.AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) # Extract links diff --git a/pyload/plugin/crypter/NCryptIn.py b/pyload/plugin/crypter/NCryptIn.py index bc9702f21..2b357395b 100644 --- a/pyload/plugin/crypter/NCryptIn.py +++ b/pyload/plugin/crypter/NCryptIn.py @@ -3,7 +3,7 @@ import binascii import re -from Crypto.Cipher import AES +import Crypto from pyload.plugin.Crypter import Crypter from pyload.plugin.captcha.ReCaptcha import ReCaptcha @@ -298,7 +298,7 @@ class NCryptIn(Crypter): # Decrypt Key = key IV = key - obj = AES.new(Key, AES.MODE_CBC, IV) + obj = Crypto.Cipher.AES.new(Key, Crypto.Cipher.AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) # Extract links diff --git a/pyload/plugin/crypter/RelinkUs.py b/pyload/plugin/crypter/RelinkUs.py index 2b9a85401..3ffc33c12 100644 --- a/pyload/plugin/crypter/RelinkUs.py +++ b/pyload/plugin/crypter/RelinkUs.py @@ -6,7 +6,8 @@ import binascii import re import os -from Crypto.Cipher import AES +import Crypto + from pyload.plugin.Crypter import Crypter from pyload.utils import fs_join @@ -281,7 +282,7 @@ class RelinkUs(Crypter): # Decrypt Key = key IV = key - obj = AES.new(Key, AES.MODE_CBC, IV) + obj = Crypto.Cipher.AES.new(Key, Crypto.Cipher.AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) # Extract links diff --git a/pyload/plugin/crypter/SafelinkingNet.py b/pyload/plugin/crypter/SafelinkingNet.py index a949d17b1..71f41469b 100644 --- a/pyload/plugin/crypter/SafelinkingNet.py +++ b/pyload/plugin/crypter/SafelinkingNet.py @@ -2,7 +2,7 @@ import re -from BeautifulSoup import BeautifulSoup +import BeautifulSoup from pyload.utils import json_loads from pyload.plugin.Crypter import Crypter @@ -66,7 +66,7 @@ class SafelinkingNet(Crypter): break pyfile.package().password = "" - soup = BeautifulSoup(self.html) + soup = BeautifulSoup.BeautifulSoup(self.html) scripts = soup.findAll("script") for s in scripts: if "d_links" in s.text: diff --git a/pyload/plugin/crypter/ShareLinksBiz.py b/pyload/plugin/crypter/ShareLinksBiz.py index 8add5214d..25e891f3b 100644 --- a/pyload/plugin/crypter/ShareLinksBiz.py +++ b/pyload/plugin/crypter/ShareLinksBiz.py @@ -3,7 +3,8 @@ import binascii import re -from Crypto.Cipher import AES +import Crypto + from pyload.plugin.Crypter import Crypter @@ -267,7 +268,7 @@ class ShareLinksBiz(Crypter): # Decrypt Key = key IV = key - obj = AES.new(Key, AES.MODE_CBC, IV) + obj = Crypto.Cipher.AES.new(Key, Crypto.Cipher.AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) # Extract links diff --git a/pyload/plugin/hoster/MegaCoNz.py b/pyload/plugin/hoster/MegaCoNz.py index 2e6735ee6..83409fde9 100644 --- a/pyload/plugin/hoster/MegaCoNz.py +++ b/pyload/plugin/hoster/MegaCoNz.py @@ -7,8 +7,7 @@ import os import random import re -from Crypto.Cipher import AES -from Crypto.Util import Counter +import Crypto from pyload.utils import json_loads, json_dumps from pyload.plugin.Hoster import Hoster @@ -90,7 +89,7 @@ class MegaCoNz(Hoster): def decryptAttr(self, data, key): k, iv, meta_mac = self.getCipherKey(key) - cbc = AES.new(k, AES.MODE_CBC, "\0" * 16) + cbc = Crypto.Cipher.AES.new(k, Crypto.Cipher.AES.MODE_CBC, "\0" * 16) attr = decode(cbc.decrypt(self.b64_decode(data))) self.logDebug("Decrypted Attr: %s" % attr) @@ -109,8 +108,8 @@ class MegaCoNz(Hoster): # convert counter to long and shift bytes k, iv, meta_mac = self.getCipherKey(key) - ctr = Counter.new(128, initial_value=long(n.encode("hex"), 16) << 64) - cipher = AES.new(k, AES.MODE_CTR, counter=ctr) + ctr = Crypto.Util.Counter.new(128, initial_value=long(n.encode("hex"), 16) << 64) + cipher = Crypto.Cipher.AES.new(k, Crypto.Cipher.AES.MODE_CTR, counter=ctr) self.pyfile.setStatus("decrypting") self.pyfile.setProgress(0) diff --git a/pyload/plugin/hoster/TurbobitNet.py b/pyload/plugin/hoster/TurbobitNet.py index bcbeddd17..8138e2e23 100644 --- a/pyload/plugin/hoster/TurbobitNet.py +++ b/pyload/plugin/hoster/TurbobitNet.py @@ -7,7 +7,7 @@ import re import time import urllib -from Crypto.Cipher import ARC4 +import Crypto from pyload.network.RequestFactory import getURL from pyload.plugin.captcha.ReCaptcha import ReCaptcha @@ -155,7 +155,7 @@ class TurbobitNet(SimpleHoster): def decrypt(self, data): - cipher = ARC4.new(binascii.hexlify('E\x15\xa1\x9e\xa3M\xa0\xc6\xa0\x84\xb6H\x83\xa8o\xa0')) + cipher = Crypto.Cipher.ARC4.new(binascii.hexlify('E\x15\xa1\x9e\xa3M\xa0\xc6\xa0\x84\xb6H\x83\xa8o\xa0')) return binascii.unhexlify(cipher.encrypt(binascii.unhexlify(data))) diff --git a/pyload/plugin/hoster/ZDF.py b/pyload/plugin/hoster/ZDF.py index c02eadc23..8272cfd93 100644 --- a/pyload/plugin/hoster/ZDF.py +++ b/pyload/plugin/hoster/ZDF.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from xml.etree.ElementTree import fromstring +import xml from pyload.plugin.Hoster import Hoster @@ -42,7 +41,7 @@ class ZDF(Hoster): def process(self, pyfile): - xml = fromstring(self.load(self.XML_API % self.get_id(pyfile.url))) + xml = xml.etree.ElementTree.fromstring(self.load(self.XML_API % self.get_id(pyfile.url))) status = xml.findtext("./status/statuscode") if status != "ok": diff --git a/pyload/plugin/hoster/ZippyshareCom.py b/pyload/plugin/hoster/ZippyshareCom.py index 40a879b55..df9af062b 100644 --- a/pyload/plugin/hoster/ZippyshareCom.py +++ b/pyload/plugin/hoster/ZippyshareCom.py @@ -3,7 +3,7 @@ import re import urllib -from BeautifulSoup import BeautifulSoup +import BeautifulSoup from pyload.plugin.captcha.ReCaptcha import ReCaptcha from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -59,7 +59,7 @@ class ZippyshareCom(SimpleHoster): def get_link(self): # get all the scripts inside the html body - soup = BeautifulSoup(self.html) + soup = BeautifulSoup.BeautifulSoup(self.html) scripts = (s.getText().strip() for s in soup.body.findAll('script', type='text/javascript')) # meant to be populated with the initialization of all the DOM elements found in the scripts diff --git a/pyload/remote/ClickNLoadBackend.py b/pyload/remote/ClickNLoadBackend.py index 99571fe8b..ece2dc316 100644 --- a/pyload/remote/ClickNLoadBackend.py +++ b/pyload/remote/ClickNLoadBackend.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- # @author: RaNaN +import BaseHTTPServer import base64 import binascii +import cgi import re import urllib -from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler -from cgi import FieldStorage - try: - from Crypto.Cipher import AES + import Crypto except Exception: pass @@ -23,7 +22,7 @@ js = None class ClickNLoadBackend(BackendBase): def setup(self, host, port): - self.httpd = HTTPServer((host, port), CNLHandler) + self.httpd = BaseHTTPServer.HTTPServer((host, port), CNLHandler) global core, js core = self.m.core js = core.js @@ -34,7 +33,7 @@ class ClickNLoadBackend(BackendBase): self.httpd.handle_request() -class CNLHandler(BaseHTTPRequestHandler): +class CNLHandler(BaseHTTPServer.BaseHTTPRequestHandler): def add_package(self, name, urls, queue=0): print "name", name @@ -94,7 +93,7 @@ class CNLHandler(BaseHTTPRequestHandler): def do_POST(self): - form = FieldStorage( + form = cgi.FieldStorage( fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD': 'POST', @@ -137,7 +136,7 @@ class CNLHandler(BaseHTTPRequestHandler): Key = binascii.unhexlify(jk) IV = Key - obj = AES.new(Key, AES.MODE_CBC, IV) + obj = Crypto.Cipher.AES.new(Key, Crypto.Cipher.AES.MODE_CBC, IV) result = obj.decrypt(crypted).replace("\x00", "").replace("\r", "").split("\n") result = filter(lambda x: x != "", result) diff --git a/pyload/remote/thriftbackend/ThriftTest.py b/pyload/remote/thriftbackend/ThriftTest.py index d8adf476e..3ea67682b 100644 --- a/pyload/remote/thriftbackend/ThriftTest.py +++ b/pyload/remote/thriftbackend/ThriftTest.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- +import getpass import os import platform import sys import time +import xmlrpclib from pyload.remote.thriftbackend.thriftgen.pyload import Pyload from pyload.remote.thriftbackend.thriftgen.pyload.ttypes import * @@ -14,8 +16,6 @@ from thrift.transport import TTransport from Protocol import Protocol -import xmlrpclib - def bench(f, *args, **kwargs): s = time.time() @@ -27,9 +27,8 @@ def bench(f, *args, **kwargs): print "%s: %f s" % (f.__name__, e-s) return ret -from getpass import getpass user = raw_input("user ") -passwd = getpass("password ") +passwd = getpass.getpass("password ") server_url = "http%s://%s:%s@%s:%s/" % ( "", diff --git a/pyload/webui/filters.py b/pyload/utils/filters.py index 9d4d47c04..9d4d47c04 100644 --- a/pyload/webui/filters.py +++ b/pyload/utils/filters.py diff --git a/pyload/webui/middlewares.py b/pyload/utils/middlewares.py index c3f4952db..c3f4952db 100644 --- a/pyload/webui/middlewares.py +++ b/pyload/utils/middlewares.py diff --git a/pyload/webui/__init__.py b/pyload/webui/__init__.py index 472e1a4f7..70928c458 100644 --- a/pyload/webui/__init__.py +++ b/pyload/webui/__init__.py @@ -5,13 +5,12 @@ import os import sys import bottle +import jinja2 import pyload.utils.pylgettext as gettext -from jinja2 import Environment, FileSystemLoader, PrefixLoader, FileSystemBytecodeCache - from pyload.Thread import Server -from pyload.Webui.middlewares import StripPathMiddleware, GZipMiddleWare, PrefixMiddleware +from pyload.utils.middlewares import StripPathMiddleware, GZipMiddleWare, PrefixMiddleware from pyload.network.JsEngine import JsEngine from pyload.utils import decode, formatSize @@ -53,14 +52,14 @@ cache = os.path.join("tmp", "jinja_cache") if not os.path.exists(cache): os.makedirs(cache) -bcc = FileSystemBytecodeCache(cache, '%s.cache') +bcc = jinja2.FileSystemBytecodeCache(cache, '%s.cache') -loader = FileSystemLoader([THEME_DIR, os.path.join(THEME_DIR, THEME)]) +loader = jinja2.FileSystemLoader([THEME_DIR, os.path.join(THEME_DIR, THEME)]) -env = Environment(loader=loader, extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'], trim_blocks=True, auto_reload=False, +env = jinja2.Environment(loader=loader, extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'], trim_blocks=True, auto_reload=False, bytecode_cache=bcc) -from filters import quotepath, path_make_relative, path_make_absolute, truncate, date +from pyload.utils.filters import quotepath, path_make_relative, path_make_absolute, truncate, date env.filters['quotepath'] = quotepath env.filters['truncate'] = truncate diff --git a/pyload/webui/app/__init__.py b/pyload/webui/app/__init__.py index 43c9ecbe9..39d0fadd5 100644 --- a/pyload/webui/app/__init__.py +++ b/pyload/webui/app/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from pyload.webui.app import api, cnl, json, pyloadweb +from pyload.webui.app import api, cnl, json, pyload diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyload.py index 27532b86e..58acdf12c 100644 --- a/pyload/webui/app/pyloadweb.py +++ b/pyload/webui/app/pyload.py @@ -15,7 +15,7 @@ from pyload.webui import PYLOAD, PYLOAD_DIR, THEME_DIR, THEME, SETUP, env from pyload.webui.app.utils import render_to_response, parse_permissions, parse_userdata, \ login_required, get_permission, set_permission, permlist, toDict, set_session -from pyload.webui.filters import relpath, unquotepath +from pyload.utils.filters import relpath, unquotepath from pyload.utils import formatSize, fs_join, fs_encode, fs_decode diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py index 3526f2615..2e7cf76c5 100644 --- a/pyload/webui/app/utils.py +++ b/pyload/webui/app/utils.py @@ -86,10 +86,8 @@ def parse_userdata(session): def login_required(perm=None): - def _dec(func): - def _view(*args, **kwargs): s = request.environ.get('beaker.session') if s.get("name", None) and s.get("authenticated", False): |