Beispiel #1
0
def main():
    from optparse import OptionParser
    from os import listdir
    from os.path import join, isdir, isfile, basename

    parser = OptionParser()
    parser.set_description(
        'Check python source files for unknown name errors '
        'and for unused imports. '
        'The arguments name files to check or '
        'directories to check recursively. '
        'If no arguments are given, the current directory '
        'is checked. '
        'If there is a recursion, it excludes ".svn", "build", '
        'and "dist" directories, and includes files that end '
        'in ".py" or ".qpy".')
    (options, args) = parser.parse_args()
    if args:
        todo = args
    else:
        todo = ['.']
    while todo:
        arg = todo.pop()
        if basename(arg) in ['.svn', 'dist', 'build']:
            continue
        elif (isfile(arg) and
              arg in sys.argv or
              (arg.endswith('.py') or
               arg.endswith('.qpy'))):
            check(arg)
        elif isdir(arg):
            todo.extend([join(arg, item) for item in listdir(arg)])
Beispiel #2
0
def main():
    from optparse import OptionParser

    p = OptionParser()
    p.set_usage('dedoppler <FULL_PATH_TO_FITS_FILE>')
    p.set_description(__doc__)

    p.add_option('-m', '--min_drift', dest='min_drift', type='float', default=0.0,
            help='Set the minimum drift rate to search. Unit: Hz/sec. Default:0.0')
    p.add_option('-M', '--max_drift', dest='max_drift', type='float', default=10.0,
            help='Set the drift rate to search. Unit: Hz/sec. Default: 10.0')
    p.add_option('-s', '--snr', dest='snr', type='float', default=10.0, help='SNR threshold. Unit: ?. Default: 10.0')
    p.add_option('-b', '--bw', dest='bw', type='float', default=1, help='Specify the amount of \'compression\' to be done in frequency domain to search for more \'spread out\' signals. Unit:?. Default: ?')
    p.add_option('-r', '--rfithresh', dest='rfithresh', type='float', default=25.0, help='Specify the RFI threshold. Unit:?. Default: 25.0')
    p.add_option('-p', '--path', dest='split_dir', type='str', default='/tmp',
            help='In the case that the input FITS file size is too big to handle at once, we\'ll need to split it into smaller FITS files. This option specify where to put those FITS files. Default: /tmp ')
    p.add_option('-o', '--output', dest='out', type='str', default='', help='')
    p.add_option('-w', '--width', dest='slice_width', type='int', default=512, help='')
    p.add_option('-l', '--loglevel', dest='loglevel', type='str', default='debug', help='Specify log level')

    opts, args = p.parse_args(sys.argv[1:])

    if len(args)!=1:
        print 'Please specify a FITS file \nExiting.'
        sys.exit()
    else:
        fitsfile = args[0]

    logging.basicConfig(
        format='%(relativeCreated)5d %(name)-15s %(levelname)-8s %(message)s', level = logging.DEBUG)

    mydedopptask = dedopp.DedopplerTask(fitsfile = fitsfile, max_drift = opts.max_drift, min_drift = opts.min_drift, snr = opts.snr, bw = opts.bw, rfithresh = opts.rfithresh, split_dir = opts.split_dir)

    mydedopptask.search()
Beispiel #3
0
def main():
    """Main function"""
    usage = "usage: %prog [options]"

    parser = OptionParser(usage)

    parser.set_description("To test the Logger class.")

    parser.add_option("-v", "--verbose", dest="verbose", help="Verbose mode", action="store_true", default=False)

    parser.add_option("-p", "--port", dest="port", help="Http Port (Default: 4041)", type="int", default=4041)

    (options, args) = parser.parse_args()

    if len(args) != 1:
        parser.error("Error: incorrect number of arguments, try --help")

    parser = PdfParser(args[0], "", "")
    # info = parser.get_logical_structure()
    # print info
    toc = parser.get_logical_structure()
    import pprint

    pprint.pprint(toc)
    info = parser.get_metadata()
    pprint.pprint(info)
def main():
    """Main function"""
    usage = "usage: %prog [options]"

    parser = OptionParser(usage)

    parser.set_description ("To test the Logger class.")

    parser.add_option ("-v", "--verbose", dest="verbose",
                       help="Verbose mode",
                       action="store_true", default=False)

    parser.add_option ("-p", "--port", dest="port",
                       help="Http Port (Default: 4041)",
                       type="int", default=4041)

    (options, args) = parser.parse_args()

    if len(args) != 0:
        parser.error("Error: incorrect number of arguments, try --help")

    from wsgiref.simple_server import make_server
    application = WebProcessorApp()
    server = make_server('', options.port, application)
    server.serve_forever()
Beispiel #5
0
def main():
    from optparse import OptionParser
    from quixote.util import import_object
    parser = OptionParser()
    parser.set_description(run.__doc__)
    default_host = 'localhost'
    parser.add_option(
        '--host', dest="host", default=default_host, type="string",
        help="Host interface to listen on. (default=%s)" % default_host)
    default_port = 3000
    parser.add_option(
        '--port', dest="port", default=default_port, type="int",
        help="Port to listen on. (default=%s)" % default_port)
    default_maxchild = 5
    parser.add_option(
        '--max-children', dest="maxchild", default=default_maxchild,
        type="string",
        help="Maximum number of children to spawn. (default=%s)" %
            default_maxchild)
    parser.add_option(
        '--script-name', dest="script_name", default=None, type="string",
        help="Value of SCRIPT_NAME (only needed if using mod_scgi)")
    default_factory = 'quixote.demo.create_publisher'
    parser.add_option(
        '--factory', dest="factory",
        default=default_factory,
        help="Path to factory function to create the site Publisher. "
             "(default=%s)" % default_factory)
    (options, args) = parser.parse_args()
    run(import_object(options.factory), host=options.host, port=options.port,
        script_name=options.script_name, max_children=options.maxchild)
Beispiel #6
0
def main():
 parser = OptionParser(usage="usage: %prog [options] [filename]", version="%prog 1.0", epilog="post")
 parser.add_option("-t", "--trans",
                  action="store_true", dest="trans", default=False,
                  help="transfer a local file to the Haze server")
 parser.add_option("-g", "--gets",
                  action="store_true", dest="gets", default=False,
                  help="get a file from the Haze Server")
 parser.set_description(des)
 (options, args) = parser.parse_args()
 alen = len(args)
 print "options:", options, " args:", args
 print base
##########################################################
 if not options.trans and not options.gets and alen >0:
  parser.print_help()
 elif options.trans and not options.gets:
  scpcommand='scp -r ' + ' '.join(args) + ' benhe@haze.hprn.yorku.ca:' + tbase
  print scpcommand
  os.system(scpcommand)
 elif options.gets and not options.trans:
  scpcommand='scp -r benhe@haze.hprn.yorku.ca:' + getMulti(args, base = tbase) + ' .'
  print scpcommand
  os.system(scpcommand)
 else:
  scpcommand='scp -r benhe@haze.hprn.yorku.ca:"' + base + '/DUTLIB.jar ' + base +'/LabLucene1.0.jar" lib/'
  print scpcommand
  os.system(scpcommand)
Beispiel #7
0
def buildOptParser():
    from optparse import OptionParser

    parser = OptionParser()
    parser.set_description("This is the proxy to PRS functionality, also invoked "+\
                           "locally, e.g. for calibration requests.")

    parser.add_option("-v", "--verbose", 
                      dest="verbosity", action="store_true",
                      help="increase HTTP client messaging on adcc GET requests.")

    parser.add_option("-i", "--invoked", 
                      dest = "invoked", action = "store_true",
                      help = "Used by processes that invoke prsproxy, so "+\
                      "that PRS proxy knows when to exit. If not present, the "+\
                      "prsproxy registers itself and will only exit by user "+\
                      "control (or by os-level signal).")

    parser.add_option("--startup-report", 
                      dest = "adccsrn", default=None, 
                      help = "Specify a file name for the adcc startup report")

    parser.add_option("--preload", 
                      dest="preload", action="store_true",
                      help = "Useful in proxy mode, where some information "+\
                      "otherwise produced during the first relevant request "+\
                      "is prepared prior to starting the HTTPServer.")

    parser.add_option("--reload", 
                      dest="reload", action="store_true",
                      help = "Just like --preload, but uses last, cached "+\
                      "(pickled) directory scan.")

    parser.add_option("-r", "--reduce-port", 
                      dest = "reduceport", default=54530, type="int",
                      help="When invoked by reduce, this is used to inform "+\
                      "the prsproxy of the port on which reduce listens for "+\
                      "xmlrpc commands.")

    parser.add_option("-p", "--reduce-pid", 
                      dest ="reducepid", default=None, type="int",
                      help = "When invoked by reduce, this option is used to "+\
                      "inform the prsproxy of the reduce application's PID.")

    parser.add_option("-l", "--listen-port", 
                      dest = "listenport", default=53530, type="int", 
                      help="prsproxy listener port for the xmlrpc "+\
                      "server.")

    parser.add_option("-w", "--http-port", 
                      dest = "httpport", default=8777, type="int",
                      help="Response port for the web interface. "+\
                      "i.e. http://localhost:<http-port>/")

    args, pos_args = parser.parse_args()

    # No positional arguments to this interface.
    return args
    def __init__(self, parent):
        self._init_ctrls(parent)
        optParse=OptionParser()
        optParse.add_option('-A','--ADV',action='store_const',dest='userlevel',const=1,default=0,help='Set User to Advanced',metavar='USERLEVEL')
        optParse.add_option('-X','--EXP',action='store_const',dest='userlevel',const=2,default=0,help='Set User to Expert',metavar='USERLEVEL')
        optParse.add_option('-H','--HOST',dest='host',type='string',help='Override hostname for computer',default=socket.gethostname(),metavar='HOST')
        optParse.add_option('-D','--DEBUG',action='store_true',dest='debug',help='Run program in debug mode',default=False,metavar='DEBUG')
        optParse.add_option('-L','--LOG',action='store_true',dest='log',help='Pump screen output to a log',default=False,metavar='LOG')

        optParse.add_option('-R','--RO',action='store_true',dest='readonly',help='Epics Variables are Read Only',default=False,metavar='READONLY')
        
        
        optParse.set_description('The graphical tool for the sample alignment code')
        
        optParse.print_help()
        (opt,args)=optParse.parse_args()
        
        if opt.log:
            newPipe=__LoggingPipe__('Autoalign')
            globals()['sys'].stdout=newPipe
            globals()['sys'].stderr=newPipe
        
        
        dSize=(2048,2048)
        self.traceGraph = kPlot(name=u'traceGraph', parent=self, pos=wx.Point(16, 104),
         size=wx.Size(456-16*2, 464), style=0,xAxis=(-dSize[0]/2,dSize[0]/2),yAxis=(-dSize[1]/2,dSize[1]/2),title='Sample Alignment')
        self.histoPlot = kPlot(name=u'histoPlot', parent=self, pos=wx.Point(16, 104+16+464),
         size=wx.Size(464*2+16, 200), style=0,title='Histogram')
        self.cmbMaterial = dictComboBox(dict=X_ROBOT_X02DA_AALib.sampleThreshLib,
              name=u'cmbMaterial', parent=self, pos=wx.Point(224, 16),
              size=wx.Size(112, 27), style=0, value=u'Material...')
        self.cmbMaterial.SetLabel(u'')
        self.stime=time.time()
        self.txtGlob.SetValue('$HOME/*/*/tif/*.tif')
        # old search string '$HOME/Data10/disk2/*/tif/*.tif'
        self.graphTimer=wx.Timer(self,-1)
        self.timerCycle=5000
        self.graphTimer.Start(self.timerCycle)
        self.Bind(wx.EVT_TIMER,self.mainTimerEvent) 
        self.cImg=100
        self.cKey=''
        self.cThresh=self.threshVal.GetValue()/10.0
        self.cThresh=1.0
        self.OnTxtGlobTextEnter([])
        self.dRange=[]
        self.batchEye=-2
        self.previewMode=0
        self.myStage=alignStage()
        self.oldImageName=''
        self.oldFlatName=''
        self.oldThresh=[]
        self.oldMat=''
        self.searchRunning=0
        #self.fltSelection.SetItems(self.imgList.keys())
        #self.doLoadImage()	
        self.flatIsLoaded=False
Beispiel #9
0
def main():
    MAKE_REGEX = (
            r"^\s+\[.+\]|"
            r"^make\[\d+\]: (`|Entering |Leaving |Nothing )|"
            r"^make -r |"
            r"^\w+ finished$|"
            r"^(\S*/)?\bgcc\s"
            )

    parser = OptionParser(version="%prog" + __VERSION__,
            formatter=Formatter())
    parser.set_usage(usage)
    parser.set_description(description)
    parser.add_option("-a", "--append", action="store_true", dest="append",
            help="append to given files, do not overwrite")
    parser.add_option("-v", "--verbose", action="store_const", dest="verbose",
            const=logging.DEBUG,
            help="verbose output for debugging")
    parser.add_option("-q", "--quiet", action="store_const", dest="verbose",
            const=logging.WARNING,
            help="suppress informational output")
    parser.add_option("--regex", action="append", dest="regexList",
            default=[],
            metavar="REGEX",
            help="append a 'status' regular expression (e.g., " +
                "'^#.*' for comment lines)")
    parser.add_option("--make", action="append_const", dest="regexList",
            const=MAKE_REGEX,
            help="short for --regex '" + MAKE_REGEX +
                "'; useful for the output of a " +
                "`make` invocation")
    parser.add_option("--strip", action="store_true", dest="strip",
            default=False,
            help="strip out informational output that doesn't " +
                "immediately precede non-informational output, rather " +
                "than display and overwrite it in place")

    global options
    (options, args) = parser.parse_args()

    if options.verbose is None:
        logger.setLevel(logging.INFO)
    else:
        logger.setLevel(options.verbose)

    logger.debug('Finished option processing, options=%r' % options)

    logger.debug('arguments:')

    for arg in args:
        logger.debug('arg: %s' % arg)

    regex = r'|'.join(options.regexList)
    tee(regex, args, append=options.append)

    logger.debug('Finished.')
def main():
    optParse = OptionParser()
    optParse.add_option(
        "-A",
        "--ADV",
        action="store_const",
        dest="userlevel",
        const=1,
        default=0,
        help="Set User to Advanced",
        metavar="USERLEVEL",
    )
    optParse.add_option(
        "-X",
        "--EXP",
        action="store_const",
        dest="userlevel",
        const=2,
        default=0,
        help="Set User to Expert",
        metavar="USERLEVEL",
    )
    optParse.add_option(
        "-H",
        "--HOST",
        dest="host",
        type="string",
        help="Override hostname for computer",
        default=socket.gethostname(),
        metavar="HOST",
    )
    optParse.add_option(
        "-D",
        "--DEBUG",
        action="store_true",
        dest="debug",
        help="Run program in debug mode",
        default=False,
        metavar="DEBUG",
    )
    optParse.add_option(
        "-R",
        "--RO",
        action="store_true",
        dest="readonly",
        help="Epics Variables are Read Only",
        default=False,
        metavar="READONLY",
    )

    optParse.set_description("The graphical frontend for the Robot Control and Sample Alignment")

    optParse.print_help()
    (opt, args) = optParse.parse_args()
    pass
Beispiel #11
0
def constructOptionParser():
    """
    returns a pre-setup optparser
    """
    parser = OptionParser(formatter=PreformattedDescriptionFormatter())

    parser.set_description('Retrieves eland config file from hts_frontend web frontend.')

    parser.epilog = """
Config File:
  * %s (System wide)
  * %s (User specific; overrides system)
  * command line overrides all config file options

  Example Config File:

    [%s]
    config_host: http://somewhere.domain:port
    genome_dir: /path to search for genomes
    post_run: runfolder -o <destdir> %%(runfolder)s

""" % (CONFIG_SYSTEM, CONFIG_USER, GERALD_CONFIG_SECTION)

    #Special formatter for allowing preformatted description.
    ##parser.format_epilog(PreformattedDescriptionFormatter())

    parser.add_option("-u", "--url",
                      action="store", type="string", dest="url")

    parser.add_option("-o", "--output-file",
                      action="store", type="string", dest="output_filepath",
                      help="config file destination. If runfolder is specified defaults "
                           "to <runfolder>/config-auto.txt" )

    parser.add_option("-f", "--flowcell",
                      action="store", type="string", dest="flowcell")

    parser.add_option("-g", "--genome_dir",
                      action="store", type="string", dest="genome_dir")

    parser.add_option("-r", "--runfolder",
                      action="store", type="string",
                      help="specify runfolder for post_run command ")

    parser.add_option("--sample-sheet", default=None,
                      help="path to save demultiplexing sample sheet")

    parser.add_option("--operator", default='', help="Name of sequencer operator")
    parser.add_option("--recipe", default="Unknown",
                      help="specify recipe name")

    parser.add_option('-v', '--verbose', action='store_true', default=False,
                       help='increase logging verbosity')
    return parser
Beispiel #12
0
def main():
    email = ''
    password = ''
    author = ''

    # parse passord file
    cParser = SafeConfigParser()
    is_exists = cParser.read(PasswdFile)
    if is_exists and cParser.has_section('blogger.py'):
        if cParser.has_option('blogger.py', 'email'):
            email = cParser.get('blogger.py', 'email')
        if cParser.has_option('blogger.py', 'password'):
            password = cParser.get('blogger.py', 'password')
        if cParser.has_option('blogger.py', 'author'):
            author = cParser.get('blogger.py', 'author')

    # parse command-line options
    oParser = OptionParser()

    oParser.add_option("-e", "--email", dest="email", help="E-mail address")
    oParser.add_option("-p", "--password", dest="password", help="Password")
    oParser.add_option("-u", "--author", dest="author", help="Blog author")
    oParser.add_option("-d", "--draft", dest="is_draft", action="store_true",
        help="post draft data")
    oParser.add_option("-f", "--file", dest="blogFile", help="Blog data file")

    oParser.set_defaults(email=email, password=password, author=author)
    oParser.set_description('follow options can be set by ~/.password.')

    option, args = oParser.parse_args()

    email = option.email
    password = option.password
    author = option.author

    if '' in (email, password, author):
        oParser.print_help()
        sys.exit(1)

    blogger = Blogger(email, password)
    if option.blogFile:
        title, content, label = createBlogData(file(option.blogFile))
    else:
        title, content, label = createBlogData()

    if title and content:
        blogger.createPost(title, content, author, label, option.is_draft)
    else:
        print 'No Blog data, do nothing'
        sys.exit(1)
Beispiel #13
0
def client_main():
    from optparse import OptionParser
    parser = OptionParser()
    parser.set_description("Opens a client connection to a Durus server.")
    parser.add_option(
        '--file', dest="file", default=None,
        help="If this is not given, the storage is through a Durus server.")
    parser.add_option(
        '--port', dest="port", default=DEFAULT_PORT,
        type="int",
        help="Port the server is on. (default=%s)" % DEFAULT_PORT)
    parser.add_option(
        '--host', dest="host", default=DEFAULT_HOST,
        help="Host of the server. (default=%s)" % DEFAULT_HOST)
    parser.add_option(
        '--address', dest="address", default=None,
        help=(
            "Address of the server.\n"
            "If given, this is the path to a Unix domain socket for "
            "the server."))
    parser.add_option(
        '--storage-class', dest='storage', default=None,
        help='Storage class (e.g. durus.file_storage.FileStorage).')
    parser.add_option(
        '--cache_size', dest="cache_size", default=10000, type="int",
        help="Size of client cache (default=10000)")
    parser.add_option(
        '--repair', dest='repair', action='store_true',
        help=('Repair the filestorage by truncating to remove anything '
              'that is malformed.  Without this option, errors '
              'will cause the program to report and terminate without '
              'attempting any repair.'))
    parser.add_option(
        '--readonly', dest='readonly', action='store_true',
        help='Open the file in read-only mode.')
    parser.add_option(
        '--startup', dest='startup',
        default=os.environ.get('DURUSSTARTUP', ''),
        help=('Full path to a python startup file to execute on startup.'
              '(default=DURUSSTARTUP from environment, if set)')
        )
    (options, args) = parser.parse_args()
    if options.address is None:
        address = (options.host, options.port)
    else:
        address = options.address
    interactive_client(options.file, address,
                       options.cache_size, options.readonly, options.repair,
                       options.startup, options.storage)
Beispiel #14
0
def main():
  usage = "usage: %prog [options] <input_files> "

  parser = OptionParser(usage)
  parser.set_description("Add a prefix and/or suffix to each element of a list.")

  parser.add_option("-d",
                    "--dir",
                    dest="dir",
                    help="Base directory",
                    type="string",
                    default=None)
  parser.add_option("-e",
                    "--ext",
                    dest="ext",
                    help="File extension",
                    type="string",
                    default=None)
  parser.add_option("-c",
                    "--check",
                    dest="check",
                    help="Check that each file exists",
                    action="store_true")


  (options, args) = parser.parse_args()


  for line in fileinput.input(args):
    line = line.strip().strip('\r\n')
    if options.dir != None:
      line = os.path.join(options.dir, line)

    if options.ext != None:
      line = line + options.ext

    if options.check and not os.path.exists(line):
      print >> sys.stderr, "No such file: " + line
      sys.exit(1)
      
    try:
      print line
    except IOError as e:
      if e.errno == 32:
        sys.exit(0)
      else:
        raise
def main(args):
    
	parser = OptionParser(usage="usage: %prog [OPTIONS] [TESTS]")
	parser.set_description(main.__doc__)

    	parser.add_option('--iterations', '-n',
    action="store", default=None,
    help="n iterations of Fibonacci Sequence", )

	#parse option
	(options, args) = parser.parse_args(args=args[1:])

	global Options
	Options = options

        x=run(Options.iterations);
        print x
Beispiel #16
0
def main():
    parser = OptionParser()
    parser.set_description("Stress test a Durus Server")
    parser.add_option(
        "--port", dest="port", default=DEFAULT_PORT, type="int", help="Port to listen on. (default=%s)" % DEFAULT_PORT
    )
    parser.add_option(
        "--host", dest="host", default=DEFAULT_HOST, help="Host to listen on. (default=%s)" % DEFAULT_HOST
    )
    parser.add_option(
        "--cache_size", dest="cache_size", default=4000, type="int", help="Size of client cache (default=4000)"
    )
    parser.add_option(
        "--max-loops", dest="loops", default=None, type="int", help="Maximum number of loops before exiting."
    )

    (options, args) = parser.parse_args()
    from durus.logger import logger

    logger.setLevel(5)
    storage = ClientStorage(host=options.host, port=options.port)
    connection = Connection(storage, cache_size=options.cache_size)
    try:
        if "obj" not in connection.get_root():
            init_db(connection)
            verify_db(connection, all=True)
            connection.commit()
    except ConflictError:
        connection.abort()
    n = options.loops
    while n is None or n > 0:
        if n is not None:
            n -= 1
        try:
            if hasattr(sys, "gettotalrefcount"):
                sys.stdout.write("refs = %s\n" % sys.gettotalrefcount())
            if randbool():
                connection.abort()
            verify_db(connection)
            mutate_db(connection)
            connection.commit()
            maybe_sleep()
        except ConflictError:
            sys.stdout.write("conflict\n")
            connection.abort()
            maybe_sleep()
def main():
 parser = OptionParser(usage="usage: %prog [options] [filename]", version="%prog 1.0")
 parser.add_option("-t", "--trans",
                  action="store_true", dest="trans", default=False,
                  help="transfer a local file to the Haze server")
 parser.add_option("-g", "--gets",
                  action="store_true", dest="gets", default=False,
                  help="get a file from the Haze Server")
 des = "Remove the relevant docs that are in supplied qrel, only for the Relevanc Feedback Track"
 parser.set_description(des)
 (options, args) = parser.parse_args()
 print "options:", options
 print "args:", args
 len = len(args)
 if len == 1:
  remove(args[0])
 elif len == 2: 
  remove(args[0], qrel=args[1])
Beispiel #18
0
    def getOpts(self):
        self.CONFIGITEMS['Debug'] = ('', '--debug', False, \
                                  'Prints debugging information to the stdout')

        # %prog expands to os.path.basename(sys.argv[0])
        usage  = "usage: %prog [options]"
        parser = OptionParser(usage=usage, version="%prog 1.0")
        parser.set_description(self.DESC)

        for key in self.CONFIGITEMS:
            (shortCmd, longCmd, argReq, helpText) = self.CONFIGITEMS[key]

            if argReq:
                parser.add_option(shortCmd, longCmd, dest=key, help=helpText)
            else:
                parser.add_option(shortCmd, longCmd, dest=key, action="store_true",  help=helpText)

        (self.OPTIONS, args) = parser.parse_args()
Beispiel #19
0
def get_server_parser(doc):
    parser = OptionParser()
    parser.set_description(doc)
    default_host = 'localhost'
    parser.add_option(
        '--host', dest="host", default=default_host, type="string",
        help="Host interface to listen on. (default=%s)" % default_host)
    default_port = 8080
    parser.add_option(
        '--port', dest="port", default=default_port, type="int",
        help="Port to listen on. (default=%s)" % default_port)
    default_factory = 'quixote.demo.create_publisher'
    parser.add_option(
        '--factory', dest="factory",
        default=default_factory,
        help="Path to factory function to create the site Publisher. "
             "(default=%s)" % default_factory)
    return parser
def main():
    # Basic option parsing 
    p = OptionParser()
    p.set_usage('beam_pattern_viewer.py [filename] [options]')
    p.set_description(__doc__)
    (options, args) = p.parse_args()
    
    print "Starting OSKAR antenna config tool..."
    global main_gui
    app = QtGui.QApplication(sys.argv)
    
    try:
        filename = args[0]
        main_gui = OskarGui(filename)
    except:
        main_gui = OskarGui()
    app.exec_()
    sys.exit()    
Beispiel #21
0
def getOptions():
    ##### Configuration options #####

    usage = "usage: %prog [options] ics_file1 ics_file2"
    parser = OptionParser(usage=usage, version=version)
    parser.set_description("ics_diff will print a comparison of two iCalendar files ")

    parser.add_option("-i", "--ignore-dtstamp", dest="ignore", action="store_true",
                      default=False, help="ignore DTSTAMP lines [default: False]")

    (cmdline_options, args) = parser.parse_args()
    if len(args) < 2:
        print("error: too few arguments given")
        print
        print(parser.format_help())
        return False, False

    return cmdline_options, args
Beispiel #22
0
def run_durus_main():
    parser = OptionParser()
    parser.set_description('Run a Durus Server')
    parser.add_option(
        '--port', dest='port', default=DEFAULT_PORT, type='int',
        help='Port to listen on. (default=%s)' % DEFAULT_PORT)
    parser.add_option(
        '--file', dest='file', default=None,
        help='If this is not given, the storage is in a new temporary file.')
    parser.add_option(
        '--host', dest='host', default=DEFAULT_HOST,
        help='Host to listen on. (default=%s)' % DEFAULT_HOST)
    logginglevel = logger.getEffectiveLevel()
    parser.add_option(
        '--logginglevel', dest='logginglevel', default=logginglevel, type='int',
        help=('Logging level. Lower positive numbers log more. (default=%s)' %
              logginglevel))
    parser.add_option(
        '--logfile', dest='logfile', default=None,
        help=('Log file. (default=stderr)'))
    parser.add_option(
        '--repair', dest='repair', action='store_true',
        help=('Repair the filestorage by truncating to remove anything '
              'that is malformed.  Without this option, errors '
              'will cause the program to report and terminate without '
              'attempting any repair.'))
    parser.add_option(
        '--readonly', dest='readonly', action='store_true',
        help='Open the file in read-only mode.')
    parser.add_option(
        '--stop', dest='stop', action='store_true',
        help='Instead of starting the server, try to stop a running one.')
    (options, args) = parser.parse_args()
    if not options.stop:
        start_durus(options.logfile,
                    options.logginglevel,
                    options.file,
                    options.repair,
                    options.readonly,
                    options.host,
                    options.port)
    else:
        stop_durus(options.host,
                   options.port)
def main():
    
    # Basic option parsing 
    p = OptionParser()
    p.set_usage('fits_pattern_viewer.py [filename] [options]')
    p.set_description(__doc__)
    (options, args) = p.parse_args()

    print "Starting HIPSR SD-FITS viewer..."
    global main_gui
    app = QtGui.QApplication(sys.argv)
    
    try:
        filename = args[0]
        main_gui = HipsrGui(filename)
    except:
        main_gui = HipsrGui()
    app.exec_()
    sys.exit()    
Beispiel #24
0
def main():
    from optparse import OptionParser

    p = OptionParser()
    p.set_usage('plot_results <FULL_PATH_TO_TEXT_FILE>')
    p.set_description(__doc__)

    opts, args = p.parse_args(sys.argv[1:])

    if len(args)!=1:
        print 'Please specify an input file \nExiting.'
        sys.exit()
    else:
        filename = args[0]


    logging.basicConfig(format='%(relativeCreated)5d %(name)-15s %(levelname)-8s %(message)s', level = logging.DEBUG)

    plot_tophits(filename)
Beispiel #25
0
def main():
    
    # Basic option parsing 
    p = OptionParser()
    p.set_usage('fits_pattern_viewer.py [filename] [options]')
    p.set_description(__doc__)
    (options, args) = p.parse_args()

    print "Starting %s..."%progname
    global main_gui
    app = QtGui.QApplication(sys.argv)
    
    try:
        filename = args[0]
        main_gui = InterFitsGui(filename, save_autos=False)
    except:
        main_gui = InterFitsGui()
    app.exec_()
    sys.exit()    
def main():
	parser = OptionParser()
	parser.set_usage(parser.get_prog_name() + " -a exp1.searchConfig.xml exp2.searchConfig\n" 
				+ " OR " + parser.get_prog_name() + " -m exp1.YYY.csv exp2.YYY.csv [...]")
	parser.set_description("""Combines BehaviorSearch .csv files (that were created using the same search configuration.)

In -a (auto mode), it will use the *.searchConfig.xml files you specify to find all of the matching CSV search results files, and combine them
into a new file, named based on the common filename stem of the combined files. (i.e. the files: xxxx_00.yyy.csv, xxxx_01.yyy.csv,  => xxxx.yyy.csv)

In -m (manual mode), only those CSV files that you manually specify will be combined, and the results will go to stdout.
(Note that you can specify wildcards, such as "data*.xml") 
""")
	parser.add_option("-m", "--manual", action="store_true", dest="manual", help="manual mode")
	parser.add_option("-a", "--autosort", action="store_true", dest="autosort", help="(auto-sort mode) use XXX.searchConfig.xml files to automatically choose which CSV files should be combined.")
	parser.add_option("-p", "--preserve", action="store_true", dest="preserve", help="keep the original search number indexes, instead of renumbering consecutively.")
	parser.add_option("-d", "--delete", action="store_true", dest="delete", help="delete the input files, after combining")

	options , filepatterns = parser.parse_args()
	if (options.manual == options.autosort):
		print "ERROR: You must specify EITHER -m (manual) or -a (autosort) mode."
		print
		parser.print_help()
		sys.exit(0)

	if (len(filepatterns) == 0):
		parser.print_help()
		sys.exit(0)
		
	filenames = []
	for fPat in filepatterns:
		filenames.extend(glob.glob(fPat))
	
	filenames = uniq(filenames)
	
	if (len(filenames) < 1):
		parser.print_help()
		sys.exit(1)

	if (options.autosort):
		autosort_and_combine(filenames, options.preserve, options.delete)
	else: # (options.manual == True)
		combine(filenames, options.preserve, options.delete, sys.stdout)
Beispiel #27
0
def get_parser():
    """return an OptionParser object for TracLegos"""

    parser = OptionParser()

    # command line parser options
    parser.add_option("-c", "--conf",
                      dest="conf", action="append", default=[],
                      help="site configuration files")
    parser.add_option("-d", "--directory",
                      dest="directory", default=".",
                      help="trac projects directory")
    parser.add_option("-i", "--inherit", dest="inherit", default=None,
                      help=".ini file to inherit from")
    parser.add_option("-s", "--repository",  dest="repository",
                      help="repository type to use")
    parser.add_option("-t", dest="templates", action="append", default=[],
                      help="trac.ini templates to be applied in order")
    parser.add_option("--db", "--database",
                      dest="database", default=None,
                      help="database type to use")
    parser.add_option("-w", "--wiki", dest="wiki",
                      action="append", default=[],
                      help="directories containing Trac wiki pages to import")

    # options to yield information
    parser.add_option("--list-templates", dest="listprojects",
                      action="store_true", default=False,
                      help="list available TracProject PasteScript templates")
    parser.add_option("--list-repositories", dest="listrepositories",
                      action="store_true", default=False,
                      help="list repository types available for setup by TracLegos")
    parser.add_option("--list-databases", dest="listdatabases",
                      action="store_true", default=False,
                      help="list available database types available for setup by TracLegos")
    parser.add_option("--list-variables", dest="printmissing",
                      action="store_true", default=False,
                      help="print variable names missing for a given configuration")

    parser.set_usage("%prog [options] project <project2> <...> var1=1 var2=2 ...")
    parser.set_description("assemble a trac project from components")
    return parser
Beispiel #28
0
def get_options():
    ##### Configuration options #####

    usage = """usage: %prog [options] ics_file [timezone]"""
    parser = OptionParser(usage=usage, version=version)
    parser.set_description("change_tz will convert the timezones in an ics file. ")

    parser.add_option(
        "-u", "--only-utc", dest="utc", action="store_true", default=False, help="Only change UTC events."
    )
    parser.add_option("-l", "--list", dest="list", action="store_true", default=False, help="List available timezones")

    (cmdline_options, args) = parser.parse_args()
    if not args and not cmdline_options.list:
        print "error: too few arguments given"
        print
        print parser.format_help()
        return False, False

    return cmdline_options, args
Beispiel #29
0
def convert_main():
    from optparse import OptionParser
    parser = OptionParser()
    parser.set_description(
        "Reads a ZODB Filestorage file and creates a new Durus "
        "FileStorage file containing the same current object records.")
    parser.add_option(
        '--zodb_file', dest="zodb_file", 
        help="The ZODB FileStorage to convert.")
    parser.add_option(
        '--durus_file', dest="durus_file",
        help=("The Durus FileStorage to create. "
              "This file will be overwritten if it already exists, "
              "so be careful."))
    (options, args) = parser.parse_args()
    if (options.zodb_file and options.durus_file and
        options.zodb_file != options.durus_file):
        convert(options.zodb_file, options.durus_file)
    else:
        parser.print_help()
Beispiel #30
0
def pack_storage_main():
    parser = OptionParser()
    parser.set_description("Packs a Durus storage.")
    parser.add_option(
        '--file', dest="file", default=None,
        help="If this is not given, the storage is through a Durus server.")
    parser.add_option(
        '--port', dest="port", default=DEFAULT_PORT,
        type="int",
        help="Port the server is on. (default=%s)" % DEFAULT_PORT)
    parser.add_option(
        '--host', dest="host", default=DEFAULT_HOST,
        help="Host of the server. (default=%s)" % DEFAULT_HOST)
    (options, args) = parser.parse_args()
    if options.file is None:
        wait_for_server(options.host, options.port)
        storage = ClientStorage(host=options.host, port=options.port)
    else:
        storage = get_storage(options.file)
    connection = Connection(storage)
    connection.pack()