Helper command line parser for taurus based on optparse. Suppose you have an application file:
import sys
from PyQt4 import Qt
class GUI(Qt.QMainWindow):
pass
def main():
import taurus.core.util.argparse as argparse
parser, options, args = argparse.init_taurus_args()
app = Qt.QApplication(sys.argv)
w = GUI()
w.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
The call to taurus.core.util.argparse.init_taurus_args() will initialize taurus environment based on the command line options given by the user. Currently, the known options are:
- --help prints the total number of available options
- --taurus-log-level sets the taurus log level
- --tango-host sets the default tango host
- --taurus-polling-period sets the default taurus global polling period (milliseconds)
- --taurus-serialization-mode sets the default taurus serialization mode
- --remote-console-port enables remote debugging using the given port
You can easily extend the taurus options with your application specific options. Suppose you want to add an option like --model=<model name>:
def main():
import taurus.core.util.argparse as argparse
parser = argparse.get_taurus_parser(parser=parser)
parser.set_usage("%prog [options] <special item>")
parser.set_description("my own GUI application")
parser.add_option("--model")
parser, options, args = argparse.init_taurus_args(parser=parser)
app = Qt.QApplication(sys.argv)
w = GUI()
w.show()
sys.exit(app.exec_())
Functions
Returns a optparse.OptionParser initialized with a optparse.OptionGroup containning some taurus options. If a parser is given as parameter then it uses this parser instead of creating a new one.
Parameters: | parser (optparse.OptionParser) – an option parser or None (default) to create a new parser |
---|---|
Returns: | an option parser or the given parser if it is not None |
Return type: | optparse.OptionParser |
Parses the command line using taurus.core.util.argparse.parse_taurus_args().
After the command line is parsed, actions are taken on each recognized parameter. For example, the taurus log level and the default tango host are set accordingly.
Parameters: |
|
---|---|
Returns: | a tuple of three elements: parser, options, args |
Return type: | optparse.OptionParser, optparse.Values, seq<str> |
Parses the command line. If parser is not given, then a new parser is created. In any case, the parser is initialized using the taurus.core.util.argparse.get_taurus_parser(). args and values are the optional parameters that will be given when executing optparse.OptionParser.parse_args().
Parameters: |
|
---|---|
Returns: | a tuple of three elements: parser, options, args |
Return type: | optparse.OptionParser, optparse.Values, seq<str> |
Splits arguments into valid parser arguments and non valid parser arguments.
Parameters: |
|
---|---|
Returns: | a tuple of two elements: parser args, non parser args |
Return type: | seq<seq<str>, seq<str>> |