Greetings I am receiving an error when I attempt to place arguments into my python script. Here is the function
from optparse import OptionParser
def getparams():
usage = "usage: %prog -d <dcb_ip> -p <port> "
parser = OptionParser(usage)
parser.add_option("-d", "--dcb_ip",
action="store",
dest="dcb_ip",
default="172.14.20.31",
help="Specifiy the IP address of the device, default is [%default].")
parser.add_option("-p", "--port",
action="store",
type="int",
dest="port",
default=51500,
help="Specify the pcl port of the monitor, default is [%default].")
parser.add_option("-i", "--interactive", action="store_true", default=False, dest="interactive")
parser.add_option("-l", "--loop", action="store", default=False, dest="loop")
parser.add_option("-w", "--write", action="write_mem", default=False, dest="interactive") #Write HART option
parser.add_option("-r", "--read", action="read_mem", default=False, dest="interactive")
parser.add_option("-c", "--Cancel", action="cancel_mem", default=False, dest="interactive")
(options, args) = parser.parse_args(sys.argv)
return options
Does anyone know why I keep getting
Traceback (most recent call last):
File "C:\Users\Documents\devices_15_JUL_2013\RSimulator.py", line 73, in getparams
parser.add_option("-w", "--write", action="write_mem", default=False) #Write mem option
OptionError: option -w/--write: invalid action: 'write_mem''
I thought -c might be a common option or something but even when I changed it still did not work :(
write_mem,read_memandcancel_memare not valid values for theactionkeyword; see Standard option actions for what is available.It is not clear what you expect those options to do, however. You specified the destination as
interactive, but that is already in use as a boolean flag for the-i,--interactiveoption.If you wanted to set boolean flags for each of these in their
_memoptions, then do so withstore_trueactions: