Exemplo n.º 1
0
    def sort(self, Ncol, order):                                        # sort function called when the user clicks on a header
        
        self.layoutAboutToBeChanged.emit()
        array = []
        
        if Ncol == 0:                                                   # if sorting by service name (and by default)
            for i in range(len(self.__serviceNames)):
                array.append(self.__serviceNames[i]['name'])

        sortArrayWithArray(array, self.__serviceNames)                  # sort the services based on the values in the array

        if order == QtCore.Qt.AscendingOrder:                                  # reverse if needed
            self.__serviceNames.reverse()   
            
        self.layoutChanged.emit()
Exemplo n.º 2
0
    def sort(self, Ncol, order):                                        # sort function called when the user clicks on a header
        
        self.layoutAboutToBeChanged.emit()
        array = []
        
        if Ncol == 0:                                                   # if sorting by ip (and by default)
            for i in range(len(self.__services)):
                array.append(IP2Int(self.__services[i]['ip']))

        elif Ncol == 1:                                                 # if sorting by port
            for i in range(len(self.__services)):
                array.append(int(self.__services[i]['port_id']))

        elif Ncol == 2:                                                 # if sorting by port
            for i in range(len(self.__services)):
                array.append(int(self.__services[i]['port_id']))
                
        elif Ncol == 3:                                                 # if sorting by protocol
            for i in range(len(self.__services)):
                array.append(self.__services[i]['protocol'])
                
        elif Ncol == 4:                                                 # if sorting by state
            for i in range(len(self.__services)):
                array.append(self.__services[i]['state'])
                
        elif Ncol == 7:                                                 # if sorting by name
            for i in range(len(self.__services)):
                array.append(self.__services[i]['name'])
            
        elif Ncol == 9:                                                 # if sorting by version
            for i in range(len(self.__services)):           
                value = ''
                if not self.__services[i]['product'] == None and not self.__services[i]['product'] == '':
                    value = str(self.__services[i]['product'])
                
                if not self.__services[i]['version'] == None and not self.__services[i]['version'] == '':
                    value = value + ' ' + self.__services[i]['version']

                if not self.__services[i]['extrainfo'] == None and not self.__services[i]['extrainfo'] == '':
                    value = value + ' (' + self.__services[i]['extrainfo'] + ')'
                array.append(value)

        sortArrayWithArray(array, self.__services)                      # sort the services based on the values in the array
        
        if order == QtCore.Qt.AscendingOrder:                                  # reverse if needed
            self.__services.reverse()   
            
        self.layoutChanged.emit()
Exemplo n.º 3
0
 def getHostActions(self):
     hostactions = []
     sortArray = []
     self.actions.beginGroup('HostActions')
     keys = self.actions.childKeys()
     for k in keys:
         hostactions.append(
             [self.actions.value(k)[0],
              str(k),
              self.actions.value(k)[1]])
         sortArray.append(self.actions.value(k)[0])
     self.actions.endGroup()
     sortArrayWithArray(
         sortArray, hostactions
     )  # sort by label so that it appears nicely in the context menu
     return hostactions
Exemplo n.º 4
0
    def sort(self, Ncol, order):
        self.layoutAboutToBeChanged.emit()
        array=[]
        
        if Ncol == 1:            
            for i in range(len(self.__scripts)):
                array.append(self.__scripts[i]['script_id'])
        if Ncol == 2:            
            for i in range(len(self.__scripts)):
                array.append(int(self.__scripts[i]['port_id']))

        sortArrayWithArray(array, self.__scripts)                       # sort the services based on the values in the array

        if order == QtCore.Qt.AscendingOrder:                                  # reverse if needed
            self.__scripts.reverse()
            
        self.layoutChanged.emit()
Exemplo n.º 5
0
    def sort(self, Ncol, order):
        self.layoutAboutToBeChanged.emit()
        array = []

        if Ncol == 3:
            for i in range(len(self.__processes)):
                array.append(self.__processes[i]['name'])

        elif Ncol == 4:
            for i in range(len(self.__processes)):
                array.append(self.__processes[i]['tabtitle'])

        elif Ncol == 5:
            for i in range(len(self.__processes)):
                array.append(IP2Int(self.__processes[i]['hostip']))

        elif Ncol == 6:
            for i in range(len(self.__processes)):
                if self.__processes[i]['port'] == '':
                    return
                else:
                    array.append(int(self.__processes[i]['port']))

        elif Ncol == 9:
            for i in range(len(self.__processes)):
                array.append(self.__processes[i]['starttime'])

        elif Ncol == 10:
            for i in range(len(self.__processes)):
                array.append(self.__processes[i]['endtime'])

        else:
            for i in range(len(self.__processes)):
                array.append(self.__processes[i]['status'])

        sortArrayWithArray(
            array, self.__processes
        )  # sort the services based on the values in the array

        if order == QtCore.Qt.AscendingOrder:  # reverse if needed
            self.__processes.reverse()

        self.__controller.updateProcessesIcon(
        )  # to make sure the progress GIF is displayed in the right place

        self.layoutChanged.emit()
Exemplo n.º 6
0
    def sort(self, Ncol,
             order):  # sort function called when the user clicks on a header

        self.layoutAboutToBeChanged.emit()
        array = []

        if Ncol == 0 or Ncol == 3:  # if sorting by IP address (and by default)
            for i in range(len(self.__hosts)):
                array.append(IP2Int(self.__hosts[i]['ip']))

        elif Ncol == 1:  # if sorting by OS
            for i in range(len(self.__hosts)):

                os_string = self.__hosts[i]['os_match']
                if os_string == '':
                    array.append('')

                elif re.search('[lL]inux', os_string, re.I):
                    array.append('Linux')

                elif re.search('[wW]indows', os_string, re.I):
                    array.append('Windows')

                elif re.search('[cC]isco', os_string, re.I):
                    array.append('Cisco')

                elif re.search('HP ', os_string, re.I):
                    array.append('Hp')

                elif re.search('[vV]x[wW]orks', os_string, re.I):
                    array.append('Hp')

                elif re.search('[vV]m[wW]are', os_string, re.I):
                    array.append('Vmware')

                else:
                    array.append('')

        sortArrayWithArray(array, self.__hosts)  # sort the array of OS

        if order == QtCore.Qt.AscendingOrder:  # reverse if needed
            self.__hosts.reverse()

        self.layoutChanged.emit()  # update the UI (built-in signal)