summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-26 13:24:55 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-26 13:24:55 +0200
commit1de8f589216259f42ead0dddbc2954fae8e5e528 (patch)
tree8c4ed7ba0c327730f794536ee7d7ab62b641255e /module
parentimproved plugins (diff)
downloadpyload-1de8f589216259f42ead0dddbc2954fae8e5e528.tar.xz
logic for container plugins implemented, basic plugin now downloads files, RSDF plugin added
Diffstat (limited to 'module')
-rw-r--r--module/Py_Load_File.py2
-rw-r--r--module/download_thread.py3
-rwxr-xr-xmodule/network/Request.py4
-rw-r--r--module/socket/SocketServer.py59
-rw-r--r--module/thread_list.py55
5 files changed, 93 insertions, 30 deletions
diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py
index 9f962ffb3..ce2a10924 100644
--- a/module/Py_Load_File.py
+++ b/module/Py_Load_File.py
@@ -27,7 +27,7 @@ class PyLoadFile:
def prepareDownload(self):
self.status.exists = self.plugin.file_exists()
- if self.status.exists:
+ if self.status.exists:
self.status.filename = self.plugin.get_file_name()
self.status.waituntil = self.plugin.time_plus_wait
self.status.url = self.plugin.get_file_url()
diff --git a/module/download_thread.py b/module/download_thread.py
index f103b2271..6eb90138f 100644
--- a/module/download_thread.py
+++ b/module/download_thread.py
@@ -102,7 +102,6 @@ class Download_Thread(threading.Thread):
if not status.exists:
raise "FileDontExists" #i know its deprecated, who cares^^
-
if status.want_reconnect:
print "handle reconnect"
@@ -115,7 +114,7 @@ class Download_Thread(threading.Thread):
status.type = "downloading"
print status.url , status.filename
- pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename)
+ pyfile.plugin.proceed(status.url, pyfile.download_folder + "/" + status.filename)
status.type = "finished"
except:
status.type = "failed"
diff --git a/module/network/Request.py b/module/network/Request.py
index 7ddeec876..1c0317cc7 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -39,7 +39,7 @@ class Request:
#self.opener.add_handler()
self.opener.addheaders = [
- ("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8"),
+ ("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.10"),
("Accept-Encoding","gzip,deflate"),
("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"),
@@ -47,7 +47,7 @@ class Request:
("Keep-Alive","300")]
self.downloader.addheaders = [
- ("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8"),
+ ("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.10"),
("Accept-Encoding","gzip,deflate"),
("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7")]
diff --git a/module/socket/SocketServer.py b/module/socket/SocketServer.py
new file mode 100644
index 000000000..5466195e8
--- /dev/null
+++ b/module/socket/SocketServer.py
@@ -0,0 +1,59 @@
+#!/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
diff --git a/module/thread_list.py b/module/thread_list.py
index 1f967540b..979a98c60 100644
--- a/module/thread_list.py
+++ b/module/thread_list.py
@@ -32,9 +32,9 @@ class Thread_List(object):
self.download_queue = Queue()
#self.status_queue = Queue()
self.f_relation = [0,0]
- self.lock = Lock()
- self.py_downloading = [] # files downloading
- self.occ_plugins = [] #occupied plugins
+ self.lock = Lock()
+ self.py_downloading = [] # files downloading
+ self.occ_plugins = [] #occupied plugins
def create_thread(self):
""" creates thread for Py_Load_File and append thread to self.threads
@@ -61,32 +61,37 @@ class Thread_List(object):
def get_job(self):
# return job if suitable, otherwise send thread idle
- self.lock.acquire()
-
- pyfile = None
-
- for i in range(len(self.py_load_files)):
- if not self.py_load_files[i].modul.__name__ in self.occ_plugins:
- pyfile = self.py_load_files.pop(i)
-
- if pyfile:
- self.py_downloading.append(pyfile)
- if not pyfile.plugin.multi_dl:
- self.occ_plugins.append(pyfile.modul.__name__)
-
- self.lock.release()
+ self.lock.acquire()
+
+ pyfile = None
+ for i in range(len(self.py_load_files)):
+ if not self.py_load_files[i].modul.__name__ in self.occ_plugins:
+ pyfile = self.py_load_files.pop(i)
+ break
+
+ if pyfile:
+ self.py_downloading.append(pyfile)
+ if not pyfile.plugin.multi_dl:
+ self.occ_plugins.append(pyfile.modul.__name__)
+
+ self.lock.release()
return pyfile
-
+
+
def job_finished(self, pyfile):
- self.lock.acquire()
-
- self.occ_plugins.remove(pyfile.modul.__name__)
- self.py_downloading.remove(pyfile)
+ self.lock.acquire()
+
+ if not pyfile.plugin.multi_dl:
+ self.occ_plugins.remove(pyfile.modul.__name__)
+
+ self.py_downloading.remove(pyfile)
+
+ if pyfile.plugin.plugin_type == "container":
+ self.parent.extend_links(pyfile.plugin.links)
#remove from list, logging etc
-
- self.lock.release()
- return True
+ self.lock.release()
+ return True
def extend_py_load_files(self):
pass