def show_failed(self,result): """ """ alert = HIGAlertDialog(message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy()
def choose_forward(self, widget): if self.directions['Choose'].command_radio.get_active(): if self.directions['Choose'].target_entry.get_text() == '': alert = HIGAlertDialog(message_format=_('No target selected!'),\ secondary_text=_('You must provide a target \ to be scanned.')) alert.run() alert.destroy() self.directions['Choose'].target_entry.grab_focus() return None self.main_vbox.remove(self.directions['Choose']) self.directions['Choose'].hide() if self.directions['Choose'].profile_radio.get_active(): self.main_vbox._pack_expand_fill(self.directions['Profile']) self.directions['Profile'].show_all() self.directions['LastPage'] = self.directions['Profile'] self.directions['Profile'].prof = True self.target = '<target>' else: self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Choose'] self.directions['Profile'].prof = False self.target = self.directions['Choose'].target_entry.get_text() self.directions['Choose'].add_new_target(self.target) self.update_command()
def __init__(self, title, text, buttons=None, dlg_type=gtk.MESSAGE_WARNING): """ when passing buttons, use a format like this: {key: (response: stock)} -> where key should be an integer, so it will pack buttons in the order you want. """ HIGAlertDialog.__init__(self, type=dlg_type, buttons=gtk.BUTTONS_NONE, message_format=title, secondary_text=text) dlg_vbox = self.get_children()[0] buttons_box = dlg_vbox.get_children()[-1] if not buttons: buttons = { } # pack buttons in dialog's buttonsbox for resp_button in buttons.values(): resp = resp_button[0] button = resp_button[1] btn = gtk.Button(stock=button) btn.show() buttons_box.pack_start(btn, False, False, 0) btn.connect('clicked', self._send_response, resp)
def get_networks(self, event): """ Try to detect network(s). """ networks = tryto_detect_networks() if not networks: dlg = HIGAlertDialog(self, message_format=_("No network(s) detected."), secondary_text=_("You will need to especify the " "network(s) yourself before detecting hosts.")) dlg.run() dlg.destroy() return entries = len(self.networks_box.get_children()) - 1 for amount, nw in enumerate(networks): if amount == entries: e = gtk.Entry() e.set_text('') e.show() self.networks_box.add(e) entries += 1 entry = self.networks_box.get_children()[amount] entry.set_text(nw.cidr_netaddress())
def set_info(self, ScanNotebookPageBT, btid): global btname global btmac global btmanu global btsdp global sdpstatus sdpbrowseinfo = "" btid+=1 print "Selected: " + str(ScanNotebookPageBT.btmap.get_selected_items()) + "\n" + str(btid) ScanNotebookPageBT.label.set_text("Device Details\t\t\t\t\n\nName: " + btname[btid] + "\nMAC: " + btmac[btid] + "\nManufacturer: " + btmanu[btid]) print "Status_select: " + sdpstatus print "Found " + str(len(btsdp[btid])) + " Services" if (sdpstatus == "Enabled"): if (len(btsdp[btid]) < 1): ScanNotebookPageBT.sdpview.get_buffer().set_text("no services found") return sdpbrowseinfo = "\nFound " + str(len(btsdp[btid])) + " Services" for svc in btsdp[btid]: try: if(str(svc["name"])=="no services found" or str(svc["name"])== ""): ScanNotebookPageBT.sdpview.get_buffer().set_text("no services found") else: try: sdpbrowseinfo += "\n\nService Name: " + str(svc["name"]) + "\n Description: " + str(svc["description"]) sdpbrowseinfo += "\n Provided By: " + str(svc["provider"]) + "\n Protocol: " + str(svc["protocol"]) sdpbrowseinfo += "\n channel/PSM: " + str(svc["port"]) + "\n svc classes: " + str(svc["service-classes"]) sdpbrowseinfo += "\n profiles: " + str(svc["profiles"]) + "\n service id: " + str(svc["service-id"]) ScanNotebookPageBT.sdpview.get_buffer().set_text(sdpbrowseinfo) except: ScanNotebookPageBT.sdpview.get_buffer().set_text("N/A") dlg = HIGAlertDialog(None, message_format=('Error'), secondary_text=("An error occurred while parsing SDP data")) dlg.run() dlg.destroy() except: ScanNotebookPageBT.sdpview.get_buffer().set_text("no services found")
def open_file (self, widget): file_chooser = ResultsFileChooserDialog(_("Select Scan Result")) file_chooser.run() file_chosen = file_chooser.get_filename() file_chooser.destroy() if check_access(file_chosen, os.R_OK): try: parser = NmapParser(file_chosen) parser.parse() except: alert = HIGAlertDialog( message_format='<b>%s</b>' % _('File is not a Umit \ Scan Result'), secondary_text=_("Selected file is not a Umit Scan \ Result file. Umit can not parse this file. Please, select another.")) alert.run() alert.destroy() return False scan_name = os.path.split(file_chosen)[-1] self.add_scan(scan_name, parser) self.combo_scan.set_active(len(self.list_scan) - 1) else: alert = HIGAlertDialog( message_format='<b>%s</b>' % \ _('Can not open selected file'), secondary_text=_("Umit can not open selected file. Please, \ select another.")) alert.run() alert.destroy()
def save_profile(self, widget): command = self.constructor.get_command('%s') close_popup = True if self.directions['Choose'].profile_radio.get_active(): profile_name = self.directions['Profile'].profile_entry.get_text() hint = self.directions['Profile'].hint_entry.get_text() buffer = self.directions['Profile'].description_text.get_buffer() description = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) buffer = self.directions['Profile'].annotation_text.get_buffer() annotation = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ options=self.constructor.get_options()) notebook_n_pages = 0 if self.notebook: notebook_n_pages = self.notebook.get_n_pages() for i in xrange(notebook_n_pages): page = self.notebook.get_nth_page(i) page.toolbar.profile_entry.update() elif self.notebook: target = self.directions['Choose'].target_entry.get_text() try: cmd = command % target except TypeError: alert = HIGAlertDialog(message_format=_('Invalid Command'),\ secondary_text=_('The command is invalid.')) alert.run() alert.destroy() close_popup = False else: current_page = self.notebook.get_nth_page(\ self.notebook.get_current_page()) if current_page is None: current_page = self.notebook.add_scan_page(target) current_page.execute_command(cmd) current_page.toolbar.target_entry.selected_target = self.\ directions['Choose'].target_entry.get_text() current_page.command_toolbar.command_entry.command = cmd current_page.command_toolbar.set_command(cmd) if self.profilemanager: self.update_profilemanager() if close_popup: self.close_wizard()
def _remove_option(self, widget): if self.box_editable._old_selected ==None : d = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_('Select a Option '), secondary_text=_('You do not select any option')) d.run() d.destroy() else: self.box_editable.delete_on_item(self.box_editable._old_selected)
def _send_report(self): if self.summary == "" or self.description == "" or self.email == "": cancel_dialog = HIGAlertDialog( type=gtk.MESSAGE_ERROR, message_format=_("Bug report is incomplete!"), secondary_text=_( "The bug report is incomplete. " "You must inform a description that explains clearly " "what is happening and a valid e-mail, so you can be " "contacted when the bug gets fixed.")) run_dialog(self._reuse_mainloop, cancel_dialog) return self.restore_state() bug_register = BugRegister() bug_register.component = self.category bug_register.summary = self.summary if self.description_report is not None: bug_register.details = self.description_report else: bug_register.details = self.description.replace("\n", "[[BR]]") bug_register.reporter = self.email bug_page = None try: bug_page = bug_register.report() assert bug_page except: import traceback traceback.print_exc() cancel_dialog = HIGAlertDialog( type=gtk.MESSAGE_ERROR, message_format=_("Bug not reported!"), secondary_text=_( "The bug description could not be " "reported. This problem may be caused by the lack " "of Internet access or indisponibility of the bug " "tracker server. Please, verify your internet access, " "and then try to report the bug once again.")) run_dialog(self._reuse_mainloop, cancel_dialog) return self.restore_state() else: ok_dialog = HIGAlertDialog( type=gtk.MESSAGE_INFO, message_format=_("Bug sucessfully reported!"), secondary_text=_( "The bug description was sucessfully " "reported. Thanks for your report! Open Monitor Desktop" "Monitor will be restarted now.")) run_dialog(self._reuse_mainloop, ok_dialog) #run_dialog(self._reuse_mainloop, ok_dialog, #show_report, # callback #self._reuse_mainloop, bug_page) # args # report sent successfully self.response(gtk.RESPONSE_DELETE_EVENT)
def start(self, reader): dialog = HIGAlertDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, message_format="Hello", secondary_text="I'm the dummy plugin" ) dialog.run() dialog.destroy()
def _alert(header, text): """ Show alert dialog with specified header and text """ alert = HIGAlertDialog( message_format='<b>%s</b>' % header, secondary_text=text ) alert.run() alert.destroy()
def _error_invalid_network(self, network): """ Show error dialog for invalid network(s). """ dlg = HIGAlertDialog(self, message_format=_('Invalid network(s).'), secondary_text=( _("There is some invalid character in network") + (" %r" % network) + _("please verify."))) dlg.run() dlg.destroy()
def show_error(self): """ """ alert = HIGAlertDialog( parent=self, type=gtk.MESSAGE_ERROR, message_format=_("Can't create file"), secondary_text=_("Please check if you have permission to " "write this file."), ) alert.run() alert.destroy()
def send_website_suggestion(self): website_url = self.website_url_entry.get_text() if website_url == '': alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields " "for website suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_website_suggestion(website_url) d.addCallback(self.show_success) d.addErrback(self.show_failed)
def verify_config_access(): """ Verify config access, detecting if is possible to write and read files """ if (not check_access(Path.config_file, os.R_OK and os.W_OK)): error_text = _( '''You do not have access to config files!\nPlease run Umit as root or change permissions %s ''' % Path.config_dir) d = HIGAlertDialog(message_format=_('Permission Denied'), secondary_text=error_text) d.run() sys.exit(0)
def show_success(self, result): """ """ if result is not None: alert = HIGAlertDialog(message_format=_("Succuss."), secondary_text=_("Send to aggregaetor successfully.")) alert.run() alert.destroy() else: alert = HIGAlertDialog(message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy()
def __init__(self, parent=None): title = _("Inventory without scheduling profile.") message = _( "This Inventory was created when a scan realized in UMIT " "was requested to be added to the Network Inventory Viewer, " "so there is no scheduling profile for it.\n\n" "This Inventory is not editable.\n\n" "(If the mentioned reason above is incorrect, either you have " "a database from somewhere else or report as bug)" ) HIGAlertDialog.__init__(self, parent, message_format=title, secondary_text=message)
def start(self, reader): self.reader = reader self.tray = Core().get_need(self.reader, 'tray') if not self.tray: d = HIGAlertDialog( Core().mainwindow, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, message_format='Error - Notifier', secondary_text='Unable to get the instance of tray module. The plugin cannot operate correctly.') d.run() d.destroy() else: self.__connect_signals()
def verify_config_access(): """ Verify config access, detecting if is possible to write and read files """ if not check_access(Path.config_file, os.R_OK and os.W_OK): error_text = _( """You do not have access to config files!\nPlease run Umit as root or change permissions %s """ % Path.config_dir ) d = HIGAlertDialog(message_format=_("Permission Denied"), secondary_text=error_text) d.run() sys.exit(0)
def __init__(self, parent=None): title = _("Inventory without scheduling profile.") message = _( "This Inventory was created when a scan realized in UMIT " "was requested to be added to the Network Inventory Viewer, " "so there is no scheduling profile for it.\n\n" "This Inventory is not editable.\n\n" "(If the mentioned reason above is incorrect, either you have " "a database from somewhere else or report as bug)") HIGAlertDialog.__init__(self, parent, message_format=title, secondary_text=message)
def profile_forward(self, widget): profile_name = self.directions['Profile'].profile_entry.get_text() if not profile_name: alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.' )) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.' )) else: alert = None if alert: alert.run() alert.destroy() self.directions['Profile'].profile_entry.grab_focus() return None self.main_vbox.remove(self.directions['Profile']) self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Profile'].hide() self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Profile']
def send_service_suggestion(self): service_name = self.service_name_entry.child.get_text() host_name = self.service_host_entry.get_text() ip = self.service_ip_entry.get_text() port = int(self.service_port_entry.get_text()) if service_name == '' or host_name == '' or ip == '' or port == "": alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields "\ "for service suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_service_suggestion(service_name, host_name, ip,port) d.addCallback(self.show_success) d.addErrback(self.show_failed)
def _save_profile(self, event): """ Save scheduling profile. """ pname = self.schedp_name.get_active_text() if not len(pname): dlg = HIGAlertDialog( self, message_format=_( "Scheduling Profile - Error \ while saving" ), secondary_text=_( "You need to specify a name \ for Profile." ), ) dlg.run() dlg.destroy() return parser = CronParser() minute = self.cron_minute.get_text() hour = self.cron_hour.get_text() day = self.cron_day.get_text() month = self.cron_month.get_text() weekday = self.cron_weekday.get_text() try: parser.parse_minute(minute) parser.parse_hour(hour) parser.parse_day(day) parser.parse_month(month) parser.parse_weekday(weekday) except Exception, e: dlg = HIGAlertDialog( self, message_format=_( "Scheduling Profile - Error \ while saving" ), secondary_text=_( "Check your cron syntax and \ try to save again." ), ) dlg.run() dlg.destroy() return
def show_help(parent,url): import webbrowser url_final = get_filename(url) doc_path = abspath(join(Path.docs_dir, url_final)) log.warning(">>> Openning documentation: %s" % doc_path) if exists(doc_path) and os.access(doc_path, os.R_OK): webbrowser.open("file://%s" % doc_path, new=open_url_as()) else: d = HIGAlertDialog(parent=parent, message_format=_("Couldn't find \ documentation files!"), secondary_text=_("""Umit couldn't find the \ documentation files. Please, go to Umit's website and have the latest \ documentation in our Support & Development section.""")) d.run() d.destroy()
def open_browser(self, widget): text1=self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\ self.scan_buffer1.get_end_iter()) text2=self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\ self.scan_buffer2.get_end_iter()) if not text1 or not text2: alert = HIGAlertDialog( message_format='<b>'+_('Select Scan')+'</b>', secondary_text=_("You must select two different scans to \ generate diff.")) alert.run() alert.destroy() return False text1 = text1.split('\n') text2 = text2.split('\n') self.temp_view = mktemp('.html') text1 = [text+'\n' for text in text1] text2 = [text+'\n' for text in text2] if use_html: diff = DiffHtml(text1, text2) diff = diff.generate() file_desc = open(self.temp_view, 'w') file_desc.write(''.join(diff)) # Closing file to avoid problems with file descriptors file_desc.close() else: diff = Diff(text1, text2) diff = diff.generate () diff.insert(0, '''<pre>(This diff is been shown in pure text \ because you dont have Python 2.4 or higher.)\n''') diff.append('</pre>') file_desc = open(self.temp_view, 'w') file_desc.writelines(diff) # Closing file to avoid problems with file descriptors file_desc.close() webbrowser.open("file://" + self.temp_view, autoraise=1)
def update_option(self, widget): """ Update option @param widget: widget from connect @type widget: HIGButton """ name = self.name_entry.get_text() if name == '': d = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_('Invalid name option '), secondary_text='Fill fields of option') d.run() d.destroy() else: if self.optionlist.options.exists(name): opt = self.get_option() self.optionlist.options.remove_option(name) self.optionlist.add(opt)
def add_option(self, widget): """ Add option @param widget: widget from connect @type widget: HIGButton """ if self.name_entry.get_text()=="": d = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_('No fields entered'), secondary_text=_('Blank options is not allowed!')) d.run() d.destroy() else: opt = self.get_option() self.optionlist.add(opt) self.add_button.set_sensitive(False) self.emit('need-save', None, None)
def load_db(self): global btmanumac global btmanuname count = 0 if(os.path.exists(os.path.join(path.paths, "UmitBT", "config", "db", "btdb.db"))): print "load database" btdb_dir = os.path.abspath(os.path.join(path.paths, "UmitBT", "config", "db", "btdb.db")) btdb = open(btdb_dir, "rb") for line in btdb: count+=1 btbuf1, btbuf2 = line.split(";") btmanumac.append(btbuf1) btmanuname.append(btbuf2) btdb.close() else: print "ERROR: Can't open btdb!" dlg = HIGAlertDialog(None, message_format=('I/O Error'), secondary_text=("Cant open btdb.db")) dlg.run() dlg.destroy()
def open_selected(self, widget=None, path=None, view_column=None, extra=None): # This avoids dialog to be closed for no results. if len(self.results) <= 0: dia = HIGAlertDialog( parent=self, message_format=_('No results'), secondary_text=_('No such results to be opened.') ) dia.run() dia.destroy() return # Open selected results! self.load_method(self.results) # Close Search Window self.close()
def get_networks(self, event): """ Try to detect network(s). """ networks = tryto_detect_networks() if not networks: dlg = HIGAlertDialog( self, message_format=_("No network(s) detected."), secondary_text=_( "You will need to especify the " "network(s) yourself before detecting hosts.")) dlg.run() dlg.destroy() return entries = len(self.networks_box.get_children()) - 1 for amount, nw in enumerate(networks): if amount == entries: e = gtk.Entry() e.set_text('') e.show() self.networks_box.add(e) entries += 1 entry = self.networks_box.get_children()[amount] entry.set_text(nw.cidr_netaddress())
def profile_forward(self, widget): profile_name = self.directions['Profile'].profile_entry.get_text() if not profile_name: alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.')) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.')) else: alert = None if alert: alert.run() alert.destroy() self.directions['Profile'].profile_entry.grab_focus() return None self.main_vbox.remove(self.directions['Profile']) self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Profile'].hide() self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Profile']
def choose_forward(self, widget): if self.directions['Choose'].command_radio.get_active(): if self.directions['Choose'].target_entry.get_text() == '': alert = HIGAlertDialog(message_format=_('No target selected!'),\ secondary_text=_('You must provide a target \ to be scanned.' )) alert.run() alert.destroy() self.directions['Choose'].target_entry.grab_focus() return None self.main_vbox.remove(self.directions['Choose']) self.directions['Choose'].hide() if self.directions['Choose'].profile_radio.get_active(): self.main_vbox._pack_expand_fill(self.directions['Profile']) self.directions['Profile'].show_all() self.directions['LastPage'] = self.directions['Profile'] self.directions['Profile'].prof = True self.target = '<target>' else: self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Choose'] self.directions['Profile'].prof = False self.target = self.directions['Choose'].target_entry.get_text() self.directions['Choose'].add_new_target(self.target) self.update_command()
def show_failed(self, result): """ """ alert = HIGAlertDialog(message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy()
def show_report(reuse_mainloop, bug_page): if not bug_page: return try: webbrowser.open(bug_page) except: # XXX What exceptions should be caught here ? page_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Could not open default Web Browser"), secondary_text=_("Umit was unable to open your default " "web browser to show the bug tracker page with the " "report status. Try visiting Umit's bug tracker " "page to see if your bug was reported.")) run_dialog(reuse_mainloop, page_dialog)
def save_profile(self, widget): profile_name = self.profile_name_entry.get_text() if profile_name == '': alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.' )) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.' )) else: alert = None if alert: alert.run() alert.destroy() self.notebook.set_current_page(0) self.profile_name_entry.grab_focus() return None if not self.deleted: self.remove_profile() command = self.constructor.get_command('%s') hint = self.profile_hint_entry.get_text() buf = self.profile_description_text.get_buffer() description = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) buf = self.profile_annotation_text.get_buffer() annotation = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ tool='nmap',\ options=self.constructor.get_options()) self.deleted = False if self.profilemanager: self.update_profilemanager() self.quit()
def start(self, reader): dialog = HIGAlertDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, message_format="Hello", secondary_text="I'm the dummy plugin") dialog.run() dialog.destroy()
def _alert(header, text): """ Show alert dialog with specified header and text """ alert = HIGAlertDialog(message_format='<b>%s</b>' % header, secondary_text=text) alert.run() alert.destroy()
def set_info(self, ScanNotebookPageBT, btid): global btname global btmac global btmanu global btsdp global sdpstatus sdpbrowseinfo = "" btid += 1 print "Selected: " + str( ScanNotebookPageBT.btmap.get_selected_items()) + "\n" + str(btid) ScanNotebookPageBT.label.set_text("Device Details\t\t\t\t\n\nName: " + btname[btid] + "\nMAC: " + btmac[btid] + "\nManufacturer: " + btmanu[btid]) print "Status_select: " + sdpstatus print "Found " + str(len(btsdp[btid])) + " Services" if (sdpstatus == "Enabled"): if (len(btsdp[btid]) < 1): ScanNotebookPageBT.sdpview.get_buffer().set_text( "no services found") return sdpbrowseinfo = "\nFound " + str(len(btsdp[btid])) + " Services" for svc in btsdp[btid]: try: if (str(svc["name"]) == "no services found" or str(svc["name"]) == ""): ScanNotebookPageBT.sdpview.get_buffer().set_text( "no services found") else: try: sdpbrowseinfo += "\n\nService Name: " + str( svc["name"]) + "\n Description: " + str( svc["description"]) sdpbrowseinfo += "\n Provided By: " + str( svc["provider"]) + "\n Protocol: " + str( svc["protocol"]) sdpbrowseinfo += "\n channel/PSM: " + str( svc["port"]) + "\n svc classes: " + str( svc["service-classes"]) sdpbrowseinfo += "\n profiles: " + str( svc["profiles"]) + "\n service id: " + str( svc["service-id"]) ScanNotebookPageBT.sdpview.get_buffer().set_text( sdpbrowseinfo) except: ScanNotebookPageBT.sdpview.get_buffer().set_text( "N/A") dlg = HIGAlertDialog( None, message_format=('Error'), secondary_text=( "An error occurred while parsing SDP data" )) dlg.run() dlg.destroy() except: ScanNotebookPageBT.sdpview.get_buffer().set_text( "no services found")
def start(self, reader): self.reader = reader self.sysinfo = Core().get_need(self.reader, 'SystemInfo') if not self.sysinfo: msg = "Cannot use SystemInfo" else: msg = "Info for %s\n\nRoutes:\n%s\nIfaces:\n%s\n" % ( self.sysinfo.get_name(), self.sysinfo.get_routes(), self.sysinfo.get_ifaces() ) dialog = HIGAlertDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, message_format="SystemInfo-Consumer", secondary_text=msg ) dialog.run() dialog.destroy()
def get_addresses(self, event): """ Get hosts for network(s). """ networks = [] for entry in self.networks_box.get_children()[:-1]: text_entry = entry.get_text() wrong = alpha.search(text_entry) if wrong: self._error_invalid_network(text_entry) return elif text_entry: networks.append(text_entry) if not networks: dlg = HIGAlertDialog(self, message_format=_("No network."), secondary_text=_("You need to specify at least " "one network to search for hosts.")) dlg.run() dlg.destroy() return self.scans = { } self.scount = 0 for n in networks: discovery = NmapCommand("%s -sP %s" % ('nmap', n)) discovery.run_scan() self.scans[self.scount] = (discovery, n) self.scount += 1 self.target_model.clear() self.hostdetect_btn.set_sensitive(False) self._adjust_target_label() gobject.timeout_add(500, self._check_scans)
def _remove_option(self, widget): if self.box_editable._old_selected == None: d = HIGAlertDialog( type=gtk.MESSAGE_ERROR, message_format=_('Select a Option '), secondary_text=_('You do not select any option')) d.run() d.destroy() else: self.box_editable.delete_on_item(self.box_editable._old_selected)
def show_error(self): """ """ alert = HIGAlertDialog(parent=self, type=gtk.MESSAGE_ERROR, message_format=_("Can't create file"), secondary_text=_( "Please check if you have permission to " "write this file.")) alert.run() alert.destroy()
def _error_invalid_network(self, network): """ Show error dialog for invalid network(s). """ dlg = HIGAlertDialog( self, message_format=_('Invalid network(s).'), secondary_text=(_("There is some invalid character in network") + (" %r" % network) + _("please verify."))) dlg.run() dlg.destroy()
def send_service_suggestion(self): service_name = self.service_name_entry.child.get_text() host_name = self.service_host_entry.get_text() ip = self.service_ip_entry.get_text() port = int(self.service_port_entry.get_text()) if service_name == '' or host_name == '' or ip == '' or port == "": alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields "\ "for service suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_service_suggestion(service_name, host_name, ip, port) d.addCallback(self.show_success) d.addErrback(self.show_failed)
def start(self, reader): self.reader = reader self.tray = Core().get_need(self.reader, 'tray') if not self.tray: d = HIGAlertDialog( Core().mainwindow, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, message_format='Error - Notifier', secondary_text= 'Unable to get the instance of tray module. The plugin cannot operate correctly.' ) d.run() d.destroy() else: self.__connect_signals()
def show_help(parent, url): import webbrowser url_final = get_filename(url) doc_path = abspath(join(Path.docs_dir, url_final)) log.warning(">>> Openning documentation: %s" % doc_path) if exists(doc_path) and os.access(doc_path, os.R_OK): webbrowser.open("file://%s" % doc_path, new=open_url_as()) else: d = HIGAlertDialog(parent=parent, message_format=_("Couldn't find \ documentation files!"), secondary_text=_("""Umit couldn't find the \ documentation files. Please, go to Umit's website and have the latest \ documentation in our Support & Development section.""")) d.run() d.destroy()
def open_browser(self, widget): text1=self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\ self.scan_buffer1.get_end_iter()) text2=self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\ self.scan_buffer2.get_end_iter()) if not text1 or not text2: alert = HIGAlertDialog( message_format='<b>' + _('Select Scan') + '</b>', secondary_text=_("You must select two different scans to \ generate diff.")) alert.run() alert.destroy() return False text1 = text1.split('\n') text2 = text2.split('\n') self.temp_view = mktemp('.html') text1 = [text + '\n' for text in text1] text2 = [text + '\n' for text in text2] if use_html: diff = DiffHtml(text1, text2) diff = diff.generate() file_desc = open(self.temp_view, 'w') file_desc.write(''.join(diff)) # Closing file to avoid problems with file descriptors file_desc.close() else: diff = Diff(text1, text2) diff = diff.generate() diff.insert( 0, '''<pre>(This diff is been shown in pure text \ because you dont have Python 2.4 or higher.)\n''') diff.append('</pre>') file_desc = open(self.temp_view, 'w') file_desc.writelines(diff) # Closing file to avoid problems with file descriptors file_desc.close() webbrowser.open("file://" + self.temp_view, autoraise=1)
def start_search(self, widget): if not self.search_db and \ not self.directory: self.search_notebook.set_current_page(-1) d = HIGAlertDialog(message_format=_("No search method selected!"), secondary_text=_("Umit can search results on \ directories or inside it's own database. Please, select a method by choosing \ a directory or by checking the search data base option at the 'Search options' \ tab before start the search")) d.run() d.destroy() return search_dict = dict(keyword=self.keyword, profile=self.profile, option=self.option, target=self.target, mac=self.mac, ipv4=self.ipv4, ipv6=self.ipv6, port=self.port, port_open=self.port_open, port_filtered=self.port_filtered, port_closed=self.port_closed, service=self.service, osclass=self.osclass, osmatch=self.osmatch, product=self.product) self.clear_result_list() if self.search_db: search_db = SearchDB() for result in search_db.search(**search_dict): self.append_result(result) if self.directory: search_dir = SearchDir(self.directory, self.file_extension) for result in search_dir.search(**search_dict): self.append_result(result) search_tabs = SearchTabs(self.notebook) for result in search_tabs.search(**search_dict): self.append_result(result)
def add_option(self, widget): """ Add option @param widget: widget from connect @type widget: HIGButton """ if self.name_entry.get_text() == "": d = HIGAlertDialog( type=gtk.MESSAGE_ERROR, message_format=_('No fields entered'), secondary_text=_('Blank options is not allowed!')) d.run() d.destroy() else: opt = self.get_option() self.optionlist.add(opt) self.add_button.set_sensitive(False) self.emit('need-save', None, None)
def start(self, reader): self.reader = reader self.sysinfo = Core().get_need(self.reader, 'SystemInfo') if not self.sysinfo: msg = "Cannot use SystemInfo" else: msg = "Info for %s\n\nRoutes:\n%s\nIfaces:\n%s\n" % ( self.sysinfo.get_name(), self.sysinfo.get_routes(), self.sysinfo.get_ifaces()) dialog = HIGAlertDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, message_format="SystemInfo-Consumer", secondary_text=msg) dialog.run() dialog.destroy()
def open_selected(self, widget=None, path=None, view_column=None, extra=None): # This avoids dialog to be closed for no results. if len(self.results) <= 0: dia = HIGAlertDialog( parent=self, message_format=_('No results'), secondary_text=_('No such results to be opened.')) dia.run() dia.destroy() return # Open selected results! self.load_method(self.results) # Close Search Window self.close()
def get_addresses(self, event): """ Get hosts for network(s). """ networks = [] for entry in self.networks_box.get_children()[:-1]: text_entry = entry.get_text() wrong = alpha.search(text_entry) if wrong: self._error_invalid_network(text_entry) return elif text_entry: networks.append(text_entry) if not networks: dlg = HIGAlertDialog(self, message_format=_("No network."), secondary_text=_( "You need to specify at least " "one network to search for hosts.")) dlg.run() dlg.destroy() return self.scans = {} self.scount = 0 for n in networks: discovery = NmapCommand("%s -sP %s" % ('nmap', n)) discovery.run_scan() self.scans[self.scount] = (discovery, n) self.scount += 1 self.target_model.clear() self.hostdetect_btn.set_sensitive(False) self._adjust_target_label() gobject.timeout_add(500, self._check_scans)
def __on_row_action(self, widget, row): "Enable/Disable menu/button callback" if not row.enabled: func = self.p_window.engine.load_plugin else: func = self.p_window.engine.unload_plugin ret, errmsg = func(row.reader) if not ret: dialog = HIGAlertDialog( self.p_window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, message_format=errmsg, secondary_text=errmsg.summary ) dialog.run() dialog.destroy() else: row.enabled = not row.enabled
def start(self, reader): testcase = TestAutoGen() passed, msg = testcase.run(reader) if passed: type = gtk.MESSAGE_INFO else: type = gtk.MESSAGE_ERROR if passed: title = "Test passed" else: title = "Test not passed" dialog = HIGAlertDialog( Core().mainwindow, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, type, message_format=title, secondary_text=msg ) dialog.run() dialog.destroy()