summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-20 15:51:27 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-20 15:51:27 +0200
commit0e674e35a5d565a2af07ab7f1b69ab43d364b819 (patch)
tree56ea0dc3d4ff02c925162153508a203fa29fa4bb
parentnormal name style (diff)
downloadpyload-0e674e35a5d565a2af07ab7f1b69ab43d364b819.tar.xz
was wir nicht brauchen auskommentiert, host überprüfung verlagert
-rw-r--r--Core.py92
-rw-r--r--module/Py_Load_File.py23
2 files changed, 62 insertions, 53 deletions
diff --git a/Core.py b/Core.py
index f2497e0ec..187c9f9f6 100644
--- a/Core.py
+++ b/Core.py
@@ -47,8 +47,8 @@ class Core(object):
self.link_file = "links.txt"
self.plugin_index = "plugin_index.txt"
self.plugins_avaible = {}
- self.plugins_needed = {}
- self.plugins_dict = {}
+ #self.plugins_needed = {}
+ #self.plugins_dict = {}
#self.applicationPath = ""
self.search_updates = False
self.plugins_folder = ""
@@ -57,6 +57,7 @@ class Core(object):
self.create_download_folder(self.download_folder)
self.create_link_file(self.link_file)
self.check_update()
+ self.check_temp_file()
def read_config(self):
""" sets self.download_folder, self.applicationPath, self.search_updates and self.plugins_folder
@@ -72,11 +73,11 @@ class Core(object):
####################################################################################################
- def import_plugins(self):
- self.check_temp_file()
- self.check_needed_plugins()
- self.import_needed_plugins()
-
+## def import_plugins(self):
+## self.check_temp_file()
+## #self.check_needed_plugins()
+## #self.import_needed_plugins()
+
def check_temp_file(self):
if not exists(self.plugin_index):
self.create_plugin_index()
@@ -103,30 +104,30 @@ class Core(object):
pickle.dump(self.plugins_avaible, open(self.plugin_index, "w"))
print "Index der Plugins erstellt"
- def check_needed_plugins(self):
- links = open(self.link_file, 'r').readlines()
- plugins_indexed = pickle.load(open(self.plugin_index, "r"))
- for link in links:
- link = link.replace("\n", "")
- for plugin_file in plugins_indexed.keys():
- if re.search(plugins_indexed[plugin_file], link) != None:
- self.plugins_needed[plugin_file] = plugins_indexed[plugin_file]
- print "Benoetigte Plugins: " + str(self.plugins_needed.keys())
-
- def import_needed_plugins(self):
- for needed_plugin in self.plugins_needed.keys():
- self.import_plugin(needed_plugin)
-
- def import_plugin(self, needed_plugin):
- try:
- new_plugin = __import__(needed_plugin)
- self.plugins_dict[new_plugin] = self.plugins_needed[needed_plugin]
- #if new_plugin.plugin_type in "hoster" or new_plugin.plugin_type in "container":
- # print "Plugin geladen: " + new_plugin.plugin_name
- #plugins[plugin_file] = __import__(plugin_file)
- except:
- print "Fehlerhaftes Plugin: " + needed_plugin
-
+## def check_needed_plugins(self):
+## links = open(self.link_file, 'r').readlines()
+## plugins_indexed = pickle.load(open(self.plugin_index, "r"))
+## for link in links:
+## link = link.replace("\n", "")
+## for plugin_file in plugins_indexed.keys():
+## if re.search(plugins_indexed[plugin_file], link) != None:
+## self.plugins_needed[plugin_file] = plugins_indexed[plugin_file]
+## print "Benoetigte Plugins: " + str(self.plugins_needed.keys())
+##
+## def import_needed_plugins(self):
+## for needed_plugin in self.plugins_needed.keys():
+## self.import_plugin(needed_plugin)
+##
+## def import_plugin(self, needed_plugin):
+## try:
+## new_plugin = __import__(needed_plugin)
+## self.plugins_dict[new_plugin] = self.plugins_needed[needed_plugin]
+## #if new_plugin.plugin_type in "hoster" or new_plugin.plugin_type in "container":
+## # print "Plugin geladen: " + new_plugin.plugin_name
+## #plugins[plugin_file] = __import__(plugin_file)
+## except:
+## print "Fehlerhaftes Plugin: " + needed_plugin
+##
####################################################################################################
@@ -161,7 +162,7 @@ class Core(object):
if link not in self.thread_list.get_loaded_urls():
plugin = self.get_hoster(link)
if plugin != None:
- self.__new_py_load_file(link, plugin)
+ self.__new_py_load_file(link)
else:
return False
@@ -208,15 +209,15 @@ class Core(object):
def get_hoster(self, url):
""" searches the right plugin for an url
"""
- for plugin, plugin_pattern in self.plugins_dict.items():
+ for plugin, plugin_pattern in self.plugins_avaible.items():
if re.match(plugin_pattern, url) != None: #guckt ob übergebende url auf muster des plugins passt
return plugin
#logger: kein plugin gefunden
return None
- def __new_py_load_file(self, url, plugin):
- new_file = PyLoadFile(self, plugin, url)
+ def __new_py_load_file(self, url):
+ new_file = PyLoadFile(self, url)
new_file.download_folder = self.download_folder
self.thread_list.append_py_load_file(new_file)
return True
@@ -229,15 +230,15 @@ class Core(object):
print "Speed" ,pyfile.status.get_speed()
print "ETA" , pyfile.status.get_ETA()
- try:
- fn = pyfile.status.filename
- p = round(float(pyfile.status.downloaded_kb)/pyfile.status.total_kb, 2)
- s = round(pyfile.status.rate, 2)
- del pyfile.status #?!?
- pyfile.status = None
- print fn + ": " + str(p) + " @ " + str(s) + "kB/s"
- except:
- print pyfile.status.filename, "downloading"
+ #try:
+ # fn = pyfile.status.filename
+ # p = round(float(pyfile.status.downloaded_kb)/pyfile.status.total_kb, 2)
+ # s = round(pyfile.status.rate, 2)
+ # del pyfile.status #?!?
+ # pyfile.status = None
+ # print fn + ": " + str(p) + " @ " + str(s) + "kB/s"
+ #except:
+ # print pyfile.status.filename, "downloading"
if pyfile.status.type == 'waiting':
print pyfile.status.filename + ": " + "wartet", pyfile.status.waituntil -time()
@@ -247,12 +248,11 @@ class Core(object):
"""
self._get_links(self.link_file)
while True:
- self.thread_list.status()
+ #self.thread_list.status()
self._test_print_status()
sleep(1)
if len(self.thread_list.threads) == 0:
break
testLoader = Core()
-testLoader.import_plugins()
testLoader.start()
diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py
index 4eee82f91..96936e4af 100644
--- a/module/Py_Load_File.py
+++ b/module/Py_Load_File.py
@@ -1,25 +1,34 @@
+# -*- coding: cp1252 -*-
from download_thread import Status
+import re
class PyLoadFile:
""" represents the url or file
"""
- def __init__(self, parent, plugin, url):
+ def __init__(self, parent, url):
self.parent = parent
self.id = None
- pluginClass = getattr(plugin, plugin.__name__)
- self.plugin = pluginClass(self)
self.url = url
self.filename = "filename"
self.download_folder = ""
+ self.modul = __import__(self._get_my_plugin())
+ pluginClass = getattr(self.modul, self.modul.__name__)
+ self.plugin = pluginClass(self)
+ self.download_folder = ""
self.status = Status(self)
- def _get_my_plugin():
- plugins = parent.get_avail_plugins()
-
+ def _get_my_plugin(self):
+ """ searches the right plugin for an url
+ """
+ for plugin, plugin_pattern in self.parent.plugins_avaible.items():
+ if re.match(plugin_pattern, self.url) != None: #guckt ob übergebende url auf muster des plugins passt
+ return plugin
+ #logger: kein plugin gefunden # was soll passieren wenn nichts gefunden wird?!?
+ return None
def prepareDownload(self):
- self.status.exists = self.plugin.file_exists()
+ self.status.exists = self.plugin.file_exists()
if self.status.exists:
self.status.filename = self.plugin.get_file_name()
self.status.waituntil = self.plugin.time_plus_wait