Re: [Tutor] tuples and mysqldb tables (fwd)

2005-09-19 Thread Ed Hotchkiss
Thanks for the link! It is EXACTLY what I have been looking for. When I used to use Flash a bit, and did some actionscript they had a similiar setup for OOP (Do all languages use OOP so similiarly?) which I never learned. I'm doing these examples, and now I'm going to try and rework the code from the beginning. Thanks again!

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


Re: [Tutor] tuples and mysqldb tables (fwd)

2005-09-19 Thread Danny Yoo


> Thanks for the debugging help :P - I've edited the error handling line, and
> defined the port_counter above, but I am still not getting any output. I
> have inserted print "scanned: ",port_counter,"\n"
> into the thread, so that should at least print to screen each time the
> thread is ran, regardless of the port being open or closed. Any ideas why
> the thread itself though is not working?
> A cleaner view of the code is here:
> http://deadbeefbabe.org/paste/1672?_nevow_carryover_=1127102735.7127.0.0.10.809800804887
>  Thanks again for the error handling help!

Hi Ed,

There are logically two possible areas where there might be a bug: there
might be a problem in the scanThread class, or there might be a problem in
scan.

Or there could be problems in both.  *grin*

You're still running into some fundamentally basic problems dealing with
variables and how variable scope works.  See:

http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm

and go through the examples there: it should help clarify some of the
confusion you have about maintaining state in a class.

As it stands, there is nothing in the class definition that knows about
what 'ip' or 'port_counter' are: those two aren't parameters of the class
or its methods, nor are they instance variables.




> I have inserted print "scanned: ",port_counter,"\n" into the thread, so
> that should at least print to screen each time the thread is ran,
> regardless of the port being open or closed.

The direct implication here is that scanThread.run() itself is NOT being
executed.  So there's also a problem in scan() that prevents the threads
from getting started in the first place.  I don't understand what you're
trying to do with:

while threading < MAX_THREADS:
...

since 'threading' is the 'threading' module.  Unfortunately, Python won't
treat this as a TypeError, even though it really should be treated as such
(what does it mean for a module to be "smaller" than something else?!)

And MAX_THREADS is undefined.

Are you getting any kind of error messages when you run your program?
I'm a bit confused, because there's so many opportunities here for Python
to tell you that there's a NameError here:  are you seeing those error
messages too?

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


Re: [Tutor] tuples and mysqldb tables (fwd)

2005-09-19 Thread Danny Yoo
[Again forwarding to tutor.  Ed, please keep tutor@python.org in CC;
otherwise, your questions might lose themselves in my mailbox.  I don't
want to be a bottleneck in your learning.]

-- Forwarded message --
Date: Mon, 19 Sep 2005 00:06:13 -0400
From: Ed Hotchkiss <[EMAIL PROTECTED]>
To: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] tuples and mysqldb tables

Thanks for the debugging help :P - I've edited the error handling line, and
defined the port_counter above, but I am still not getting any output. I
have inserted print "scanned: ",port_counter,"\n"
into the thread, so that should at least print to screen each time the
thread is ran, regardless of the port being open or closed. Any ideas why
the thread itself though is not working?
A cleaner view of the code is here:
http://deadbeefbabe.org/paste/1672?_nevow_carryover_=1127102735.7127.0.0.10.809800804887
 Thanks again for the error handling help!

 On 9/18/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
>
>
>
> > def run(self):
> > try:
> > ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > ss.connect((ip, port_counter))
> > print "%s | %d OPEN" % (ip, port_counter)
> > ss.close()
> > except: pass
> 
>
> Hi Ed,
>
> Yikes. Don't do that. *grin*
>
> By "that", I mean setting the exception handler here to do nothing.
> Exception handling shouldn't abused to silence errors like that, at least,
> not wholesale like that. At the very least, while we're debugging this,
> import the 'traceback' module and at least give a heads up, like this:
>
> except:
> traceback.print_exc()
>
> Once this is in place, expect to see errors. I know what you meant to do:
> you wanted to ignore network errors, so try to make the exception handler
> a little more specific in the exceptions it's trying to silence.
>
> The problem here is that the handler has been inadvertantely silencing a
> legitimate NameError. From casual inspection, it's not clear what
> 'port_counter' is. I suspect you want to add that as part of the thread's
> state, in which case consider adding it within your thread's __init__
> method.
>
>
> > def scan(ip, begin, end):
> > for port_counter in range(begin, end):
> > while threading < MAX_THREADS:
> > scanThread().start()
> > # end function ---
>
>
> Ok, I definitely suspect port_counter now as the culprit here. Make sure
> you create each thread with port_counter as a part of each thread's state.
>
>
> [Aside: are you trying to a port scanner in the style that Jacob Matthews
> wrote about here?
>
> http://www.kuro5hin.org/story/2004/3/17/93442/8657
>
> Just curious.]
>
>
>
> Good luck to you!
>
>


-- 
edward hotchkiss

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