summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-02 20:42:13 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-02 20:42:13 +0200
commit113a7c42c94953a9491e7aad501269f476a79af4 (patch)
treef478f367f5a820772e4a87cf4881da35c88b10e1 /module
parentwebif: log+download page (diff)
downloadpyload-113a7c42c94953a9491e7aad501269f476a79af4.tar.xz
new dlc plugins
Diffstat (limited to 'module')
-rw-r--r--module/ConfigParser.py2
-rw-r--r--module/PluginManager.py2
-rw-r--r--module/ThreadManager.py50
-rwxr-xr-xmodule/network/Request.py11
-rw-r--r--module/plugins/container/DLC_25.pycbin7765 -> 8193 bytes
-rw-r--r--module/plugins/container/DLC_26.pycbin7757 -> 8166 bytes
6 files changed, 49 insertions, 16 deletions
diff --git a/module/ConfigParser.py b/module/ConfigParser.py
index 859136572..b9b46176b 100644
--- a/module/ConfigParser.py
+++ b/module/ConfigParser.py
@@ -39,7 +39,6 @@ class ConfigParser:
self.password = ""
#stored outside and may not modified
- #@TODO start setup..
self.checkVersion()
@@ -192,7 +191,6 @@ class ConfigParser:
#----------------------------------------------------------------------
def saveConfig(self, config, filename):
"""saves config to filename"""
- #@TODO save username and config
with open(filename, "wb") as f:
for section in config.iterkeys():
diff --git a/module/PluginManager.py b/module/PluginManager.py
index bace9807d..e2e3c934b 100644
--- a/module/PluginManager.py
+++ b/module/PluginManager.py
@@ -134,7 +134,7 @@ class PluginManager():
for item in config:
self.core.config.addPluginConfig([name]+item)
- #@TODO replace with plugins in homedir, plugin updater
+ # replace with plugins in homedir, plugin updater
return plugins
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index a49885297..a48d7e729 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -19,10 +19,13 @@
"""
from threading import Event
-import PluginThread
-
+from subprocess import Popen
+from os.path import exists
from time import sleep
+from module.network.Request import getURL
+import PluginThread
+
########################################################################
class ThreadManager:
"""manages the download threads, assign jobs, reconnect etc"""
@@ -68,33 +71,58 @@ class ThreadManager:
def work(self):
"""run all task which have to be done (this is for repetivive call by core)"""
- self.checkReconnect()
+ self.tryReconnect()
self.checkThreadCount()
self.assignJob()
#----------------------------------------------------------------------
- def checkReconnect(self):
+ def tryReconnect(self):
"""checks if reconnect needed"""
if not (self.core.server_methods.is_time_reconnect() and self.core.config["reconnect"]["activated"] ):
return False
-
+
active = [x.active.plugin.wantReconnect and x.active.plugin.waiting for x in self.threads if x.active]
- print active
+
if active.count(True) > 0 and len(active) == active.count(True):
+
+ if not exists(self.core.config['reconnect']['method']):
+ if exists(join(pypath, self.core.config['reconnect']['method'])):
+ self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method'])
+ else:
+ self.core.config["reconnect"]["activated"] = False
+ self.log.warning(_("Reconnect script not found!"))
+ return
+
+
self.reconnecting.set()
#Do reconnect
- self.log.info(_("Reconnecting"))
+ self.log.info(_("Starting reconnect"))
+
while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0:
sleep(0.25)
-
- print "wating finsihed"
+
+ ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1)
- print "do reconnect"
-
+ self.core.hookManager.beforeReconnecting(ip)
+ reconn = Popen(self.core.config['reconnect']['method'])#, stdout=subprocess.PIPE)
+ reconn.wait()
+ sleep(1)
+ ip = ""
+ while ip == "":
+ try:
+ ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) #get new ip
+ except:
+ ip = ""
+ sleep(1)
+ self.core.hookManager.afterReconnecting(ip)
+
+ self.log.info(_("Reconnected, new IP: %s") % ip)
+
+
self.reconnecting.clear()
#----------------------------------------------------------------------
diff --git a/module/network/Request.py b/module/network/Request.py
index f3e399c1d..012d01ddf 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -85,7 +85,7 @@ class Request:
self.pycurl.setopt(pycurl.CONNECTTIMEOUT, 30)
self.pycurl.setopt(pycurl.NOSIGNAL, 1)
self.pycurl.setopt(pycurl.NOPROGRESS, 0)
- self.pycurl.setopt(pycurl.PROGRESSFUNCTION, self.progress)
+ self.pycurl.setopt(pycurl.PROGRESSFUNCTION, self.noprogress)
self.pycurl.setopt(pycurl.AUTOREFERER, 1)
self.pycurl.setopt(pycurl.HEADERFUNCTION, self.write_header)
self.pycurl.setopt(pycurl.BUFFERSIZE, self.bufferSize)
@@ -125,6 +125,7 @@ class Request:
def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, no_post_encode=False):
+
url = str(url)
if post:
@@ -198,6 +199,8 @@ class Request:
url = str(url)
+ self.pycurl.setopt(pycurl.PROGRESSFUNCTION, self.progress)
+
if post:
if not no_post_encode:
post = urllib.urlencode(post)
@@ -351,7 +354,11 @@ class Request:
return False
self.dl_arrived = int(dl_d)
self.dl_size = int(dl_t)
-
+
+ def noprogress(self, dl_t, dl_d, up_t, up_d):
+ if self.abort:
+ return False
+
def get_free_name(self, folder, file_name):
file_count = 0
file_name = join(folder, file_name)
diff --git a/module/plugins/container/DLC_25.pyc b/module/plugins/container/DLC_25.pyc
index a2f396dc6..512ceda08 100644
--- a/module/plugins/container/DLC_25.pyc
+++ b/module/plugins/container/DLC_25.pyc
Binary files differ
diff --git a/module/plugins/container/DLC_26.pyc b/module/plugins/container/DLC_26.pyc
index 5c8c98088..60378b5a8 100644
--- a/module/plugins/container/DLC_26.pyc
+++ b/module/plugins/container/DLC_26.pyc
Binary files differ