Re: [Tutor] script question

2005-10-18 Thread Chris Hallman
Here is my latest revision, which works very well. # This Python script was written to forward interface down messages    # to ESM1. If the incoming arguements match the interface file # (c:\utils\interface.ini) then the message is forwarded. # # Author:    tcdh # Date:        09/22/05 #

Re: [Tutor] script question

2005-09-30 Thread Kent Johnson
Chris Hallman wrote: > > Thanks for all the input!!! I really appreciate it. I need to post a > correction to my script. What I sent was an early version. I made a few > minor modifications: You don't seem to have incorporated any of the suggestions that you have received! I doubt that a 4000

Re: [Tutor] script question

2005-09-29 Thread Jacob S.
Why are you importing string?   1) You don't seem to use it anywhere 2) Use string methods instead   Jacob - Original Message - From: Chris Hallman To: tutor@python.org Sent: Wednesday, September 28, 2005 7:35 AM Subject: Re: [Tutor] s

Re: [Tutor] script question

2005-09-28 Thread Andrew P
Have you benchmarked it yet?  4000 lines isn't very many, even for an older machine.  Starting the Python interpreter usually takes most of the time with simple scripts like this.  Honestly, benchmark :) You might find it easier to do:: interface_list = INI.items(section)for i in interface_list:

Re: [Tutor] script question

2005-09-28 Thread Chris Hallman
Thanks for all the input!!! I really appreciate it. I need to post a correction to my script. What I sent was an early version. I made a few minor modifications: import ConfigParser, string, sys, ossection = sys.argv[1]interface = sys.argv[3]INI=ConfigParser.ConfigParser()INI.read("c:\utils\int

Re: [Tutor] script question

2005-09-26 Thread Kent Johnson
Kent Johnson wrote: > *TEST FIRST* Don't optimize until you know it is too slow and you > have a test case that you can time to see if your 'optimizations' are > making it faster. Pardon my shouting :-) Kent ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] script question

2005-09-26 Thread Kent Johnson
Chris Hallman wrote: > Here is the script: > > import ConfigParser, string, sys > section = sys.argv[1] > port = sys.argv[3] > INI=ConfigParser.ConfigParser() > INI.read("interfaces.ini") > passwordentries=[p for p in INI.options(section)] > passwordlist=[INI.get(section, pw) for pw in passwordent

Re: [Tutor] script question

2005-09-26 Thread R. Alan Monroe
> for i in passwordlist: > if i == port: > os.system("d:\\tnd\\bin\\cawto.exe -cat NetNet " + sys.argv[1] + " " + >sys.argv[2] + " " + sys.argv[3] + " " + sys.argv[4]) If you don't have duplicates in your list, a "break" after the os.system line might help, because once you've found

Re: [Tutor] script question

2005-09-26 Thread Christopher Arndt
Chris Hallman schrieb: > for i in passwordlist: > if i == port: > os.system("d:\\tnd\\bin\\cawto.exe -cat NetNet " + sys.argv[1] + > " " + sys.argv[2] + " " + sys.argv[3] + " " + sys.argv[4]) 1) The last line can be also expressed as: os.system(r"d:\tnd\bin\cawto.exe -cat NetNet %s" %

Re: [Tutor] script question

2005-09-26 Thread Kent Johnson
Chris Hallman wrote: > The script is executed in this > manner: > > python search_interface.py device interface interface_name "is down - > 00:00:00 01/01/06" > > Here is the script: > > import ConfigParser, string, sys > section = sys.argv[1] > port = sys.argv[3] > INI=ConfigParser.ConfigPars

[Tutor] script question

2005-09-26 Thread Chris Hallman
I needed a script that takes command line arguments, searches an ini file for a match to the arguments and then executes a Windows executable. This is my first script using python so I wanted to make sure I made the most of the language. I took bits and pieces from different tutorials and examples