#!/usr/bin/env python2 """Control Script for processing comet front end. Mostly this just uses the objects for control, but it does get to specify a few things """ import cometFlowControl import cometCommands import optparse import sys # Use optparse to define commmand line options. parser = optparse.OptionParser() parser.add_option("-l","--logfile",action="store",dest="logfile", type="string",default=None, help="Specify the name of the log file for the comet job") parser.add_option("-c","--configfile",action="store",dest="configfile", type="string",default = "comet.cfg", help="Specify the name of the cards file for the comet job") parser.add_option("-r","--runnumber",action="store",dest="number",type="string", default = None, help="Provide a number of up to 8 characters to give output files a unique name. This will be encorporated into the output files. If this option is used it will override the value in the cards file.") parser.add_option("-u","--comment",action="store",dest="comment",type="string", default = None, help="Provide a comment to be used in the last field of the filename. This will be truncated if the file name exceeds 80 characters") parser.add_option("-t","--tmpdir",action="store",dest="tmpdir", type="string", help="Specify the directory for temporary files. Defaults to /tmp/Icedust_") parser.add_option("--command",action="store",dest="command", type="string",default=None, help="Get help for a command word in used in the configuration file. This command also requires the --section option") parser.add_option("--section",action="store",dest="section", type="string",default=None, help="Get help for a section in used in the configuration file.") parser.add_option("--list",action="store_true",dest="list", help="List all card file options") (options,args) = parser.parse_args() ################################################################# #Start the real Script. # If command has been set this is a request for help. if (options.command): if (options.section): commandList = cometCommands.cometCommands() print options.section,":",options.command+"\n"+commandList.getCommandHelp(options.section,options.command) sys.exit() sys.exit("The --section option is required for --command. Please specify the section.\nIf you are unsure use --list to list all sections and commands.") # We could also be getting help on the section if (options.section): commandList = cometCommands.cometCommands() print commandList.getSectionHelp(options.section) sys.exit() # We could also be listing commands if (options.list): commandList = cometCommands.cometCommands() commandList.listCommands() print """ To get help with a specific section type RunIcedustControl -- section=\"section\"""" print """ To get help with a specific command type RunIcedustControl -- section=\"section\" --command=\"command\" """ sys.exit() # Create the object. control = cometFlowControl.cometFlowControl() # Pass the command line arguments. control.setLogfile(options.logfile) control.setConfig(options.configfile) control.setOutputNumber(options.number) control.setOutputComment(options.comment) control.setTmpDir(options.tmpdir) # Process options and run. control.RunIcedust()