Example #1
0
 def run(self):
 # self.total_ip_count = 15
     while self.enable:
         for j in range(self.total_ip_count):
             ip = rpclib.int2ip(rpclib.ip2int(self.net) + (j + 1))
             if self.count_threads < self.num_threads:
                 #print(self.count_threads)
                 ThreadScanIp(ip, self.scan_ip_timeout, self, self.form).start()
             else:
                 time.sleep(self.scan_ip_timeout)
                 #print("threads count:", self.count_threads)
         time.sleep(self.interval)
Example #2
0
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)
        uic.loadUi("./MainWindow/form.ui", self)
        self.setWindowTitle("NFS-List")
        self.setLayout(self.gridLayout)
        self.setGeometry(100, 100, 640, 480)
        self.listWidget.setViewMode(QtGui.QListView.IconMode)
        self.listWidget.setMovement(QtGui.QListWidget.Static)
        self.ipv6_enable = True  # False
        self.addr_ipv4 = None
        self.addr_ipv6 = None
        self.addr_ipv4_array = []
        self.addr_ipv6_array = []
        self.time = 1

        self.hosts = []
        self.icon = QtGui.QIcon("./MainWindow/NAS-icon.png")
        self.setWindowIcon(self.icon)

        #Tray
        tray_menu = QtGui.QMenu(self)

        show_hide_action = QAction("Show/Hide", self)
        quitAction = QAction("Quit", self)

        tray_menu.addAction(show_hide_action)
        tray_menu.addAction(quitAction)

        tray = QSystemTrayIcon(self)
        tray.setIcon(self.icon)
        tray.setContextMenu(tray_menu)
        tray.setToolTip(self.windowTitle())
        tray.show()
        #
        show_hide_action.triggered.connect(self.showHideWindow)
        quitAction.triggered.connect(QtGui.qApp.quit)

        #end tray

        # self.ico.addPixmap(self.pixmap)
        ifaces = QtNetwork.QNetworkInterface.allInterfaces()
        for iface in ifaces:
            for addr_iface in iface.addressEntries():
                if addr_iface.ip() != QtNetwork.QHostAddress(QtNetwork.QHostAddress.LocalHost) and \
                                addr_iface.ip() != QtNetwork.QHostAddress(QtNetwork.QHostAddress.LocalHostIPv6):
                    if addr_iface.ip().toIPv4Address():
                        self.addr_ipv4_array.append(addr_iface)
                    if self.ipv6_enable:
                        if addr_iface.ip().toIPv6Address():
                            self.addr_ipv6_array.append(addr_iface)

        if len(self.addr_ipv4_array) >= 1:
            self.addr_ipv4 = self.addr_ipv4_array[0].ip().toString()

        #ip data#

        addr_mask = self.addr_ipv4_array[0].netmask().toString()
        #addr_mask = '255.255.255.192'

        __list_aprefix = addr_mask.split('.')
        cidr_ipv4 = 0
        bn = '0b'
        baddr = '0b'
        for i in __list_aprefix:
            cidr_ipv4 += rpclib.bit_count(int(i))
            bn += bin(int(i))[2:]

        print("cidr:", cidr_ipv4)
        print(bn)
        #
        total_ip_count = (2 ** (32 - cidr_ipv4)) - 2
        print('total_ip_count:', total_ip_count)
        print(self.addr_ipv4)
        int_net_ipv4 = rpclib.ip2int(self.addr_ipv4) & rpclib.ip2int(addr_mask)
        net_ipv4 = rpclib.int2ip(int_net_ipv4)


        #abc = ClockThread(self.time, self.add_new_item)
        #abc.start()
        #self.add_new_item('t34', 't32')

        self.scan_network = ThreadScanNetwork(10, net_ipv4, cidr_ipv4, self, 1.2)
        self.scan_network.start()

        self.check_host = ThreadCheckHost(self.hosts, self)
        self.check_host.start()

        #self.add_host({"host":"100.64.0.1","structures":[{'groups': [b'*'], 'dir': b'/srv/NFS'}]})
        """
        self.listWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

        self.actionInfo = QAction("Info", self.listWidget)
        self.actionMount = QAction("Mount", self.listWidget)
        self.listWidget.addAction(self.actionMount)
        self.listWidget.addAction(self.actionInfo)

        self.actionInfo.triggered.connect(self.showInfo)
        self.actionMount.triggered.connect(self.my_method)
        """
        self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.listWidget.customContextMenuRequested.connect(self.showRightMenu)