Пример #1
0
 def _update_label(self, widget):
     #XXX Replace by Command
     log.debug("Update Label")
     selected = self._selected
     cmd = CommandChangeLabel(selected, self._entry_name.get_text(), 
                              self._profilecore,self._boxeditable, True)
     command_manager.add_command(cmd)
Пример #2
0
    def _add(self):


        #self._widget.do_draw()
        label = self._widget.get_children()[0]
        label = gtk.Label()

        label.show()

        self._widget.set_size_request(-1, 23)
        self._widget.show()
        self._widget.set_view(True)

        if self._widget.is_voidplace():
            self._widget.show_voidplace()

        self._widget.set_view(True)
        #self._table.attach(self._widget, 0,2,self._x,self._y)

        #self._widget.do_voidplace()

        self._table.set_row_spacing(self._x,self._spacing)
        #from umit.interfaceeditor.BugDiff import BugDiff
        #BugDiff.pdic(self._coords)
        log.debug('CommandVoidplace: add voidplace')
Пример #3
0
    def start(self, reader):
        self.reader = reader

        self.icon = None
        self.wnd_pos = (0, 0)

        self.menu = gtk.Menu()
        self.menu.show()

        action = gtk.Action(None, '_Quit', 'Quit from UMIT', gtk.STOCK_QUIT)
        action.connect('activate', self.__on_quit)

        item = action.create_menu_item()
        item.show()

        self.menu.append(item)

        self.type = self.notifier = None

        # Force to use win32 module
        if WIN32_PRESENT:
            self.set_type(TrayPlugin.TYPE_WINDOWS)
        else:
            self.set_type(tray_prefs.parser['notifications']['type'].value)
            tray_prefs.parser['notifications']['type'].value = self.type

            logo = os.path.join(Path.icons_dir, 'umit_16.ico')
            log.debug('Creating status icon with %s as logo' % logo)

            self.icon = gtk.status_icon_new_from_file(logo)
            tray_prefs.change_cb = self.set_type

        self.icon.connect('popup-menu', self.__on_right_click)
        self.icon.connect('activate', self.__on_activate)
Пример #4
0
    def _add_page(self):
        log.debug('<<< Add new page')
        if self.label == None :
            label = self._notebook.create_label(self._name)
        else : 
            label = self.label

        if self._number == -1:
            self._notebook.sections_widgets_list.append(label)
            self._notebook.sections_widgets[label] = self._notebook.get_n_pages()
        else:
            num = self._number
            self._notebook.sections_widgets_list.insert(num,label)
            self._notebook.sections_widgets[label] = self._number-1
            for i in range(num-1, len(self._notebook.sections_widgets)-1):
                widget_tmp = self._notebook.sections_widgets_list[i+1]
                self._notebook.sections_widgets[widget_tmp] = self._notebook.sections_widgets[widget_tmp] + 1 

        self._notebook.insert_page(self._page, label, self._number)
        #self._notebook.append_page(self._page, label)
        self._page.show_all()
        label.voidplace()
        label.show_all()

        #profilecore
        #print self._name
        elem = self._profilecore.search_in_groups(self._name)
        if elem == None:

            self._profilecore.add_section(self._name)
            label.set_name(self._name)
Пример #5
0
    def _remove_option(self):

        widget = self._widget
        childs = widget.get_children()
        self._saved = [] 
        for i in childs:
            widget.remove(i)
            self._saved.append(i)
        t = gtk.Label('-')
        t.set_size_request(-1, 23)
        t.show()

        widget.pack_start(t)
        widget.do_voidplace()


        #Profile Core modifications: 
        po = self._widget.get_profileoption()

        widget_prev = self._page.get_prev_widget(self._widget)
        #widget_next = self._page.get_next_widget(self._widget)
        #print widget_prev
        #print widget_next
        #po.set_next_opt(None)

        #XXX <--- this protection should be wrong, too defencive 
        if widget_prev!=None:

            widget_prev.get_profileoption().set_next_opt(po.get_next_opt())

        self._profilecore.remove_opt(po.get_section(), po.get_label())


        log.debug('Removing option, Adding Void Place')
Пример #6
0
    def _add_option(self):
        widget_option = self._widget_option
        widget = self._widget
        childs = widget.get_children()
        widget.remove(childs[0])
        if widget.is_voidplace():
            widget.unload_voidplace()
        if self._saved==None:
            for k in widget_option:
                widget.pack_start(k)
                k.show_all()
        else: 
            for k in self._saved:
                widget.pack_start(k)
                k.show_all()
        #self._widget.show_all()
        #widget_option.show() # XXX - may be need 

        #Profile Core modifications: 
        po = self._widget.get_profileoption()
        #print po.get_next_opt()
        widget_prev = self._page.get_prev_widget(self._widget)
        #widget_next = self._page.get_next_widget(self._widget)
        #print widget_prev
        #print widget_next
        if widget_prev !=None:
            po.set_next_opt(widget_prev.get_profileoption().get_next_opt())
            widget_prev.get_profileoption().set_next_opt(po.get_label())
        self._profilecore.add_from_profileoption(po)



        log.debug('Adding option')
Пример #7
0
 def _on_remove_press(self, widget):
     log.debug('<<< Remove Option from OptionList')
     selected = self.get_selected()
     (model, iter) = self.get_selected_option()
     if selected!=None:
         self._new_list.remove(selected)
         self._model.remove(iter)
Пример #8
0
    def add_profile(self, profile_name, **attributes):
        log.debug(">>> Add Profile '%s': %s" % (profile_name, attributes))
        try:
            self.add_section(profile_name)
        except DuplicateSectionError:
            return None
        except ValueError:
            return None

        for attr in attributes:
            if attr != "options":
                self._set_it(profile_name, attr, attributes[attr])

        options = attributes["options"]
        if isinstance(options, basestring):
            self._set_it(profile_name, "options", options)
            # Assuming there are no values for these options
            options = {}
        elif isinstance(options, dict):
            self._set_it(profile_name, "options", ",".join(options))

        for opt in options:
            if options[opt]:
                self._set_it(profile_name, opt, options[opt])
        self.save_changes()
Пример #9
0
    def __create_tab(self, tab_name, section_name, tab):
        log.debug(">>> Tab name: %s" % tab_name)
        log.debug(">>>Creating profile editor section: %s" % section_name)

        vbox = HIGVBox()
        table = HIGTable()
        section = HIGSectionLabel(section_name)

        vbox._pack_noexpand_nofill(section)
        vbox._pack_noexpand_nofill(HIGSpacer(table))
        vbox.set_border_width(6)

        tab.fill_table(table, True)
        self.scrollwindow = HIGScrolledWindow()
        self.scrollwindow.set_size_request(600,300)
        vp = gtk.Viewport()
        vp.add(vbox)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.scrollwindow.add(vp)

        vbox_tmp = HIGVBox()
        vbox_tmp.set_border_width(6)
        vbox_tmp.set_spacing(12)
        vbox_tmp.pack_start(self.scrollwindow)


        self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
Пример #10
0
    def get_scan_results(self):
        scan_file = None
        for i in range(self.scan_notebook.get_n_pages()):
            sbook_page = self.scan_notebook.get_nth_page(i)

            if not sbook_page.status.get_empty():
                scan_file = sbook_page.parsed.nmap_xml_file
                if hasattr(scan_file, "name"):
                    # this scan was loaded from a file so nmap_xml_file is
                    # actually a file object, but we are interested only in
                    # the file name.
                    scan_file = scan_file.name

            if scan_file and os.access(scan_file, os.R_OK) and\
               os.path.isfile(scan_file):
                log.debug(">>> Retrieving unsaved scan result: %s" % scan_file)

                try:
                    parsed = NmapParser()
                    parsed.set_xml_file(scan_file)
                    parsed.parse()
                    parsed.scan_name = "Unsaved " + sbook_page.get_tab_label()
                    parsed.unsaved = True
                except:
                    pass
                else:
                    yield parsed
Пример #11
0
    def _move_right(self):
        log.debug("move right")
        current = self._notebook.get_current_page()
        self._notebook.reorder_child(self._page,current+self._number )
        name = self._page.get_name()
        if name != None :
            self._profilecore.move_section_right(name)

        #Ajust sections childs (NotebookLabel)

        dic = self._notebook.sections_widgets
        list = self._notebook.sections_widgets_list

        list_tmp = []
        for i in range(len(list)):
            widget = list.pop()
            list_tmp.append(widget)
            if widget.get_name()==name :
                break 
        w_tmp = list_tmp.pop()
        w_tmp2 = list_tmp.pop()
        num = dic[w_tmp] 
        dic[w_tmp] = dic[w_tmp2]
        dic[w_tmp2] = num
        list.append(w_tmp2)
        list.append(w_tmp)
        for i in range(len(list_tmp)):
            list.append(list_tmp.pop())
Пример #12
0
    def delete_section(self):
        if self._old_select.is_voidplace():

            log.debug('Key press event on NotebookEditable \
                      -- unload voidplace')
            #self._old_select.unload_voidplace()
            #label_tmp =self.get_tab_label(self.get_nth_page(
                #self.get_current_page()))
            #num = self.sections_widgets[label_tmp]
            #del self.sections_widgets[label_tmp]
            #for i in range(num, len(self.sections_widgets)):
                #print i
                #widget_tmp = self.sections_widgets_list[i+1]
                #self.sections_widgets[widget_tmp] = self.sections_widgets[widget_tmp] - 1 

            #self.sections_widgets_list.pop(num)
            #self.remove_page(self.get_current_page())
            num = self.get_current_page()
            cmd = CommandPageNotebook(self,
                                      self.get_nth_page(num),num, 
                                      self._profilecore,
                                      False)
            command_manager.add_command(cmd)

            self._old_select=None
        else: 
            log.debug('Key press event on NotebookEditable -- \
                      CommandAddRemoveLabel')
            cmd = CommandAddRemoveLabel(self._old_select, 
                                        self._old_select.get_text(), self._profilecore,False)
            command_manager.add_command(cmd)
        self.emit('need-save', 'Sections', None)
Пример #13
0
 def match_port(self, port):
     log.debug("Match port:%s" % port)
     if port == [""] or port == ["*"]:
         return True
     
     ports = []
     
     for p in self.parsed_scan.ports:
         for portid in p:
             if self.port_open and portid["state"] == "open":
                 ports.append(portid["portid"])
             elif self.port_filtered and portid["state"] == "filtered":
                 ports.append(portid["portid"])
             elif self.port_closed and portid["state"] == "closed":
                 ports.append(portid["portid"])
             elif not self.port_open and \
                     not self.port_filtered and \
                     not self.port_closed:
                 # In case every port state is False, add every port
                 ports.append(portid["portid"])
                 
     for keyport in port:
         if keyport not in ports:
             return False # No match for asked port
     else:
         return True # Every given port matched current result
Пример #14
0
    def delete_files(self, widget):
        # NOTE: This method should be adapted in umit.core.UserConf
        # Creating an empty recent_scans file
        
        log.debug('>>> Reset store files:  -  %s' % base_paths['user_dir'])

        reset_user_dir(base_paths['user_dir'])
Пример #15
0
    def __init__(self, value, \
                 name=None, def_value=None, desc=None, \
                 attrs=(), parent=None):
        """
        Create a variable

        @param value the value for variable
        @param name the name for variable (optional if are in list)
        @param def_val the default value for variable (optional if is user conf)
        @param desc the description of value (optional if in user conf)
        @param attrs a list of attributes
        @param sectiondict the section dict
        """
        self._value = self.__class__.convert(value)
        self._name = name
        self._def_val = self.__class__.convert(def_value)
        self._desc = desc
        self._parent = parent

        # Compatibility for child objects
        self.add_attribute(attrs, 'id', Integer, '_id')

        self.set_attributes(attrs)
        self.check_validity()

        if not Variable.setted(self._value):
            raise Exception("Value not setted")
        
        if not isinstance(self._value, self.__class__.element_type):
            raise Exception("Unable to set a valid type")
        
        log.debug(">>> Variable named '%s' allocate with value '%s'" % (self._name, self._value))
Пример #16
0
    def _move_down(self):

        widget_swap = self._get_next()
        if not self._voidplace : 
            self._profilecore.move_option_down(self._section_name, 
                                               self._name, 
                                               widget_swap.get_name())
        self._swap( widget_swap, self._move)
        #x, y = self._coords[widget_swap]
        #self._move.set_select(False)
        #widget_swap.set_select(False)

        #w_tmp = gtk.Label('tmp')
        #self._table.attach(w_tmp, 1,2, x, y)
        #self._table.remove(widget_swap)
        #self._table.attach(widget_swap, 0,2, self._x, self._x+1)
        #self._table.remove(self._move)

        #self._table.attach(self._move, 0,2, x, y)
        #self._table.remove(w_tmp)

        #self._coords[widget_swap] = [self._x, self._y]
        #self._coords[self._move] = [x,y]
        self._parent.send_signal()
        self._move.do_draw()
        log.debug('<<< Moving item down')
Пример #17
0
    def sanity_settings(self, settings):
        log.debug(">>> Sanitize %s" % str(settings))

        tuple_regex = "[\(\[]\s?(\d+)\s?,\s?(\d+)\s?,\s?(\d+)\s?[\)\]]"
        if isinstance(settings, basestring):
            settings = [int(t) for t in re.findall(tuple_regex, settings)[0]]

        return settings
Пример #18
0
    def on_key_press(self, widget, event):
        _keyval = gtk.gdk.keyval_name(event.keyval)
        log.debug('Key press event on NotebookEditable')
        if self._old_select==None:
            log.debug('Key press event on NotebookEditable -- Return')
            return

        if _keyval == "Delete" :
            self.delete_section()
Пример #19
0
    def match_profile(self, profile):
        log.debug("Match profile: %s" % profile)
        log.debug("Comparing: %s == %s ??" % \
                  (str(self.parsed_scan.profile_name).lower(),
                   "*%s*" % profile.lower()))
        if profile == "*" or profile == "" or \
           fnmatch(str(self.parsed_scan.profile_name).lower(),
                   "*%s*" % profile.lower()):
            return True # Pattern matches

        return False # Pattern doesn't match
Пример #20
0
    def _remove_label(self):

        self._widget.voidplace()

        #ProfileCore
        if self._new : 
            pass



        log.debug('Removing label, Adding Void Place')
Пример #21
0
def root_dir():
    """Retrieves root dir on current filesystem"""
    curr_dir = os.getcwd()
    while True:
        splited = os.path.dirname(curr_dir)
        if curr_dir == splited:
            break
        curr_dir = splited

    log.debug(">>> Root dir: %s" % curr_dir)
    return curr_dir
Пример #22
0
    def format_date(self, date):
        """
        Format date to be displayed in Date column.
        """
        try:
            date.hour
        except AttributeError, e:
            log.critical(">>> Report this as a BUG!, sqlite didn't return "
                "column with timestamp format, errmsg: %s" % e)
            log.debug(">>> date, type(date):", date, type(date))

            return date
Пример #23
0
    def __init__(self, search_directory, file_extensions=["usr"]):
        SearchResult.__init__(self)
        log.debug(">>> SearchDir initialized")
        self.search_directory = search_directory

        if isinstance(file_extensions, basestring):
            self.file_extensions = file_extensions.split(";")
        elif isinstance(file_extensions, list):
            self.file_extensions = file_extensions
        else:
            raise Exception("Wrong file extension format! '%s'" %
                            file_extensions)
Пример #24
0
    def _move_up(self):

        widget_swap = self._get_prev()
        if not self._voidplace : 
            self._profilecore.move_option_up(self._section_name, 
                                             self._name,
                                             widget_swap.get_name())
        self._swap(self._move, widget_swap)
        #widget_swap.do_resize_voidplace()
        self._parent.send_signal()
        self._move.do_draw()
        log.debug('<<< Moving item up')
Пример #25
0
    def set_option_display(self, optiondisplay):
        """
        Set a option display to change fields when cursor change
        @param optiondisplay: it's a mainframe that contains fields to set 
        @type optiondisplay: OptionDisplay
        """

        self.optiondisplay = optiondisplay
        self.exists_display = (self.optiondisplay != None ) #True or False
        if self.exists_display:
            log.debug('<<< Cursor changed')
            self.__treeview.connect("cursor-changed",self.update_option_display)
Пример #26
0
    def match_osmatch(self, osmatch):
        # XXX only the last osmatch is being used
        log.debug("Match osmatch: %s" % osmatch)
        if osmatch == "" or osmatch == "*":
            return True

        for host in self.parsed_scan.hosts:
            if not host.osmatch:
                continue
            match = host.osmatch[-1].get("name", False)
            if match and fnmatch(match.lower(), "*%s*" % osmatch.lower()):
                return True
        return False
Пример #27
0
 def on_button_press(self, widget, event):
     log.debug('Button press on Notebook')
     if self._old_select != None:
         self._old_select.set_select(False)
     widget.set_select(True)
     self._old_select = widget
     widget.do_draw()
     self.set_current_page(self.sections_widgets[widget])
     #XXX - this focus owns drag-n-drop received :( 
     #widget.grab_focus()
     self._page_in = self.get_current_page()
     log.debug('<<< Setting page %s'%self._page_in)
     return True
Пример #28
0
    def match_service(self, service):
        log.debug("Match service: %s" % service)
        if service == "" or service == "*":
            return True
        
        services = []
        for port in self.parsed_scan.ports:
            if 'name' in port and port['name'] not in services:
                services.append(port["service_name"])

        if service in services:
            return True # Given service name matched current result
        return False # Given service name didn't match current result
Пример #29
0
def create_user_dir(config_file, user_home):
    log.debug(">>> Create user dir at given home: %s" % user_home)
    log.debug(">>> Using %s as source" % config_file)

    user_dir = os.path.join(user_home, base_paths['config_dir'])

    if os.path.exists(user_home):
        if os.access(user_home, os.R_OK and os.W_OK):
            if not os.path.exists(user_dir):
                os.mkdir(user_dir)
                for dirname in userdir_dirs:
                    os.mkdir(os.path.join(user_dir, dirname))
                log.debug(">>> Umit user dir (%r) successfully "
                        "created!" % user_dir)
            else:
                log.debug(">>> Umit user dir (%r) already exists" % user_dir)
        else:
            log.warning(">>> No permissions to create user dir!")
            return False

    main_dir = os.path.dirname(config_file)
    for name in userdir_files:
        copy_config_file(name, main_dir, user_dir)

    return dict(user_dir = user_dir,
                config_dir = user_dir,
                config_file = os.path.join(user_dir, 'umit.conf'))
Пример #30
0
    def change_combo(self,combo):
        model = combo.get_model()
        index = combo.get_active()
        if index:
            if model[index][0]=='Option List':

                log.debug('Show Button List ')
                self._button_list.show()

            else:

                log.debug('Hide Button List ')
                self._button_list.hide()
        return
Пример #31
0
    def set_umit_conf(self, base_dir):
        main_config_dir = ""
        main_config_file = ""

        if (os.path.exists(CONFIG_DIR) and os.path.exists(
                os.path.join(CONFIG_DIR, base_paths['config_file']))):
            main_config_dir = CONFIG_DIR

        elif (os.path.exists(os.path.join(base_dir, CONFIG_DIR))
              and os.path.exists(
                  os.path.join(base_dir, CONFIG_DIR,
                               base_paths['config_file']))):
            main_config_dir = os.path.join(base_dir, CONFIG_DIR)

        elif (os.path.exists(
                os.path.join(os.path.dirname(base_dir), CONFIG_DIR))
              and os.path.exists(
                  os.path.join(os.path.dirname(base_dir), CONFIG_DIR,
                               base_paths['config_file']))):
            main_config_dir = (os.path.join(os.path.dirname(base_dir),
                                            CONFIG_DIR))

        else:
            # XXX This is bad, it doesn't create temporary configuration
            # files for everything that umit uses nowadays.
            main_config_dir = create_temp_conf_dir(VERSION)

        # Main config file, based on the main_config_dir got above
        main_config_file = os.path.join(main_config_dir,
                                        base_paths['config_file'])

        # This is the expected place in which umit.conf should be placed
        supposed_file = os.path.join(base_paths['user_dir'],
                                     base_paths['config_file'])
        config_dir = ""
        config_file = ""

        if os.path.exists(supposed_file)\
               and check_access(supposed_file, os.R_OK and os.W_OK):
            config_dir = base_paths['user_dir']
            config_file = supposed_file
            log.debug(">>> Using config files in user home directory: %s" \
                      % config_file)

            # Verify if an old ~/.umit exists, and merge into user
            # localappdata (Windows only).
            backup = nt_appdata.merge()
            if backup is not None:
                log.debug(">>> Merging config files from %r to %r (new "
                          "configdir already exists)" % (backup, config_dir))
                file_merger(backup, config_dir, True, *userdir_files)

        elif not os.path.exists(supposed_file)\
                and not check_access(base_paths['user_dir'],
                        os.R_OK and os.W_OK):

            # Before attemping to create a new user directory, merge the older
            # ~/.umit to user localappdata (Windows only).
            backup = nt_appdata.merge()
            if backup is not None:
                log.debug(">>> Merging config files from %r to %r" %
                          (backup, config_dir))
                file_merger(backup, config_dir, True, *userdir_files)

            try:
                result = create_user_dir(
                    os.path.join(main_config_dir, base_paths['config_file']),
                    HOME)
                if not isinstance(result, dict):
                    raise Exception()
            except:
                log.debug(">>> Failed to create user home")
            else:
                config_dir = result['config_dir']
                config_file = result['config_file']
                log.debug(">>> Using recently created config files in "
                          "user home: %s" % config_file)

        if config_dir and config_file:
            # Either base_paths['user_dir'] existed or it just got created.
            #
            # In both cases it is possible that config merge is necessary,
            # if the path already existed then it is possible that:
            #   1) there are newer config files that need merging;
            #   2) there are newer config dirs that need copying;
            #   3) maybe there was an ~/.umit which got merged into user's
            #      local appdata and now configuration files need be merged
            #      [Windows only].
            # if it just got created then:
            #   See 3) above.
            dir_creator(config_dir, *userdir_dirs)
            file_merger(main_config_dir, config_dir, False, *userdir_files)
        else:
            log.debug(">>> There is no way to create nor use home config.")
            log.debug(">>> Trying to use main configuration files...")

            config_dir = main_config_dir
            config_file = main_config_file

        self._parse_and_set_dirs(config_file, config_dir)
 def close(self):
     log.debug(">>> CLOSE")
     self.email_server.close()
     del(self.email_server)
 def save_changes(self):
     log.debug('call save changes - network settings')
     self.parser.save_changes()
Пример #34
0
 def unload_voidplace(self):
     log.debug('<<< Unload voidplace happen')
     self._voidplace.set_user_data(None)
     self._voidplace.destroy()
     self._voidplace = None
     self._vp = False
Пример #35
0
 def hide_voidplace(self):
     if self.is_voidplace():
         self._icon.hide_voidplace()   
         self._vp = False
         
     log.debug('hide voidplace')
 def save(self):
     self._profilecore.write_file(self.profile_editor_file)
     log.debug('<<< Saving to file %s ' % self.profile_editor_file)
 def save_conf(self):
     # Let's save our configuration to self.conf_file
     log.debug("Saving configuration to %s" % self.conf_file)
     self.parser.save_to_file(self.conf_file)
 def add_port(self, port_info):
     log.debug(">>> Add Port: %s" % str(port_info))
     self.port_list.append([""] + list(port_info))
 def save_changes(self):
     log.debug('call save changes')
     self.parser.save_changes()
 def load_from_directory(self, path):
     log.debug("Loading source files from plugin directory: %s" % path)
     self.tree.load_directory(path)
    def connect(self):
        log.debug(">>> Connecting to smtp server at %s:%s as %s" % (
            self.server, self.port, self.localdomain))

        self.email_server = SMTP(self.server, self.port, self.localdomain)
        log.debug(">>> Connected!")

        log.debug(">>> EHLO %s" % self.from_addr)
        self.email_server.ehlo(self.from_addr)

        if self.tls:
            log.debug(">>> STARTTLS")
            self.email_server.starttls()

            log.debug(">>> EHLO %s" % self.from_addr)
            self.email_server.ehlo(self.from_addr)

        if self.login_passwd:
            log.debug(">>> LOGIN %s@%s" % (self.login, self.login_passwd))
            self.email_server.login(self.login, self.login_passwd)
Пример #42
0
    def __update_rich_list(self):
        """
        This is the timeout callback called to update the gui
        in the find phase
        """

        working = False

        for upd_obj in self.p_window.update_eng.list:
            upd_obj.lock.acquire()

            try:
                # Check if we are working
                if upd_obj.status == LATEST_GETTING:
                    working = True

                # Update the row
                row = upd_obj.object
                row.message = upd_obj.label
            finally:
                upd_obj.lock.release()

        # No locking from here we have finished

        if not working:
            # Mark as finished
            self.p_window.update_eng.stop()
            self.find_updates_btn.set_sensitive(True)

            lst = filter( \
                lambda x: (x.status == LATEST_GETTED) and (x) or (None),\
                self.p_window.update_eng.list \
            )
            elst = filter( \
                lambda x: (x.status == LATEST_ERROR) and (x) or (None),\
                self.p_window.update_eng.list \
            )

            if not lst and not elst:
                self.p_window.toolbar.unset_status()

                self.p_window.animated_bar.label = \
                    _('<b>No updates found</b>')
                self.p_window.animated_bar.start_animation(True)

                self.richlist.clear()
                self.populate()

                self.menu_enabled = True
            else:
                # Now prepare the download page

                if not elst:
                    self.p_window.toolbar.show_message( \
                        _("<b>Updates found: %d</b>") % len(lst), \
                        stock=gtk.STOCK_APPLY \
                    )
                else:
                    self.p_window.toolbar.show_message( \
                        _('<b>Updates found: %d with %d errors</b>')  \
                        % (len(lst), len(elst)), stock=gtk.STOCK_APPLY \
                    )

                for obj in self.p_window.update_eng.list:
                    row = obj.object
                    active = (obj.status == LATEST_GETTED)

                    if active:
                        obj.last_update_idx = 0
                        row.show_include = True

                        log.debug("Connecting 'query-tooltip' for %s" % obj)

                        # The tooltip is showed and hidden continuously
                        row.versions_button.props.has_tooltip = True
                        row.versions_button.connect(
                            'query-tooltip',
                            self.__query_tooltip_versions_button, obj
                        )

                        row.versions_model.clear()

                        row.versions_model.append([
                            gtk.STOCK_CANCEL, _("Skip")
                        ])

                        for update in obj.updates:
                            cur_v = Version(row.reader.version)
                            new_v = Version(update.version)

                            if new_v > cur_v:
                                row.versions_model.append([
                                    gtk.STOCK_GO_UP, _("Update to %s") % \
                                    update.version
                                ])
                            elif new_v == cur_v:
                                row.versions_model.append([
                                    gtk.STOCK_REFRESH, _("Reinstall %s") % \
                                    update.version
                                ])
                            else:
                                row.versions_model.append([
                                    gtk.STOCK_GO_DOWN, _("Downgrade to %s") % \
                                    update.version
                                ])

                        row.versions_button.set_active(0)
                        row.message = obj.label
                    else:
                        row.saturate = True

                if lst:
                    self.install_updates_btn.show()

                self.find_updates_btn.hide()
                self.skip_install_btn.show()

        return working
 def add_host(self, host_info):
     log.debug(">>> Add Host: %s" % str(host_info))
     self.host_list.append([""] + list(host_info))
Пример #44
0
    def _parse_and_set_dirs(self, config_file, config_dir):
        """Parse the given config_file and then set the directories."""
        # Parsing the umit main config file
        self.config_parser.read(config_file)

        # Should make the following only after reading the umit.conf file
        self.config_dir = config_dir
        self.config_file = config_file
        self.config_file_set = True
        self.locale_dir = LOCALE_DIR
        self.pixmaps_dir = PIXMAPS_DIR
        self.icons_dir = ICONS_DIR
        self.misc_dir = MISC_DIR
        self.docs_dir = DOCS_DIR
        self.styles_dir = STYLES_DIR
        self.languages_dir = LANGUAGES_DIR

        log.debug(">>> Config file: %s" % config_file)
        log.debug(">>> Locale: %s" % self.locale_dir)
        log.debug(">>> Pixmaps: %s" % self.pixmaps_dir)
        log.debug(">>> Icons: %s" % self.icons_dir)
        log.debug(">>> Misc: %s" % self.misc_dir)
        log.debug(">>> Docs: %s" % self.docs_dir)
        log.debug(">>> Styles: %s" % self.styles_dir)
        log.debug(">>> Languages: %s" % self.languages_dir)
Пример #45
0
    def read(self, filename):
        log.debug(">>> Trying to parse: %s" % filename)

        self.filenames = ConfigParser.read(self, filename)
        return self.filenames
 def put_on_page(self):
     log.debug('<<< Put on page %s' % self._page_in)
     self.set_current_page(self._page_in)