def start(self): """Delete the old logs and open the new ones""" if ProgramState.PY2EXE: #these redirect output, to avoid writing to the Main.exe.log (default py2exe behavior) #we want to avoid that because it pops a dialog about errors, and we definitely want to fail silently when demoing the app... sys.stdout = open(os.path.join(Globals.LOG_FOLDER, 'stdout.out'), "w") sys.stderr = open(os.path.join(Globals.LOG_FOLDER, 'stderr.out'), "w") #remove the old tor logs: Files.delete_file(os.path.join(Globals.LOG_FOLDER, 'tor.out'), True) #open up the debug logs and create the testfile: self.start_logs(["main", "errors", "automated", "pysocks", "tor_conn"], "main", Globals.LOG_FOLDER) #rotate the logs every half an hour, so that they can have lots of info, but not fill someone's hard drive... Scheduler.schedule_repeat(30 * 60, self.rotate_logs)
def start(self): """Delete the old logs and open the new ones""" if ProgramState.PY2EXE: #these redirect output, to avoid writing to the Main.exe.log (default py2exe behavior) #we want to avoid that because it pops a dialog about errors, and we definitely want to fail silently when demoing the app... sys.stdout = open(os.path.join(Globals.LOG_FOLDER, 'stdout.out'), "w") sys.stderr = open(os.path.join(Globals.LOG_FOLDER, 'stderr.out'), "w") #remove the old tor logs: Files.delete_file(os.path.join(Globals.LOG_FOLDER, 'tor.out'), True) #open up the debug logs and create the testfile: self.start_logs(["main", "errors", "automated", "pysocks", "tor_conn"], "main", Globals.LOG_FOLDER) #rotate the logs every half an hour, so that they can have lots of info, but not fill someone's hard drive... Scheduler.schedule_repeat(30 * 60, self.rotate_logs)
def check_previous_logs(): try: #check to see if we closed cleanly before we start_logs! errorFile = os.path.join(Globals.LOG_FOLDER, 'errors.out') shutdownMarkerFileName = os.path.join(Globals.LOG_FOLDER, 'closedcleanly.txt') failedToCloseCleanlyLastTime = Files.file_exists(shutdownMarkerFileName) wasErrorLastTime = Files.file_exists(errorFile) and os.path.getsize(errorFile) != 0 #submit error log if failedToCloseCleanlyLastTime or wasErrorLastTime: startTime = time.time() ClientUtil.create_error_archive("autogenerated") log_msg("Took %.2f seconds to zip error logs" % (time.time() - startTime), 2) #remove error log else: Files.delete_file(Globals.BUG_REPORT_NAME, True) except Exception, error: log_ex(error, "Failed to make error report!")
for arg in args: if arg == conf["address"]: found = True break if not found: continue dataDir = "tor_data%d" % (i) logFile = "%s/tor%d.out" % (LOG_FOLDER, i) data += "\nDataDirectory %s\n" % (dataDir) data += "Log [DIRSERV, OR] debug info file %s\n" % (logFile) data += "DirPort %s\n" % conf["dirport"] data += "ORPort %s\n" % conf["orport"] data += "Nickname %s\n" % conf["name"] data += "Address %s\n" % conf["address"] #clean up any leftover log files: Files.delete_file(logFile, True) #remove the old data if we're supposed to: if options.purge: if os.path.exists(dataDir): shutil.rmtree(dataDir, True) #copy keys over: os.makedirs(dataDir) copy_directory("keys%d" % (i), os.path.join(dataDir, "keys")) #print out the file fileName = "authority%d.conf" % (i) write_to_file(fileName, data) #start the process if System.IS_WINDOWS: p = subprocess.Popen(TOR_EXE + " -f " + fileName) else: p = subprocess.Popen([TOR_EXE, "-f", fileName], executable=TOR_EXE, cwd=os.getcwd())