From 88227131086768d62f26be330f3101924ebbb50e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 28 May 2009 14:52:22 +0200 Subject: time shedule fix --- Core.py | 20 ++++++++++----- config | 4 +-- module/network/Request.py | 2 +- module/remote/SocketServer.py | 58 ++++++++++++++++++++++++++++++++++++++++++ module/remote/__init__.py | 1 + module/socket/SocketServer.py | 59 ------------------------------------------- 6 files changed, 75 insertions(+), 69 deletions(-) create mode 100644 module/remote/SocketServer.py create mode 100644 module/remote/__init__.py delete mode 100644 module/socket/SocketServer.py diff --git a/Core.py b/Core.py index 31b38013c..5f194fdc3 100644 --- a/Core.py +++ b/Core.py @@ -36,6 +36,7 @@ from sys import stdout from time import sleep from module.Py_Load_File import PyLoadFile +from module.remote.SocketServer import ServerThread from module.thread_list import Thread_List class Core(object): @@ -52,7 +53,7 @@ class Core(object): self.search_updates = False self.read_config() - print self.is_dltime # debug only + print "Downloadtime:", self.is_dltime() # debug only self.thread_list = Thread_List(self) @@ -201,11 +202,11 @@ class Core(object): print start_h, start_m, end_h, end_m print hour, minute - if hour > start_h and hour < end_h: + if hour > int(start_h) and hour < int(end_h): return True - elif hour == start_h and minute >= start_m: + elif hour == int(start_h) and minute >= int(start_m): return True - elif hour == end_h and minute <= end_m: + elif hour == int(end_h) and minute <= int(end_m): return True else: return False @@ -227,9 +228,14 @@ class Core(object): while True: #self.thread_list.status() self._test_print_status() - sleep(1) + sleep(2) if len(self.thread_list.threads) == 0: break -testLoader = Core() -testLoader.start() +if __name__ == "__main__": + + testLoader = Core() + #server = ServerThread(testLoader) + #server.start() + + testLoader.start() diff --git a/config b/config index 4c9b1fdf4..2ff4514a7 100644 --- a/config +++ b/config @@ -9,5 +9,5 @@ searchUpdates: True logFolder: Logs fullLog: True [time] -start: 10:00 -end: 13:00 \ No newline at end of file +start: 0:00 +end: 6:00 \ No newline at end of file diff --git a/module/network/Request.py b/module/network/Request.py index 07c1769ec..86449a4f2 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -83,7 +83,7 @@ class Request: return output - def addAuth(self, user, pw): + def add_auth(self, user, pw): self.downloader.addheaders.append(['Authorization','Basic ' + base64.encodestring(user + ':' + pw)[:-1]]) diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py new file mode 100644 index 000000000..4469f89ac --- /dev/null +++ b/module/remote/SocketServer.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -'- coding: utf-8 -*. +""" +authored by: RaNaN + +This modul class handels all incoming and outgoing data between server and gui + +""" +import asynchat +import asyncore +import socket +import threading + + +class ServerThread(threading.Thread): + def __init__(self, pycore): + threading.Thread.__init__(self) + self.setDaemon(True) + self.server = MainServerSocket(7272, pycore) + + def run(self): + asyncore.loop() + print "loop closed" + + +class MainServerSocket(asyncore.dispatcher): + def __init__(self, port, pycore): + print 'initing MSS' + asyncore.dispatcher.__init__(self) + 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 + SecondaryServerSocket(newSocket, self.pycore) + def handle_close(self): + print "going to close" + self.close() + + +class SecondaryServerSocket(asynchat.async_chat): + def __init__(self, pycore, *args): + print 'initing SSS' + self.pycore = pycore + asynchat.async_chat.__init__(self, *args) + self.set_terminator('\n') + self.data = [] + def collect_incoming_data(self, data): + self.data.append(data) + def found_terminator(self): + self.push("daten") + self.data = [] + #having fun with the data + def handle_close(self): + print "Disconnected from", self.getpeername() + self.close() \ No newline at end of file diff --git a/module/remote/__init__.py b/module/remote/__init__.py new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/module/remote/__init__.py @@ -0,0 +1 @@ + diff --git a/module/socket/SocketServer.py b/module/socket/SocketServer.py deleted file mode 100644 index 5466195e8..000000000 --- a/module/socket/SocketServer.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -'- coding: utf-8 -*. -""" -authored by: RaNaN - -This modul class handels all incoming and outgoing data between server and gui - -""" -import threading -import socket -import asyncore -import asynchat - -class ServerThread(threading.Thread): - - def __init__(self): - threading.Thread.__init__ (self) - self.server = MainServerSocket(7272) - - def run(self): - asyncore.loop() - - def stop(self): - asyncore.socket_map.clear() - self.server.close() - - -class MainServerSocket(asyncore.dispatcher): - def __init__(self, port): - print 'initing MSS' - asyncore.dispatcher.__init__(self) - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) - self.bind(('',port)) - self.listen(5) - def handle_accept(self): - newSocket, address = self.accept() - print "Connected from", address - SecondaryServerSocket(newSocket) - def handle_close(self): - print "going to close" - self.close() - - - -class SecondaryServerSocket(asynchat.async_chat): - def __init__(self, *args): - print 'initing SSS' - asynchat.async_chat.__init__(self, *args) - self.set_terminator('\n') - self.data = [] - def collect_incoming_data(self, data): - self.data.append(data) - def found_terminator(self): - self.push(''.join(self.data)) - self.data = [] - #having fun with the data - def handle_close(self): - print "Disconnected from", self.getpeername() - self.close() \ No newline at end of file -- cgit v1.2.3