I'm probably asking for a lot here. But I don't think I understand this fully.
This is the part I tried to get the Bar in. I actually got it in GUI wise. >> But I had no idea to let it run the moment I clicked "Scan" >> > > OK, Normally you have to update the bar values from inside a > loop on your Scan method. In practice you probably need to > use a timer to relinquish control back to the GUI so that the > Guage refreshes itself. In pseudo code: > def onScan(self): > self.myfile = open('foo.txt') > self.count = 0 > self.setTimer(0.01, self.processLine) > > def processLine(self) > line = self.myfile.readline() > if line: > processLine(line) > self.count += 1 > self.myGauge.setValue(count) > self.setTimer(0.01, self.processLine) > else: > self.myGuage.setValue(0) > > This also allows the user to use the GUI while the scan is running > Ok. So lets see if I got this right. In the onScan you define self.myfile to open 'foo.txt' One thing I don't get here is what is foo.txt used for? Then you set the count to 0 Then you set the timer to 0.01 with the event processLine? then in the processLine you add 1 to the count with every line that is read? ## Define all the private IP ranges that we're not going to filter in >> ## the ipconfig part of the program. >> ## From private4 to private19 is actually 1 range. (Needs to be looked >> at.) >> >> ##------------------------------------------------------------------------------ >> private1 = r"192\.168\.\d+\.\d+" >> private2 = r"169\.254\.\d+\.\d+" >> private3 = r"10\.\d+\.\d+\.\d+" >> ... >> private19 = r"172\.31\.\d+\.\d+" >> > > Why not put them in a list or tuple called privates? > It will save typing and: > > lines = file('ipconfig.txt', "r+").readlines() >> for i in range(len(lines)): >> if re.search("IP\D+ \:", lines[i]): >> if not re.search(private1, lines[i]): >> if not re.search(private2, lines[i]): >> .... >> if not re.search(private19, lines[i]): >> > > The if not search lines could then be replaced by a loop. > This has the added advantage that you can change the > list of privates(adding or deleting entries)) without > changing this code. > > lines = file('ipconfig.txt', "r+").readlines() > for i in range(len(lines)): > if re.search("IP\D+ \:", lines[i]): > for p in patterns: > if search(p,lines[i]): > break > else: > # equivalent of the end of your chain > > Another approach would be to compbine all the private IP > addresses into a single long regex. You can then do a > single search for the pattern. This would be faster but > slightly harder to read/debug. > I'll try to implement that loop :) Thanks for the help! Regards, Olrik
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor