def _setup_environment(self): """Finish misc startup tasks like starting logging, zipping any crash logs from the last run, installing signal handlers, startup argument handler, etc""" #apply the necessary hacks: Twisted.apply_dns_hack() Twisted.apply_dns_hack2() if System.IS_WINDOWS: Win32HiddenWindowHack.apply() #start listening for connections from any other instances of BitBlinder StartupServer.start() Profiler.start() #Make sure we log ALL exceptions Twisted.install_exception_handlers(self.on_quit_signal) #Set the signal handler for exiting def sig_handler(signum, frame): self.on_quit_signal() signal.signal(signal.SIGTERM, sig_handler) #make the gui: GUIController.start() self.gui = GUIController.get() #do some tests to see how this user's network is configured: NetworkState.test_network_state() #TODO: figure out what needs to change in the wrapper and submit a fix warnings.filterwarnings('ignore', module=".*TwistedProtocolWrapper.*", lineno=447)
def create_debug_menu(self): #Debug Menu self.debugMenu = gtk.Menu() self.profileMenuItem = GTKUtils.append_menu_item(self.debugMenu, "Start Profiler", self.toggle_profiler) def on_profiler_started(profiler): self.profileMenuItem.child.set_text("Stop Profiler") self._start_listening_for_event("started", Profiler.get(), on_profiler_started) def on_profiler_stopped(profiler): self.profileMenuItem.child.set_text("Start Profiler") self._start_listening_for_event("stopped", Profiler.get(), on_profiler_stopped) self.debugMenuRoot = gtk.MenuItem("Debug") self.debugMenuRoot.set_submenu(self.debugMenu) self.debugMenuRoot.show() return self.debugMenu
def toggle_profiler(self, widget=None): if Profiler.get().isProfiling: Profiler.get().stop() else: Profiler.get().start()