def start(winhndl=None): """ Start quickscan. """ log.info("QuickScan starting..") # Check permissions verify_config_access() if not development_mode(default=True): # Generating temporary files names stdout_output = tempfile.mktemp() stderr_output = tempfile.mktemp() _stdout = open(stdout_output, "w") _stderr = open(stderr_output, "w") sys.stdout = _stdout sys.stderr = _stderr sys.excepthook = UmitExceptionHook() try: run_quickscan(winhndl) except KeyboardInterrupt: # if we are on win32, we should be here in case a WM_CLOSE message # was sent. safe_shutdown(None, None) else: # run_scheduler should finish normally when running as a Windows # Service safe_shutdown(None, None)
def safe_shutdown(rec_signal, frame): """ Remove temp files before quitting. """ log.info("Scheduler finishing..") if rec_signal is not None: raise SystemExit
def _graph_refresh(self, event): """ Perform graph refresh now. """ log.info(">>> TLGraph being refreshed!") self.connector.emit('data-changed', None, None) return True
def dump(self): log.info(">>> dump(): conflicts/provides/needs: %d / %d / %d" % \ ( len(self.who_conflicts), len(self.who_provides), len(self.who_needs) ) )
def __run_gui(self): log.info(">>> GUI Mode") import warnings warnings.filterwarnings("error", module = "gtk") try: import gtk except Warning, e: print e.message sys.exit(-1)
def save_changes(self, widget): log.info('>>> Saving preferences changes') general_settings.save_changes() expose_conf.save_changes() network_conf.save_changes() nse_conf.save_changes() # save changes of registered pages self.__vt.save_changes()
def stop(self): log.info('Reverting changes.') ScanNotebook.HIGAnimatedTabLabel = HIGClosableTabLabel sys.modules['higwidgets.hignotebooks'].HIGClosableTabLabel = \ HIGClosableTabLabel sys.modules['higwidgets.hignotebooks'].HIGAnimatedTabLabel = \ HIGClosableTabLabel self.update_existing_tab_labels(HIGClosableTabLabel)
def start(self, reader): global global_animation log.info('We\'re going to hook a class man. Pay attention.') Core().connect('NmapScanNotebookPage-created', self.__on_new_nb_page) path = reader.extract_file('data/throbber-16.gif') global_animation = gtk.gdk.PixbufAnimation(path) ScanNotebook.HIGAnimatedTabLabel = MyHIGClosableTabLabel sys.modules['higwidgets.hignotebooks'].HIGClosableTabLabel = \ MyHIGClosableTabLabel sys.modules['higwidgets.hignotebooks'].HIGAnimatedTabLabel = \ MyHIGClosableTabLabel self.update_existing_tab_labels(MyHIGClosableTabLabel)
def scan_path(self): """ Walk the path passed in the constructor for .ump files, then save the found plugins on a dict that could be accesed with get_plugins() No recursive scan, only top-level directory is considerated. """ if self.scanned or not os.path.exists(self.path): return for file in os.listdir(self.path): path = os.path.join(self.path, file) if file.endswith(".ump") and \ os.path.isfile(path): try: reader = PluginReader(path) except BadPlugin, exp: log.info("%s" % exp) continue self._plugins[file] = reader
class App: def __init__(self, args=sys.argv): self.main_window = None # Initialite the PluginEngine PluginEngine() def __parse_cmd_line(self): pass def __create_show_main_window(self): try: if option_parser.get_inventory(): from umit.inventory.Viewer import InventoryViewer self.main_window = InventoryViewer() else: from umit.gui.MainWindow import MainWindow self.main_window = MainWindow() except Exception: # If any exception happens at this point we need to stop gtk # so Umit doesn't hang. import gtk gtk.main_quit() raise if is_maemo(): import hildon self.hildon_app = hildon.Program() self.hildon_app.add_window(self.main_window) self.main_window.show_all() if not expose_conf.show_toolbar: self.main_window.toolbar.hide_all() def safe_shutdown(self, signum, stack): log.debug("\n\n%s\nSAFE SHUTDOWN!\n%s\n" % ("#" * 30, "#" * 30)) log.debug("SIGNUM: %s" % signum) if self.main_window: scans = self.main_window.scan_notebook.get_children() for scan in scans: log.debug(">>> Killing Scan: %s" % scan.get_tab_label()) scan.kill_scan() scan.close_tab() self.main_window.scan_notebook.remove(scan) del(scan) self.main_window._exit_cb() sys.exit(signum) def run(self): # Try to load psyco module, saving this information # if we care to use it later (such as in a About Dialog) if not development_mode(default=False): try: import psyco except ImportError: log.warning(_("RUNNING WITHOUT PSYCO!")) log.warning(_("psyco is a module that speeds up the execution " "of Python applications. It is not a requirement, and " "Umit will work normally without it, but you're " "encouraged to install it to have a better speed " "experience. Download psyco at http://psyco.sf.net/""")) self.using_psyco = False else: psyco.profile() self.using_psyco = True self.diff = option_parser.get_diff() if self.diff: self.__run_text() else: self.__run_gui() def __run_text(self): log.info(">>> Text Mode") def __run_gui(self): log.info(">>> GUI Mode") import warnings warnings.filterwarnings("error", module = "gtk") try: import gtk except Warning, e: print e.message sys.exit(-1) warnings.resetwarnings() import gobject log.info('>>> Splash run or not ?') if general_settings.splash: log.info(' >>> Running splash ') from umit.gui.Splash import Splash log.info(">>> Pixmaps path: %s" % Path.pixmaps_dir) if not is_maemo(): pixmap_d = Path.pixmaps_dir if pixmap_d: pixmap_file = os.path.join(pixmap_d, 'splash.png') self.splash = Splash(pixmap_file, 1400) if main_is_frozen(): # This is needed by py2exe gtk.gdk.threads_init() gtk.gdk.threads_enter() # Create and show the main window as soon as possible if general_settings.splash: gobject.idle_add(self.__create_show_main_window) else: self.__create_show_main_window() # Run main loop #gobject.threads_init() gtk.main() if main_is_frozen(): gtk.gdk.threads_leave()
def __run_text(self): log.info(">>> Text Mode")
def _brasil_log(self): if self.brazil: log.info("Isto aqui, o o") log.info("E um pouquinho de Brasil, io io") log.info("Deste Brasil que canta e e feliz") log.info("Feliz, feliz") log.info("") log.info("E tambem um pouco de uma raca") log.info("Que nao tem medo de fumaca ai, ai") log.info("E nao se entrega, nao ") log.info("") log.info('Olha o jeito das "cadera" que ela sabe dar') log.info("Olha o tombo nos quadris que ela sabe dar") log.info("Olha o passe de batuque que ela sabe dar") log.info("Olha so o remelexo que ela sabe dar") log.info("") log.info("Morena boa me faz chorar") log.info("Poe a sandalia de prata") log.info("e vem pro samba sambar") self.brazil = False