Beispiel #1
0
 def gethost():
     mylock.acquire()
     if not hostmanager.instance().cangethost():
         mylock.release()
         return None
     host = hostmanager.instance().gethost()
     mylock.release()
     return host
Beispiel #2
0
 def gethost():
     mylock.acquire()
     if not hostmanager.instance().cangethost():
         mylock.release()
         return None
     host = hostmanager.instance().gethost()
     mylock.release()
     return host
Beispiel #3
0
 def __init__(self):
     Tkinter.Tk.__init__(self)
     self.title("Get Lan Info")
     self.geometry('300x200')
     self.iconname("haha")
     self.frame = Tkinter.Frame(self, cnf=configManager.instance().getconfig('Frame'), relief=RIDGE, borderwidth=2)
     self.frame.pack(fill=BOTH, expand=1)
     self.var = Tkinter.StringVar()
     self.font = tkFont.Font(family="Times", size=10, weight=tkFont.BOLD)
     self.listbox = Tkinter.Listbox(self.frame, cnf=configManager.instance().getconfig('Listbox'), height=5,
                                    selectmode=BROWSE, listvariable=self.var, font=self.font, bg='#646464',
                                    fg='#c8c8c8')
     self.list_item = tuple(hostmanager.instance().getresult())
     self.var.set(self.list_item)
     self.scrl = Tkinter.Scrollbar(self.frame)
     self.scrl.pack(side=RIGHT, fill=Y)
     self.listbox.configure(yscrollcommand=self.scrl.set)
     self.listbox.pack(side=LEFT, fill=BOTH)
     self.scrl['command'] = self.listbox.yview
     self.button2 = Tkinter.Button(self.frame, text="Exit", command=self.exit)
     self.button2.pack(side=BOTTOM)
     self.done = 0
     self.starttime = time.time()
     #'''
     for key in self.listbox.keys():
         value = self.listbox.cget(key)
         if type(value) is not None:
             print "{0}: {1}".format(key, self.listbox.cget(key))
         else:
             print key
Beispiel #4
0
 def dorun(self):
     #hostmanager.instance().addhostlist(self.hostlist)
     hostmanager.instance().printf()
     for i in range(self.num):
         print "adding a thread %d" % i
         self.threadlist.append(onethread())
         print "added a thread %d" % i
     for i in range(self.num):
         print "starting a thread %d" % i
         self.threadlist[i].start()
         print "started a thread %d" % i
     for i in range(self.num):
         print "joining a thread %d" % i
         self.threadlist[i].join()
         print "joined a thread %d" % i
     hostmanager.instance().printf()
     return 0
Beispiel #5
0
 def dorun(self):
     #hostmanager.instance().addhostlist(self.hostlist)
     hostmanager.instance().printf()
     for i in range(self.num):
         print "adding a thread %d" % i
         self.threadlist.append(onethread())
         print "added a thread %d" % i
     for i in range(self.num):
         print "starting a thread %d" % i
         self.threadlist[i].start()
         print "started a thread %d" % i
     for i in range(self.num):
         print "joining a thread %d" % i
         self.threadlist[i].join()
         print "joined a thread %d" % i
     hostmanager.instance().printf()
     return 0
Beispiel #6
0
    def run(self):
        #num = 0
        while not self.done:
            time.sleep(1)
            #num += 1
            #runtime = time.time() - self.starttime
            #tmplist = list(self.list_item)
            #for i in range(len(tmplist)):
            #tmplist[i] += runtime

            #tmplist.insert(0, num)
            self.list_item = tuple(hostmanager.instance().getresult())
            self.var.set(self.list_item)
            self.update()
Beispiel #7
0
    def run(self):
        #num = 0
        while not self.done:
            time.sleep(1)
            #num += 1
            #runtime = time.time() - self.starttime
            #tmplist = list(self.list_item)
            #for i in range(len(tmplist)):
                #tmplist[i] += runtime

            #tmplist.insert(0, num)
            self.list_item = tuple(hostmanager.instance().getresult())
            self.var.set(self.list_item)
            self.update()
Beispiel #8
0
 def __init__(self):
     Tkinter.Tk.__init__(self)
     self.title("Get Lan Info")
     self.geometry('300x200')
     self.iconname("haha")
     self.frame = Tkinter.Frame(
         self,
         cnf=configManager.instance().getconfig('Frame'),
         relief=RIDGE,
         borderwidth=2)
     self.frame.pack(fill=BOTH, expand=1)
     self.var = Tkinter.StringVar()
     self.font = tkFont.Font(family="Times", size=10, weight=tkFont.BOLD)
     self.listbox = Tkinter.Listbox(
         self.frame,
         cnf=configManager.instance().getconfig('Listbox'),
         height=5,
         selectmode=BROWSE,
         listvariable=self.var,
         font=self.font,
         bg='#646464',
         fg='#c8c8c8')
     self.list_item = tuple(hostmanager.instance().getresult())
     self.var.set(self.list_item)
     self.scrl = Tkinter.Scrollbar(self.frame)
     self.scrl.pack(side=RIGHT, fill=Y)
     self.listbox.configure(yscrollcommand=self.scrl.set)
     self.listbox.pack(side=LEFT, fill=BOTH)
     self.scrl['command'] = self.listbox.yview
     self.button2 = Tkinter.Button(self.frame,
                                   text="Exit",
                                   command=self.exit)
     self.button2.pack(side=BOTTOM)
     self.done = 0
     self.starttime = time.time()
     #'''
     for key in self.listbox.keys():
         value = self.listbox.cget(key)
         if type(value) is not None:
             print "{0}: {1}".format(key, self.listbox.cget(key))
         else:
             print key
Beispiel #9
0
 def setresult(host, flag):
     hostmanager.instance().setresult(host, flag)
Beispiel #10
0
    def run(self):
        self.running = 1
        print "run thread {0}".format(self.name)
        while self.running:
            host = onethread.gethost()
            if host is None:
                return 0
            p = pingTask(host)
            p.dotask()
            if p.retcode == 0:
                tmp = re.search('TTL=\d+', p.output)
                if tmp is not None:
                    onethread.setresult(host, True)
                    print "thread {0} host {1} is over with {2}".format(self.name, host, True)
                else:
                    onethread.setresult(host, False)
                    print "thread {0} host {1} is over with {2}".format(self.name, host, False)
            else:
                onethread.setresult(host, False)
                print "thread {0} host {1} is over with {2}".format(self.name, host, False)

    def stop(self):
        self.running = 0

if __name__ == '__main__':
    hostmanager.instance().genhostlist(network='192.168.1', max=106, min=105)
    ot = onethread()
    ot.start()
    ot.join()
Beispiel #11
0

class main:
    def __init__(self, tnum=2):
        self.dm = dmThread()
        self.rh = rhThread(tnum)

    def run(self):
        self.rh.start()
        self.dm.start()
        while True:
            if dmstop and rhstop:
                return 0
            if dmstop:
                self.dm.join()
                if not rhstop:
                    self.rh.rh.stop()
            if rhstop:
                self.rh.join()


if __name__ == '__main__':
    hostmanager.instance().genhostlist(network='192.168.118', max=120, min=100)
    m = main(5)
    m.run()





Beispiel #12
0
            if type(value) is not None:
                print "{0}: {1}".format(key, self.listbox.cget(key))
            else:
                print key
        #'''

    def exit(self):
        self.done = 1
        self.destroy()

    def run(self):
        #num = 0
        while not self.done:
            time.sleep(1)
            #num += 1
            #runtime = time.time() - self.starttime
            #tmplist = list(self.list_item)
            #for i in range(len(tmplist)):
            #tmplist[i] += runtime

            #tmplist.insert(0, num)
            self.list_item = tuple(hostmanager.instance().getresult())
            self.var.set(self.list_item)
            self.update()


if __name__ == "__main__":
    hostmanager.instance().genhostlist(network='192.168.118', max=106, min=105)
    dm = DisplayMsg()
    dm.run()
Beispiel #13
0
 def setresult(host, flag):
     hostmanager.instance().setresult(host, flag)