diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-06-17 11:49:15 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-06-17 11:49:15 +0200 |
commit | 5c4b8fe36b6aef655c3d54448741beb9247f044f (patch) | |
tree | 4b0d13785be91b2f7c7d9e26facb639e1e1b331a /module | |
parent | file_list saves links, links.txt only for link dumping (diff) | |
download | pyload-5c4b8fe36b6aef655c3d54448741beb9247f044f.tar.xz |
new server functions
Diffstat (limited to 'module')
-rw-r--r-- | module/file_list.py | 9 | ||||
-rw-r--r-- | module/remote/SocketServer.py | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/module/file_list.py b/module/file_list.py index fe4080807..3a1c866dc 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -22,6 +22,7 @@ LIST_VERSION = 1 import cPickle from Py_Load_File import PyLoadFile +from module.remote.RequestObject import RequestObject class File_List(object): def __init__(self, core): @@ -67,6 +68,8 @@ class File_List(object): output = open('links.pkl', 'wb') cPickle.dump(self.data, output, -1) + self.inform_client() + def load(self): try: pkl_file = open('links.pkl', 'rb') @@ -83,6 +86,12 @@ class File_List(object): self.core.logger.info("Links loaded: "+ str(int(len(obj) - 1))) + def inform_client(self): + obj = RequestObject() + obj.command = "file_list" + obj.data = self.data + + self.core.server.push_all(obj) class Data(): def __init__(self, url): diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py index 676cb5556..297a9a422 100644 --- a/module/remote/SocketServer.py +++ b/module/remote/SocketServer.py @@ -42,15 +42,15 @@ class ServerThread(threading.Thread): class MainServerSocket(asyncore.dispatcher): def __init__(self, port, pycore): - print 'initing MSS' asyncore.dispatcher.__init__(self) + pycore.logger.info('initing Remote-Server') self.pycore = pycore self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.bind(('localhost', port)) self.listen(5) def handle_accept(self): newSocket, address = self.accept() - print "Connected from", address + self.pycore.logger.info("Connected from " + str(address)) SecondaryServerSocket(newSocket, self.pycore) def handle_close(self): print "going to close" @@ -59,7 +59,6 @@ class MainServerSocket(asyncore.dispatcher): class SecondaryServerSocket(asynchat.async_chat): def __init__(self, socket, pycore): - print 'initing SSS' asynchat.async_chat.__init__(self, socket) self.pycore = pycore self.handler = RequestHandler(pycore) @@ -70,11 +69,10 @@ class SecondaryServerSocket(asynchat.async_chat): def found_terminator(self): rep = self.handler.proceed(self.data) self.push(rep) - print "data arrived" self.data = "" #having fun with the data def handle_close(self): - print "Disconnected from", self.getpeername() + self.pycore.logger.info("Disconnected from "+ str(self.getpeername())) self.close() def push_obj(self, obj): obj = self.handler.encrypt(obj) |