diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-01-21 22:13:21 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-01-21 22:13:21 +0100 |
commit | 4eb1404eca2b795d809ee626a057a543043060cb (patch) | |
tree | db25eddebc985a6066001e38e593c8f45e468910 | |
parent | Fixed Netload Wait (diff) | |
download | pyload-4eb1404eca2b795d809ee626a057a543043060cb.tar.xz |
some optimizations
-rw-r--r-- | module/Plugin.py | 3 | ||||
-rw-r--r-- | module/download_thread.py | 7 | ||||
-rw-r--r-- | module/file_list.py | 1 | ||||
-rw-r--r-- | module/plugins/Hook.py | 2 | ||||
-rwxr-xr-x | pyLoadCore.py | 31 |
5 files changed, 17 insertions, 27 deletions
diff --git a/module/Plugin.py b/module/Plugin.py index 2e61a1b55..5006da8dd 100644 --- a/module/Plugin.py +++ b/module/Plugin.py @@ -19,12 +19,11 @@ import logging import re -from os.path import exists, join +from os.path import exists from time import sleep from module.network.Request import Request -from module.XMLConfigParser import XMLConfigParser from module.download_thread import CaptchaError diff --git a/module/download_thread.py b/module/download_thread.py index a07f4511f..4a031a04c 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -49,7 +49,8 @@ class Status(object): return self.pyfile.plugin.req.dl_size / 1024 def percent(self): if not self.kB_left() == 0 and not self.size() == 0: - return ((self.size()-self.kB_left()) * 100) / self.size() + percent = ((self.size()-self.kB_left()) * 100) / self.size() + return percent if percent < 101 else 0 return 0 class Reconnect(Exception): @@ -115,7 +116,9 @@ class Download_Thread(threading.Thread): self.loadedPyFile.status.error = str(e) finally: self.parent.job_finished(self.loadedPyFile) - sleep(0.5) + else: + sleep(3) + sleep(0.8) if self.shutdown: sleep(1) self.parent.remove_thread(self) diff --git a/module/file_list.py b/module/file_list.py index bbea40e23..2785afdb2 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -144,6 +144,7 @@ class File_List(object): return files def getAllFiles(self): + files = [] for pypack in self.data["queue"] + self.data["packages"]: for pyfile in pypack.files: diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 6f8a48802..541d0c2e9 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -19,9 +19,7 @@ """ import logging -from os.path import join -from module.XMLConfigParser import XMLConfigParser class Hook(): def __init__(self, core): diff --git a/pyLoadCore.py b/pyLoadCore.py index 96cd1b204..05a487cf8 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -23,15 +23,17 @@ """
CURRENT_VERSION = '0.3'
+from getopt import getopt
import gettext
from glob import glob
from imp import find_module
import logging
import logging.handlers
+from operator import attrgetter
from os import execv
from os import makedirs
-from os import sep
from os import remove
+from os import sep
from os.path import basename
from os.path import dirname
from os.path import exists
@@ -48,7 +50,6 @@ import thread import time
from time import sleep
from xmlrpclib import Binary
-from getopt import getopt
from module.CaptchaManager import CaptchaManager
from module.HookManager import HookManager
@@ -304,9 +305,8 @@ class Core(object): def compare_time(self, start, end):
- toInt = lambda x: int(x)
- start = map(toInt, start)
- end = map(toInt, end)
+ start = map(int, start)
+ end = map(int, end)
if start == end: return True
@@ -469,8 +469,7 @@ class ServerMethods(): self.core.file_list.save()
def del_packages(self, ids):
- for id in ids:
- self.core.file_list.packager.removePackage(id)
+ map(self.core.file_list.packager.removePackage, ids)
self.core.file_list.save()
def kill(self):
@@ -481,22 +480,13 @@ class ServerMethods(): self.core.do_restart = True
def get_queue(self):
- data = []
- for q in self.core.file_list.data["queue"]:
- data.append(q.data)
- return data
+ return map(attrgetter("data"), self.core.file_list.data["queue"])
def get_collector_packages(self):
- data = []
- for q in self.core.file_list.data["packages"]:
- data.append(q.data)
- return data
+ return map(attrgetter("data"), self.core.file_list.data["packages"])
def get_collector_files(self):
- files = []
- for f in self.core.file_list.data["collector"]:
- files.append(f.id)
- return files
+ return map(attrgetter("id"), self.core.file_list.data["collector"])
def move_file_2_package(self, fid, pid):
try:
@@ -511,8 +501,7 @@ class ServerMethods(): self.core.file_list.packager.pushPackage2Queue(id)
def restart_package(self, packid):
- for id in self.core.file_list.packager.getPackageFiles(packid):
- self.core.file_list.packager.resetFileStatus(id)
+ map(self.core.file_list.packager.resetFileStatus, self.core.file_list.packager.getPackageFiles(packid))
def restart_file(self, fileid):
self.core.file_list.packager.resetFileStatus(fileid)
|