summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-29 00:16:22 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-29 00:16:22 +0200
commit5f1c75fd93af98a5d870424971f0383ac4614058 (patch)
treed0e3d5d00295cdd5c9f65a755254aced21a6ff68
parentpremium and free download works with rapidshare (diff)
downloadpyload-5f1c75fd93af98a5d870424971f0383ac4614058.tar.xz
socket server basic
-rw-r--r--Core.py4
-rw-r--r--Plugins/Plugin.py12
-rw-r--r--Plugins/RapidshareCom.py8
-rw-r--r--config22
-rw-r--r--module/remote/RequestHandler.py29
-rw-r--r--module/remote/SocketServer.py15
-rw-r--r--pluginconfig4
-rw-r--r--sockettest.py24
8 files changed, 90 insertions, 28 deletions
diff --git a/Core.py b/Core.py
index a314c0a03..a32e091e3 100644
--- a/Core.py
+++ b/Core.py
@@ -232,7 +232,7 @@ class Core(object):
if __name__ == "__main__":
testLoader = Core()
- #server = ServerThread(testLoader)
- #server.start()
+ server = ServerThread(testLoader)
+ server.start()
testLoader.start()
diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py
index 28de69928..c882c34bb 100644
--- a/Plugins/Plugin.py
+++ b/Plugins/Plugin.py
@@ -13,13 +13,13 @@ class Plugin():
self.config = {}
props = {}
props['name'] = "Base Plugin"
- props['pattern'] = None
- props['type'] = "hoster"
props['version'] = "0.1"
+ props['pattern'] = None
+ props['type'] = "hoster"
props['format'] = "*.py"
props['description'] = """bla"""
- props['author_name'] = ("RaNaN", "spoob")
- props['author_mail'] = ("RaNaN@pyload.org", "spoob@pyload.org")
+ props['author'] = "Spoob"
+ props['author_email'] = "nn@nn.de"
self.props = props
self.parent = parent
self.req = Request()
@@ -49,6 +49,7 @@ class Plugin():
"""
return self.parent.url
+
def get_file_name(self):
return re.findall("([^\/=]+)", self.parent.url)[-1]
@@ -72,7 +73,8 @@ class Plugin():
if self.parser.has_section(self.props['name']):
for option in self.parser.options(self.props['name']):
- self.config[option] = self.parser.get(self.props['name'], option, raw=True)
+ self.config[option] = self.parser.get(self.props['name'], option)
+ self.config[option] = False if self.config[option].lower() == 'false' else self.config[option]
def __call__(self):
return self.props['name']
diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py
index 3af2333c8..ebe526903 100644
--- a/Plugins/RapidshareCom.py
+++ b/Plugins/RapidshareCom.py
@@ -28,7 +28,7 @@ class RapidshareCom(Plugin):
self.multi_dl = False
self.read_config()
- if self.config['premium'] == "True":
+ if self.config['premium']:
self.multi_dl = True
def set_parent_status(self):
@@ -65,7 +65,7 @@ class RapidshareCom(Plugin):
def get_wait_time(self):
- if self.config['premium'] == "True":
+ if self.config['premium']:
self.time_plus_wait = 0
return True
@@ -101,7 +101,7 @@ class RapidshareCom(Plugin):
def get_file_url(self):
""" returns the absolute downloadable filepath
"""
- if self.config['premium'] == "True":
+ if self.config['premium']:
return self.parent.url
if self.html[1] == None:
@@ -126,7 +126,7 @@ class RapidshareCom(Plugin):
def proceed(self, url, location):
- if self.config['premium'] == "True":
+ if self.config['premium']:
self.req.add_auth(self.config['username'], self.config['password'])
self.req.download(url, location)
diff --git a/config b/config
index 2ff4514a7..7aeccfdff 100644
--- a/config
+++ b/config
@@ -1,13 +1,17 @@
[general]
-downloadFolder: Downloads
-linkFile: links.txt
-useReconnect: False
-reconnectMethod: ./reconnect.sh
+downloadFolder = Downloads
+linkFile = links.txt
+useReconnect = False
+reconnectMethod = ./reconnect.sh
[updates]
-searchUpdates: True
+searchUpdates = True
[log]
-logFolder: Logs
-fullLog: True
+logFolder = Logs
+fullLog = True
[time]
-start: 0:00
-end: 6:00 \ No newline at end of file
+start = 0:00
+end = 6:00
+[remote]
+activated = True
+port = 7272
+passwort = pwhere
diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py
new file mode 100644
index 000000000..9964c90c0
--- /dev/null
+++ b/module/remote/RequestHandler.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+"""
+authored by: RaNaN
+
+this module handels the incoming requests
+
+"""
+
+import base64
+from cPickle import Pickler
+from cStringIO import StringIO
+from Crypto.Cipher import AES
+
+
+class RequestHandler():
+ def __init__(self, core):
+ self.core = core
+ self.p = Pickler(string)
+ self.obj = AES.new('pw', AES.MODE_ECB)
+
+ def proceed(self, data):
+ return "the answer."
+
+ def decrypt(self, string):
+ string = string
+ buf = StringIO(string)
+
+
diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py
index 4469f89ac..3635e16d8 100644
--- a/module/remote/SocketServer.py
+++ b/module/remote/SocketServer.py
@@ -10,6 +10,7 @@ import asynchat
import asyncore
import socket
import threading
+from RequestHandler import RequestHandler
class ServerThread(threading.Thread):
@@ -41,18 +42,20 @@ class MainServerSocket(asyncore.dispatcher):
class SecondaryServerSocket(asynchat.async_chat):
- def __init__(self, pycore, *args):
+ def __init__(self, socket, pycore):
print 'initing SSS'
- self.pycore = pycore
- asynchat.async_chat.__init__(self, *args)
- self.set_terminator('\n')
+ asynchat.async_chat.__init__(self, socket)
+ self.pycore = pycore
+ self.handler = RequestHandler(pycore)
+ self.set_terminator('\n')
self.data = []
def collect_incoming_data(self, data):
self.data.append(data)
def found_terminator(self):
- self.push("daten")
+ self.handler.proceed(self.data)
+ self.push(str(self.pycore.plugins_avaible))
self.data = []
#having fun with the data
def handle_close(self):
print "Disconnected from", self.getpeername()
- self.close() \ No newline at end of file
+ self.close()
diff --git a/pluginconfig b/pluginconfig
index eac984aff..2ddf68df9 100644
--- a/pluginconfig
+++ b/pluginconfig
@@ -1,4 +1,4 @@
[RapidshareCom]
premium = False
-username = ""
-password = ""
+user = user
+pw = pw
diff --git a/sockettest.py b/sockettest.py
new file mode 100644
index 000000000..afac02bb9
--- /dev/null
+++ b/sockettest.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# -'- coding: utf-8 -*.
+"""
+authored by: Captain Blackbeard
+
+script only for socket testing
+
+"""
+
+import socket
+
+sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+sock.connect(('localhost', 7272))
+print "Connected to server"
+data = """A few lines of data to test the operation of both server and client.
+Und noch eine Zeile"""
+for line in data.splitlines():
+ sock.sendall(line+'\n')
+ print "Sent:", line
+
+response = sock.recv(8192)
+
+print "Received:", response
+sock.close()