writes a :return:
(self, pyfile)
| 49 | |
| 50 | |
| 51 | def writeDebugReport(self, pyfile): |
| 52 | """ writes a |
| 53 | :return: |
| 54 | """ |
| 55 | |
| 56 | dump_name = "debug_%s_%s.zip" % (pyfile.pluginname, strftime("%d-%m-%Y_%H-%M-%S")) |
| 57 | dump = self.getDebugDump(pyfile) |
| 58 | |
| 59 | try: |
| 60 | import zipfile |
| 61 | |
| 62 | zip = zipfile.ZipFile(dump_name, "w") |
| 63 | |
| 64 | for f in listdir(join("tmp", pyfile.pluginname)): |
| 65 | try: |
| 66 | # avoid encoding errors |
| 67 | zip.write(join("tmp", pyfile.pluginname, f), save_join(pyfile.pluginname, f)) |
| 68 | except: |
| 69 | pass |
| 70 | |
| 71 | info = zipfile.ZipInfo(save_join(pyfile.pluginname, "debug_Report.txt"), gmtime()) |
| 72 | info.external_attr = 0644 << 16L # change permissions |
| 73 | |
| 74 | zip.writestr(info, dump) |
| 75 | zip.close() |
| 76 | |
| 77 | if not stat(dump_name).st_size: |
| 78 | raise Exception("Empty Zipfile") |
| 79 | |
| 80 | except Exception, e: |
| 81 | self.m.log.debug("Error creating zip file: %s" % e) |
| 82 | |
| 83 | dump_name = dump_name.replace(".zip", ".txt") |
| 84 | f = open(dump_name, "wb") |
| 85 | f.write(dump) |
| 86 | f.close() |
| 87 | |
| 88 | self.m.core.log.info("Debug Report written to %s" % dump_name) |
| 89 | |
| 90 | def getDebugDump(self, pyfile): |
| 91 | dump = "pyLoad %s Debug Report of %s %s \n\nTRACEBACK:\n %s \n\nFRAMESTACK:\n" % ( |