How to run python file with options (exemple: python example.py --client=clientname)

Jun 13, 2012 at 9:05 AM

How to run python file with options (exemple: python example.py --client=clientname)?

where to submit the options : --client=clientname? in the Arguments text field?

Jun 13, 2012 at 12:50 PM

Assuming you made a project:

With the project selected: Project->Properties->Debug->Script Arguments

var1="value1";var2="value2"

Jun 14, 2012 at 7:18 AM
Edited Jun 14, 2012 at 7:20 AM

Thank you a lot for your help!!

The case here is that i'm trying to parse the arguments with "getopt"

The arguments are in the format of --argument1="cc"

sometimes an option does not have value (without "=..") exemple: -o (for exemple to tell the process to omit clientname)

 

 

code:

opts, args = getopt.getopt(args[1:], opt_short, opt_long)

   for opt, arg in opts:



      if opt in ('-c', '--client'):

         client2 = arg

I tried to submit 

With the project selected: Project->Properties->Debug->Script Arguments

client="clientname";server="server2";-o and it didn't work!

 

sorry to bother again, and thanks one more time for your help

Jun 14, 2012 at 10:47 AM

it's working thanks!

I put the Arguments in this way: --client=clientname --server=server2 (separated by space instead of ";")

 

but I realized that the script is exiting on the following command line:

print commands.getoutput('./send_file.sh '+ server +' '+ file) where server and file are too string variables

 

debug message:

'{' is not recognized as an internal or external command,operable program or batch file.

 

Thanks for your help!