Mark Kels wrote:

On Mon, 21 Feb 2005 13:21:35 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:


How far does it get? How do you know?

I would put some debug print statements in. Also you should call sk.close() in the else clause of
scan(). Finally, I don't think you will see any output in the result window until get_info()
returns; you have to give some time to mainloop() for it to be able to trigger the updates.


I don't understand how to prevent the program from crashing right now...
I'll deal with other bugs when I'll finish this one :)
So, why does the program crashes and how can I prevent it ??

Thanks !!



Hi Mark,

I believe Kent has given you the solution, it's perhaps just not what you expected it to be. Adding debug print statements might have helped you to see. To demonstrate further try scanning only 1 or 2 ports.

When your app appears to be frozen or crashing, I suspect it is happily scanning away. Looks like you have an overly ambitious while loop in the scan function, which isn't giving the Tk Text widget (result_t?) time to update.

Someone more experienced that I will certainly have a better way, but you might try adding root.update() at the end (but inside) the while loop to force an update.

# + ---The Scan---
def scan(host,start_port,end_port):
   sk=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   while start_port<=end_port:
       try:
           sk.connect((host,start_port))
       except:
           result_t.insert(END,"Port",start_port,"is CLOSED on",host,"\n")
       else:
           result_t.insert(END,"Port",start_port,"is OPENED on",host,"\n")
       start_port=start_port+1
       root.update() #<<-- add this

and have a look here http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm

>>> import Tkinter
>>> help(Tkinter.Tk)
Help on class Tk in module Tkinter:
...
|
| update(self)
| Enter event loop until all pending events have been processed by Tcl.
|
| update_idletasks(self)
| Enter event loop until all idle callbacks have been called. This
| will update the display of windows but not process events caused by
| the user.
...
HTH,
Marty



_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to