summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-06-08 12:23:28 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-06-08 12:23:28 +0200
commit7b6a6cb94c8c2abc449351a1238227f9b10b0872 (patch)
treecc419ba50b1cbab369949c0be45ccc2e82c57dba /module
parentFixed the YouPorn.com Plugin (diff)
downloadpyload-7b6a6cb94c8c2abc449351a1238227f9b10b0872.tar.xz
core able to push data to gui, proxy support: closed #1
Diffstat (limited to 'module')
-rw-r--r--module/Py_Load_File.py5
-rwxr-xr-xmodule/network/Request.py13
-rw-r--r--module/remote/RequestHandler.py4
-rw-r--r--module/remote/RequestObject.py3
-rw-r--r--module/remote/SocketServer.py17
5 files changed, 35 insertions, 7 deletions
diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py
index 9fcd554a5..d0a4c4591 100644
--- a/module/Py_Load_File.py
+++ b/module/Py_Load_File.py
@@ -26,6 +26,11 @@ class PyLoadFile:
return "Plugin"
def prepareDownload(self):
+
+ if self.parent.config['useproxy']:
+ self.plugin.req.add_proxy(self.parent.config['proxyprotocol'], self.parent.config['proxyadress'])
+
+
self.status.exists = self.plugin.file_exists()
if self.status.exists:
self.status.filename = self.plugin.get_file_name()
diff --git a/module/network/Request.py b/module/network/Request.py
index 8e2b6ae02..de9000ab3 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -59,12 +59,12 @@ class Request:
if post:
post = urllib.urlencode(post)
else:
- post = None
+ post = None
if get:
- get = urllib.urlencode(get)
+ get = urllib.urlencode(get)
else:
- get = ""
+ get = ""
url = url + get
req = urllib2.Request(url, data=post)
@@ -100,11 +100,16 @@ class Request:
def add_cookies(self, req):
cookie_head = ""
for cookie in self.cookies:
- cookie_head += cookie.name+"="+cookie.value+"; "
+ cookie_head += cookie.name + "=" + cookie.value + "; "
req.add_header("Cookie", cookie_head)
#def download(url, filename, reporthook = None, data = None): #default von urlretrieve auch None?
# return self.downloader.urlretrieve(url, filename, reporthook, data)
+ def add_proxy(self, protocol, adress):
+ handler = urllib2.ProxyHandler({protocol: adress})
+ self.opener.add_handler(handler)
+ self.downloader.add_handler(handler)
+
def download(self, url, filename, post={}):
if post:
diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py
index f7623d27b..2f6f248bd 100644
--- a/module/remote/RequestHandler.py
+++ b/module/remote/RequestHandler.py
@@ -28,7 +28,7 @@ class RequestHandler:
if obj.command == "exec":
func = getattr(self.core, obj.function)
- obj.response = func(*obj.args)
+ obj.response = func( * obj.args)
else:
obj.response = "error happend"
@@ -54,7 +54,7 @@ class RequestHandler:
p_str = ""
for i in range(padding - 1):
- p_str += random.choice(string.letters + string.digits)
+ p_str += random.choice(string.letters + string.digits + string.punctuation)
p_str += hex(len(p_str)).replace("0x", "")
enc_str += p_str
diff --git a/module/remote/RequestObject.py b/module/remote/RequestObject.py
index 7080a6faf..c5786061b 100644
--- a/module/remote/RequestObject.py
+++ b/module/remote/RequestObject.py
@@ -13,4 +13,5 @@ class RequestObject(object):
self.command = None
self.function = ""
self.args = []
- self.response = "" \ No newline at end of file
+ self.response = None
+ self.data = None \ No newline at end of file
diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py
index c519d8a3b..e5932bb6e 100644
--- a/module/remote/SocketServer.py
+++ b/module/remote/SocketServer.py
@@ -24,6 +24,20 @@ class ServerThread(threading.Thread):
asyncore.loop()
print "loop closed"
+ def sockets(self):
+ """returns all connected sockets in a list"""
+ sockets = []
+ for value in asyncore.socket_map.values():
+ if SecondaryServerSocket == value.__class__:
+ sockets.append(value)
+
+ return sockets
+
+ def push_all(self, obj):
+ """push obj to all sockets"""
+ for socket in self.sockets():
+ socket.push_obj(obj)
+
class MainServerSocket(asyncore.dispatcher):
def __init__(self, port, pycore):
@@ -61,3 +75,6 @@ class SecondaryServerSocket(asynchat.async_chat):
def handle_close(self):
print "Disconnected from", self.getpeername()
self.close()
+ def push_obj(self, obj):
+ obj = self.handler.encrypt(obj)
+ self.push(obj)