diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-26 15:36:51 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-26 15:36:51 +0200 |
commit | d02541c948a71533469663b3400bc4a3179548c2 (patch) | |
tree | 021232e6a2e0f05b99b21041e66ae1ccdc651ea5 | |
parent | better youtube video id parsing, nicer testoutput (diff) | |
download | pyload-d02541c948a71533469663b3400bc4a3179548c2.tar.xz |
introduced logger
-rw-r--r-- | Core.py | 30 | ||||
-rw-r--r-- | Logs/faild.txt | 29 | ||||
-rw-r--r-- | Plugins/Plugin.py | 2 | ||||
-rw-r--r-- | Plugins/RSDF.py | 5 | ||||
-rw-r--r-- | module/download_thread.py | 18 | ||||
-rwxr-xr-x | module/network/Request.py | 3 | ||||
-rw-r--r-- | module/thread_list.py | 2 |
7 files changed, 63 insertions, 26 deletions
@@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # -#Copyright (C) 2009 sp00b, sebnapi +#Copyright (C) 2009 sp00b, sebnapi, RaNaN # #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by @@ -25,19 +25,19 @@ from glob import glob from string import find, split from os import sep, chdir, mkdir, curdir, name, system, remove from os.path import exists, abspath, dirname, basename -from sys import path, exit +from sys import path, exit, stdout from logging import warning, basicConfig import urllib2 import re from time import sleep, time +import logging +import logging.handlers #my imports from module.download_thread import Download_Thread from module.thread_list import Thread_List from module.Py_Load_File import PyLoadFile -basicConfig(filename='Logs/faild.txt', format = '%(message)s') - class Core(object): """ pyLoad main """ @@ -45,9 +45,9 @@ class Core(object): self.download_folder = "" self.link_file = "links.txt" self.plugins_avaible = {} - #self.plugins_needed = {} - #self.plugins_dict = {} - #self.applicationPath = "" + self.read_config() + self.init_logger(logging.DEBUG) # logging level + self.search_updates = False self.plugins_folder = "" self.read_config() @@ -90,7 +90,7 @@ class Core(object): pass if plugin_pattern != "": self.plugins_avaible[plugin_file] = plugin_pattern - print plugin_file, "hinzugefuegt" + self.logger.debug(plugin_file + " hinzugefuegt") print "Index der Plugins erstellt" ## def check_needed_plugins(self): @@ -207,6 +207,20 @@ class Core(object): self.thread_list.append_py_load_file(new_file) return True + def init_logger(self, level): + handler = logging.handlers.RotatingFileHandler('Logs/log.txt', maxBytes = 12800 , backupCount = 10) #100 kb + console = logging.StreamHandler(stdout) + #handler = logging.FileHandler('Logs/log.txt') + frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", + "%d.%m.%Y %H:%M:%S") + handler.setFormatter(frm) + console.setFormatter(frm) + + self.logger = logging.getLogger() # settable in config + self.logger.addHandler(handler) + self.logger.addHandler(console) #if console logging + self.logger.setLevel(level) + def _test_print_status(self): if self.thread_list.py_downloading: diff --git a/Logs/faild.txt b/Logs/faild.txt index e69de29bb..d77ca4862 100644 --- a/Logs/faild.txt +++ b/Logs/faild.txt @@ -0,0 +1,29 @@ +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +testest +geloggt +geloggt diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index 90781f765..f7ea99b7d 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -45,8 +45,6 @@ class Plugin(): def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html != None: - self.download_html() return self.parent.url diff --git a/Plugins/RSDF.py b/Plugins/RSDF.py index 9b377a2a3..65f01d41b 100644 --- a/Plugins/RSDF.py +++ b/Plugins/RSDF.py @@ -36,11 +36,6 @@ class RSDF(Plugin): """ returns True or False """ return True - - def get_file_url(self): - """ returns the absolute downloadable filepath - """ - return self.parent.url def __call__(self): return self.plugin_name diff --git a/module/download_thread.py b/module/download_thread.py index 502d42ddc..96bc4dd34 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -83,13 +83,12 @@ class Download_Thread(threading.Thread): if self.parent.py_load_files: self.loadedPyFile = self.parent.get_job() if self.loadedPyFile: - try: + try: self.download(self.loadedPyFile) - except Exception, e: - print "Error:", e - #catch up all error here - finally: - self.parent.job_finished(self.loadedPyFile) + except Exception, e: + print "Error:", e #catch up all error here + finally: + self.parent.job_finished(self.loadedPyFile) sleep(0.5) if self.shutdown: sleep(1) @@ -99,9 +98,9 @@ class Download_Thread(threading.Thread): pyfile = py_load_file status = pyfile.status pyfile.prepareDownload() - - if not status.exists: - raise "FileDontExists" #i know its deprecated, who cares^^ + + if not status.exists: + raise "FileDontExists" #i know its deprecated, who cares^^ if status.want_reconnect: print "handle reconnect" @@ -112,7 +111,6 @@ class Download_Thread(threading.Thread): try: status.type = "downloading" - print "download", status.filename pyfile.plugin.proceed(status.url, pyfile.download_folder + "/" + status.filename) status.type = "finished" diff --git a/module/network/Request.py b/module/network/Request.py index 1c0317cc7..510f6d069 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -27,6 +27,7 @@ class Request: def __init__(self): self.dl_time = 0 + self.dl_finished = 0 self.dl_size = 0 self.dl_arrived = 0 self.dl = False @@ -114,7 +115,7 @@ class Request: def get_ETA(self): try: - return (self.dl_size - self.dl_arrived) / (self.dl_arrived / (time.time() - self.dl_time)) + return (self.dl_size - self.dl_arrived) / (self.dl_arrived / (time.time() - self.dl_time if self.dl else self.dl_finished)) except: return "No Download" diff --git a/module/thread_list.py b/module/thread_list.py index 979a98c60..065318a56 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -73,6 +73,7 @@ class Thread_List(object): self.py_downloading.append(pyfile) if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) + self.parent.logger.info('start downloading ' + pyfile.url ) self.lock.release() return pyfile @@ -85,6 +86,7 @@ class Thread_List(object): self.occ_plugins.remove(pyfile.modul.__name__) self.py_downloading.remove(pyfile) + self.parent.logger.info('finished downloading ' + pyfile.url + ' @'+str(pyfile.status.get_speed())+'kb/s') if pyfile.plugin.plugin_type == "container": self.parent.extend_links(pyfile.plugin.links) |