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