summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-12-22 13:45:30 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2010-12-22 13:45:30 +0100
commitdde6a329fdaa5dca48080770dee82cb51cf12585 (patch)
treed665099c49a0ef1f5c09a9d2f8b19ba09f531437 /module/network
parentat least its downloading now (diff)
downloadpyload-dde6a329fdaa5dca48080770dee82cb51cf12585.tar.xz
refactoring part 1: deprecation warnings, reduced debug, cookie compatibility
Diffstat (limited to 'module/network')
-rw-r--r--module/network/Browser.py40
-rw-r--r--module/network/HTTPBase.py4
2 files changed, 29 insertions, 15 deletions
diff --git a/module/network/Browser.py b/module/network/Browser.py
index 3db2299f0..df0f24b4d 100644
--- a/module/network/Browser.py
+++ b/module/network/Browser.py
@@ -10,13 +10,14 @@ from HTTPDownload import HTTPDownload
from FTPBase import FTPDownload
from XDCCBase import XDCCDownload
+from traceback import print_stack
+
class Browser(object):
def __init__(self, interface=None, cookieJar=CookieJar(), bucket=None, proxies={}):
self.log = getLogger("log")
self.lastURL = None
self.interface = interface
- self.cookieJar = cookieJar
self.bucket = bucket
self.http = HTTPBase(interface=interface, proxies=proxies)
@@ -24,10 +25,11 @@ class Browser(object):
self.proxies = proxies
def setCookieJar(self, cookieJar):
- self.http.cookieJar = cookieJar
+ self.cookieJar = cookieJar
+ self.http.cookieJar = self.cookieJar
def clearCookies(self):
- pass #@TODO
+ self.cookieJar.clear()
def clearReferer(self):
self.lastURL = None
@@ -77,15 +79,6 @@ class Browser(object):
pass
return location
- def download(self, url, file_name, folder, get={}, post={}, ref=True, cookies=True, no_post_encode=False):
- #@TODO
-
- filename = join(folder, file_name)
- d = self.httpDownload(url, filename, get, post)
- waitFor(d)
-
- return filename
-
def httpDownload(self, url, filename, get={}, post={}, referer=None, cookies=True, customHeaders={}, chunks=1,
resume=False):
if not referer:
@@ -112,6 +105,27 @@ class Browser(object):
d = dwnld.download()
return d
+
+ #compatibility wrapper
+ def clean(self):
+ self.log.warning("Browser: deprecated call 'clean'")
+ print_stack()
+
+ def load(self, *args, **kwargs):
+ self.log.warning("Browser: deprecated call 'load'")
+ print_stack()
+ return self.getPage(*args, **kwargs)
+
+ def download(self, url, file_name, folder, get={}, post={}, ref=True, cookies=True, no_post_encode=False):
+ #@TODO
+ self.log.warning("Browser: deprecated call 'download'")
+ print_stack()
+
+ filename = join(folder, file_name)
+ d = self.httpDownload(url, filename, get, post)
+ waitFor(d)
+
+ return filename
if __name__ == "__main__":
browser = Browser()#proxies={"socks5": "localhost:5000"})
@@ -127,4 +141,4 @@ if __name__ == "__main__":
from time import sleep
while True:
- sleep(1) \ No newline at end of file
+ sleep(1)
diff --git a/module/network/HTTPBase.py b/module/network/HTTPBase.py
index 753c6c0f1..fead2f4ed 100644
--- a/module/network/HTTPBase.py
+++ b/module/network/HTTPBase.py
@@ -49,7 +49,7 @@ import socks
from MultipartPostHandler import MultipartPostHandler
-DEBUG = 1
+DEBUG = 0
HANDLE_ERRORS = 1
class PyLoadHTTPResponse(HTTPResponse):
@@ -293,7 +293,7 @@ class HTTPBase():
self.cookieJar = CookieJar()
- self.debug = True
+ self.debug = DEBUG
def createOpener(self, cookies=True):
opener = OpenerDirector()