def cleanup(self): """Make sure the reactor, threads, etc have been stopped. Also removes the file that indicates we shutdown cleanly.""" #shutdown Twisted if ProgramState.USE_GTK: Globals.reactor.stop() Globals.reactor.runUntilCurrent() #ensure that all threads have closed: remainingThreads = threading.enumerate() for thread in remainingThreads: if threading._MainThread != type(thread): log_msg( "Thread has not finished by the end of the program: %s" % (thread), 1) #start the update if necessary: if Updater.get().APPLY_UPDATE: ClientUtil.apply_update() #NOTE: we intentionally leave the log files open so that errors can get written to them... log_msg("Thanks for using BitBlinder", 2) ErrorReporting.destroy_marker_file() #NOTE: this is here so that threads can finish properly. I was getting errors from leftover threads without it. #However, I'm pretty sure that it was just from the IDE time.sleep(0.2)
def cleanup(self): """Make sure the reactor, threads, etc have been stopped. Also removes the file that indicates we shutdown cleanly.""" #shutdown Twisted if ProgramState.USE_GTK: Globals.reactor.stop() Globals.reactor.runUntilCurrent() #ensure that all threads have closed: remainingThreads = threading.enumerate() for thread in remainingThreads: if threading._MainThread != type(thread): log_msg("Thread has not finished by the end of the program: %s" % (thread), 1) #start the update if necessary: if Updater.get().APPLY_UPDATE: ClientUtil.apply_update() #NOTE: we intentionally leave the log files open so that errors can get written to them... log_msg("Thanks for using BitBlinder", 2) ErrorReporting.destroy_marker_file() #NOTE: this is here so that threads can finish properly. I was getting errors from leftover threads without it. #However, I'm pretty sure that it was just from the IDE time.sleep(0.2)
if os.path.exists(Globals.UPDATE_FILE_NAME): shutil.move(Globals.UPDATE_FILE_NAME, Globals.UPDATE_FILE_NAME + ".prev") break except Exception, error: time.sleep(0.5) if time.time() > startTime + 5.0: log_ex( error, "Failed to remove update .exe from the previous update" ) ignoreUpdater = True #ok, lets try making a file, just so I can see why this is failing for people: if issubclass(type(error), WindowsError): try: testFile = open( Globals.UPDATE_FILE_NAME + ".test", "wb") testFile.write("hello?") testFile.close() except Exception, error: log_ex(error, "And we could NOT write a file") else: log_msg( "But we successfully wrote to a file (%s) Weird." % (Globals.UPDATE_FILE_NAME + ".test")) break #apply any pending updates and quit: if ProgramState.INSTALLED and not ignoreUpdater and Files.file_exists( Globals.UPDATE_FILE_NAME): ClientUtil.apply_update()