diff options
-rw-r--r-- | module/remote/ClientSocket.py | 30 | ||||
-rw-r--r-- | module/remote/RequestHandler.py | 4 | ||||
-rw-r--r-- | module/remote/SocketServer.py | 1 | ||||
-rwxr-xr-x | pyMainGui.py | 25 |
4 files changed, 48 insertions, 12 deletions
diff --git a/module/remote/ClientSocket.py b/module/remote/ClientSocket.py new file mode 100644 index 000000000..74f66f0be --- /dev/null +++ b/module/remote/ClientSocket.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# -'- coding: utf-8 -*. +""" +authored by: RaNaN + +socket for connecting to the core's server + +""" +import asynchat +import socket +from RequestHandler import RequestHandler + +class ClientSocket(asynchat.async_chat): + def __init__(self, client): + asynchat.async_chat.__init__(self) + self.client = client + self.data = "" + self.handler = RequestHandler(None) + self.set_terminator("\n") + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + + def handle_connect(self): + print "connected" + + def collect_incoming_data(self, data): + self.data += data + + def found_terminator(self): + pass + #process diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py index 1405fd3eb..212f65b1c 100644 --- a/module/remote/RequestHandler.py +++ b/module/remote/RequestHandler.py @@ -21,7 +21,7 @@ from RequestObject import RequestObject class RequestHandler: def __init__(self, core): self.core = core - key = SHA.new(core.config['remotepassword']) + key = SHA.new("pwhere") #core.config['remotepassword'] key = MD5.new(key.hexdigest()) self.aes = AES.new(key.hexdigest(), AES.MODE_ECB) @@ -32,7 +32,7 @@ class RequestHandler: func = getattr(self.core, obj.function) obj.response = func(*obj.args) else: - obj.response = "antwort" + obj.response = "error happend" return self.encrypt(obj) diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py index 9000c1c71..5bd6ba3d0 100644 --- a/module/remote/SocketServer.py +++ b/module/remote/SocketServer.py @@ -52,6 +52,7 @@ class SecondaryServerSocket(asynchat.async_chat): def collect_incoming_data(self, data): self.data += data def found_terminator(self): + print "data arrived" rep = self.handler.proceed(self.data) self.push(rep) self.data = "" diff --git a/pyMainGui.py b/pyMainGui.py index e570841d3..58295655f 100755 --- a/pyMainGui.py +++ b/pyMainGui.py @@ -2,10 +2,11 @@ import wx from os import sep from os.path import abspath, dirname +from module.remote.ClientSocket import ClientSocket class pyAddDownloadDialog(wx.Dialog): def __init__(self, parent, id, title): - wx.Dialog.__init__(self, parent, id, title, size=(700,400)) + wx.Dialog.__init__(self, parent, id, title, size=(600,400)) pass @@ -19,12 +20,12 @@ class pyPanelUp(wx.Panel): downloadliste.InsertColumn(0, 'Name', width=250) downloadliste.InsertColumn(1, 'Status') downloadliste.InsertColumn(2, 'Groesse') - downloadliste.InsertColumn(3, 'Uebertragen') - downloadliste.InsertColumn(4, 'Prozent',width=50) - downloadliste.InsertColumn(5, 'Dauer',width=50) - downloadliste.InsertColumn(6, 'Uebrig',width=50) - downloadliste.InsertColumn(7, 'Geschwindigkeit',width=50) - downloadliste.InsertColumn(8, 'Download FOrdner', width=200) + downloadliste.InsertColumn(3, 'Uebertragen', width=100) + downloadliste.InsertColumn(4, 'Prozent', width=60) + downloadliste.InsertColumn(5, 'Dauer', width=60) + downloadliste.InsertColumn(6, 'Uebrig', width=60) + downloadliste.InsertColumn(7, 'kb/s', width=50) + #downloadliste.InsertColumn(8, 'Download FOrdner', width=200) sizer.Add(downloadliste, 1, wx.EXPAND) self.SetSizer(sizer) @@ -39,10 +40,16 @@ class pyPanelDown(wx.Panel): class pyMain(wx.Frame): def __init__(self, parent, id, title="pyLoad"): - wx.Frame.__init__(self,parent,id,title, size=(910,500)) + wx.Frame.__init__(self,parent,id,title, size=(800,500)) appPath = dirname(abspath(__file__)) + sep + # socket + + self.socket = ClientSocket(self) + self.socket.connect(('localhost', 7272)) + self.socket.push("nonsense\n") + # Menubar menubar = wx.MenuBar() file = wx.Menu() @@ -77,8 +84,6 @@ class pyMain(wx.Frame): self.Bind(wx.EVT_MENU, self.OnExit,exit) self.Bind(wx.EVT_TOOL, self.onAddButtonClicked, add) - - self.Centre() self.Show(True) |