[Tutor] Turning a "script" into an "application"

Bill Mill bill.mill at gmail.com
Tue Oct 26 23:57:18 CEST 2004


Christian,

I'm not really sure what you're asking. Do you have more concrete questions?

It seems to me that, instead of messing around with threads, you may
want to write an entirely seperate script to control the network
script. Pseudocode:

##############
#network_script_controller
#############
while 1:
    actions = {'1': send_foo_to_network_script,    #this is a function reference
        '2': send_bar_to_network_script                 #so is this
        #and whatever else menu options you want
        }
    print "Enter one to change foo, or two to change bar"
    msg = raw_input('>')
    actions[msg]()

#############
#network_script
############
while 1:
    do_my_processing_loop()
    check_for_new_messages()

And you could simply use sockets for communication between the two. Is
that something like what you're looking for?

Peace
Bill Mill
bill.mill at gmail.com


On Tue, 26 Oct 2004 16:19:28 -0500, Christian Wyglendowski
<christian.wyglendowski at greenville.edu> wrote:
> Hi fellow Python programmers,
> 
> I have created a network monitoring script with Python. It takes some
> command line arguments and captures packets from a network interface for
> a period of time, performs a simple analysis on the captured packets and
> then sends an email to me if the results are outside of set boundaries.
> Right now I have the script running every so often using Windows Task
> Scheduler.
> 
> Rather than use Windows to control my script's behavior, I would like to
> add some larger control method to it so it can have persistent (in
> memory) data, the ability to control scan parameters from within the
> application, the ability to stop and start scans from within the
> application, save captured data to file, etc.  I would like to leave
> interface options open (text, GUI, web, etc).
> 
> What I hope to get from the community here is a nudge in the right
> direction.
> 
> Do I need to use threads?  Is there some sort of framework already
> available that I can build upon?  Is there some programming construct
> that lends itself to this sort of problem?  Other ideas that I have not
> even thought of?
> 
> Thanks for any guidance anyone can give.  This is mostly new territory
> for me.
> 
> Christian
> http://www.dowski.com
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list