← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #144072]: define my own help parameters

 

Question #144072 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/144072

    Status: Open => Answered

RaiMan proposed the following answer:
--1. this will never work in IDE, since in IDE no args are given to the
script. So your script can only from command line (use any defined
method, that gives the args through to your script)

--2. OptionParser throws an exception, when an option is given, that is not defined by you (this is the case for -h, even if this yields a default action)
so you have to script like that:
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-u", action="store_false", dest="option", default=True, help="Up system")
try:
	(options, args) = parser.parse_args()
except:
	print "option exception"
print sys.argv[1:]

in the except block you might implement corrective actions (or just
exit(), will be silent again with rc2)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.