summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-13 22:54:42 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-13 22:54:42 +0200
commit35e6ed6e84bd85aa487419edbc79ba44b18c665c (patch)
tree564df2238ce821b626f61f9a8678f8ac28afad0e
parentmore detailed debug reports (diff)
downloadpyload-35e6ed6e84bd85aa487419edbc79ba44b18c665c.tar.xz
refractored debug report + config section
-rw-r--r--module/PluginThread.py108
1 files changed, 61 insertions, 47 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py
index 059f2e097..50aa7c2c8 100644
--- a/module/PluginThread.py
+++ b/module/PluginThread.py
@@ -45,6 +45,62 @@ class PluginThread(Thread):
Thread.__init__(self)
self.setDaemon(True)
self.m = manager #thread manager
+
+
+ def writeDebugReport(self, pyfile):
+ dump = "pyLoad %s Debug Report of %s \n\nTRACEBACK:\n %s \n\nFRAMESTACK:\n" % (self.m.core.server_methods.get_server_version(), pyfile.pluginname, format_exc())
+
+ tb = exc_info()[2]
+ stack = []
+ while tb:
+ stack.append(tb.tb_frame)
+ tb = tb.tb_next
+
+ for frame in stack[1:]:
+
+ dump += "\nFrame %s in %s at line %s\n" % (frame.f_code.co_name,
+ frame.f_code.co_filename,
+ frame.f_lineno)
+
+ for key, value in frame.f_locals.items():
+ dump += "\t%20s = " % key
+ try:
+ if hasattr(value, "__iter__"):
+ dump += pformat(value) + ":" + pformat(list(value))
+ else:
+ dump += pformat(value) + "\n"
+ except:
+ dump += "<ERROR WHILE PRINTING VALUE>\n"
+
+ dump += "\n\nPLUGIN OBJECT DUMP: \n\n"
+
+ for name in dir(pyfile.plugin):
+ attr = getattr(pyfile.plugin, name)
+ if not name.endswith("__") and type(attr) not in (InstanceType,MethodType):
+ dump += "\t%20s = " % name
+ dump += pformat(attr) +"\n"
+
+ dump += "\nPYFILE OBJECT DUMP: \n\n"
+
+ for name in dir(pyfile):
+ attr = getattr(pyfile, name)
+ if not name.endswith("__") and type(attr) not in (InstanceType,MethodType):
+ dump += "\t%20s = " % name
+ dump += pformat(attr) +"\n"
+
+
+ if self.m.core.config.plugin.has_key(pyfile.pluginname):
+ dump += "\n\nCONFIG: \n\n"
+ dump += pformat(self.m.core.config.plugin[pyfile.pluginname]) +"\n"
+
+
+
+ dump_name = "debug_%s_%s.txt" % (pyfile.pluginname, strftime("%d%h%Y_%H:%M:%S"))
+ self.m.core.log.info("Debug Report written to %s" % dump_name)
+
+ f = open(dump_name, "wb")
+ f.write(dump)
+ f.close()
########################################################################
@@ -125,9 +181,11 @@ class DownloadThread(PluginThread):
except error, e:
code, msg = e
+
if self.m.core.debug:
print "pycurl error", code, msg
print_exc()
+ self.writeDebugReport()
if code == 7:
self.m.log.warning(_("Couldn't connect to host waiting 1 minute and retry."))
@@ -145,53 +203,8 @@ class DownloadThread(PluginThread):
pyfile.error = str(e)
if self.m.core.debug:
- print_exc()
-
- dump = "pyLoad Debug Report\n\nTRACEBACK from %s:\n %s \n\nDUMP from %s:\n" % (pyfile.pluginname, format_exc(), pyfile.pluginname)
-
- tb = exc_info()[2]
- stack = []
- while tb:
- stack.append(tb.tb_frame)
- tb = tb.tb_next
-
- for frame in stack[1:]:
-
- dump += "\nFrame %s in %s at line %s\n" % (frame.f_code.co_name,
- frame.f_code.co_filename,
- frame.f_lineno)
-
- for key, value in frame.f_locals.items():
- dump += "\t%20s = " % key
- try:
- if hasattr(value, "__iter__"):
- dump += pformat(value) + ":" + pformat(list(value))
- else:
- dump += pformat(value) + "\n"
- except:
- dump += "<ERROR WHILE PRINTING VALUE>\n"
-
- dump += "\n\nPLUGIN OBJECT DUMP: \n\n"
-
- for name in dir(pyfile.plugin):
- attr = getattr(pyfile.plugin, name)
- if not name.endswith("__") and type(attr) not in (InstanceType,MethodType):
- dump += "\t%20s = " % name
- dump += pformat(attr) +"\n"
-
- dump += "\nPYFILE OBJECT DUMP: \n\n"
-
- for name in dir(pyfile):
- attr = getattr(pyfile, name)
- if not name.endswith("__") and type(attr) not in (InstanceType,MethodType):
- dump += "\t%20s = " % name
- dump += pformat(attr) +"\n"
-
- dump_name = "debug_%s_%s.txt" % (pyfile.pluginname, strftime("%d%h%Y_%H:%M:%S"))
- self.m.core.log.info("Debug Report written to %s" % dump_name)
- f = open(dump_name, "wb")
- f.write(dump)
- f.close()
+ print_exc()
+ self.writeDebugReport(pyfile)
self.active = False
pyfile.release()
@@ -278,6 +291,7 @@ class DecrypterThread(PluginThread):
if self.m.core.debug:
print_exc()
+ self.writeDebugReport(pyfile)
return