Beispiel #1
1
def parse_options():
    global g_verbose

    parser = OptionParser(usage='usage: %prog [options] <ssh-server>[:<server-port>]',
                          version='%prog 1.0', description=HELP)
    parser.add_option('-q', '--quiet', action='store_false', dest='verbose', default=True,
                      help='squelch all informational output')
    parser.add_option('-p', '--remote-port', action='store', type='int', dest='port',
                      default=DEFAULT_PORT,
                      help='port on server to forward (default: %d)' % DEFAULT_PORT)
    parser.add_option('-u', '--user', action='store', type='string', dest='user',
                      default=getpass.getuser(),
                      help='username for SSH authentication (default: %s)' % getpass.getuser())
    parser.add_option('-K', '--key', action='store', type='string', dest='keyfile',
                      default=None,
                      help='private key file to use for SSH authentication')
    parser.add_option('', '--no-key', action='store_false', dest='look_for_keys', default=True,
                      help='don\'t look for or use a private key file')
    parser.add_option('-P', '--password', action='store_true', dest='readpass', default=False,
                      help='read password (for key or password auth) from stdin')
    parser.add_option('-r', '--remote', action='store', type='string', dest='remote', default=None, metavar='host:port',
                      help='remote host and port to forward to')
    options, args = parser.parse_args()

    if len(args) != 1:
        parser.error('Incorrect number of arguments.')
    if options.remote is None:
        parser.error('Remote address required (-r).')

    g_verbose = options.verbose
    server_host, server_port = get_host_port(args[0], SSH_PORT)
    remote_host, remote_port = get_host_port(options.remote, SSH_PORT)
    return options, (server_host, server_port), (remote_host, remote_port)
Beispiel #2
0
def main () :

    usage =  "./app/python/arc2warc.py  [OPTIONS] ARC-FILES "
             
 
    parser = OptionParser(usage)

    parser.add_option("-c", "--compressed", dest="cmode",
                      action="store_true", help="compressed outpout  WARC FILE")
    parser.add_option("-t", "--tempdir", dest="tmpdir",
                      help="Temporary working directory", default="./")
    parser.add_option("-v","--verbose",
                                action="store_true",dest="verbose" , default=False,
                                help="print more information")                        

    (options, args) = parser.parse_args()


    if not ( len (args) > 0 ):
       parser.error(" Please give one or more arcs to convert")


    for fname in args:
        ofname = guessname( fname , options.cmode )
        if options.verbose:
            print 'Converting %s to %s' % ( fname , ofname )            
        convert( fname , ofname , options.tmpdir , options.cmode )
        if options.verbose:
            print 'Done'    
        



  
    return
Beispiel #3
0
def _parseArgs():
  helpString = (
    "This script scrubs data-path profiling info from YOMP service logs on "
    "the local host and emits a CSV file to STDOUT.\n"
    "%prog"
  )

  parser = OptionParser(helpString)

  parser.add_option(
    "--logdir",
    action="store",
    type="str",
    default=logging_support.LoggingSupport.getLoggingRootDir(),
    dest="logDir",
    help=("Logging root directory path override. [default: %default]\n"))

  (options, posArgs) = parser.parse_args()

  if len(posArgs) != 0:
    parser.error("Expected no positional args, but got %s: %s" % (
                 len(posArgs), posArgs,))

  if not os.path.isdir(options.logDir):
    parser.error("Log directory doesn't exist or is not a directory: %r"
                 % (options.logDir,))

  return {
    "logDir": options.logDir
  }
Beispiel #4
0
    def __init__(self):

        self.__options = None

        parser = OptionParser(
            usage="%prog [-v] [-q] [-d] [-f] [-g] [-c config_file]",
            version="OSSIM (Open Source Security Information Management) " + \
                      "- Agent ")

        parser.add_option("-v", "--verbose", dest="verbose",
                          action="count",
                          help="verbose mode, makes lot of noise")
        parser.add_option("-d", "--daemon", dest="daemon", action="store_true",
                          help="Run agent in daemon mode")
        parser.add_option("-f", "--force", dest="force", action="store_true",
                          help="Force startup overriding pidfile")
        parser.add_option("-s", "--stats", dest="stats", type='choice', choices=['all', 'clients', 'plugins'], default=None,
                          help="Get stats about the agent")
        parser.add_option("-c", "--config", dest="config_file", action="store",
                          help="read config from FILE", metavar="FILE")
        (self.__options, args) = parser.parse_args()

        if len(args) > 1:
            parser.error("incorrect number of arguments")

        if self.__options.verbose and self.__options.daemon:
            parser.error("incompatible options -v -d")
Beispiel #5
0
def main():
    p = OptionParser()
    options, args = p.parse_args()

    if len(args) != 1:
        p.error("no valid directory given")

    inp = args[0]
    outp = inp + ".npz"

    files = []
    for dirpath, dirnames, filenames in os.walk(inp):
        for fn in filenames:
            if fn.endswith('.txt'):
                files.append(
                    (dirpath[len(inp)+1:] + '/' + fn[:-4],
                     os.path.join(dirpath, fn)))

    data = {}
    for key, fn in files:
        key = key.replace('/', '-').strip('-')
        try:
            data[key] = np.loadtxt(fn)
        except ValueError:
            print("Failed to load", fn)

    savez_compress(outp, **data)
Beispiel #6
0
def main():
    usage = "usage: %prog [options] [broker-url]"
    epilog = """\
The worker needs Filetracker server configured. If no FILETRACKER_URL is
present in the environment, a sensible default is generated, using the same
host as the Celery broker uses, with default Filetracker port."""
    parser = OptionParser(usage=usage, epilog=epilog)
    parser.disable_interspersed_args()

    os.environ.setdefault('CELERY_CONFIG_MODULE', 'sio.celery.default_config')
    app = Celery()
    cmd = WorkerCommand(app)
    for x in cmd.get_options():
        parser.add_option(x)

    options, args = parser.parse_args()

    if len(args) > 1:
        parser.error("Unexpected arguments: " + ' '.join(args[1:]))
    if args:
        broker_url = args[0]
        os.environ['CELERY_BROKER_URL'] = args[0]

    if 'FILETRACKER_URL' not in os.environ:
        default_filetracker_host = None
        if 'CELERY_BROKER_URL' in os.environ:
            default_filetracker_host = \
                    _host_from_url(os.environ['CELERY_BROKER_URL'])
        if not default_filetracker_host:
            default_filetracker_host = '127.0.0.1'
        os.environ['FILETRACKER_URL'] = 'http://%s:%d' \
                % (default_filetracker_host, DEFAULT_FILETRACKER_PORT)

    return cmd.run(**vars(options))
Beispiel #7
0
def main(argv=sys.argv):
    logging.basicConfig()
    log.setLevel(logging.INFO)

    parser = OptionParser(
        description="Generate some statistics about Karl usage",
        usage="%prog [options]",
        )

    parser.add_option('-C', '--config', dest='config', default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    options, args = parser.parse_args()

    if len(args):
        parser.error("Command does not take arguments.")

    config = options.config
    if not config:
        config = get_default_config()
    root, closer = open_root(config)

    try:
        gen_stats(root)
    finally:
        transaction.abort()
Beispiel #8
0
def arguments_parse():
    """Handle the command line arguments."""
    parser = OptionParser(usage='usage: %prog [options] arguments')
    parser.add_option('-f', '--file',
                      dest='filename',
                      metavar='FILE',
                      help='specify the input XML testcase file for testing (REQUIRED)')
    parser.add_option('-p', '--packages',
                      dest='custompackages',
                      metavar='FILE',
                      help='specify the input file for custom package processing')
    parser.add_option('-o', '--out',
                      dest='allpackages',
                      metavar='FILE',
                      help='specify the output file to print the list of packages in the input XML')
    (options, args) = parser.parse_args()
    # If no arguments are passed just print the help message
    if options.filename is None:
        print colorize("The input file (specified by the '-f' option) is mandatory.", 'red')
        parser.print_help()
        sys.exit(1)
    if len(args) != 0:
        parser.error('Invalid number of arguments.')
        sys.exit(1)
    # Either call -p or -o, but not both
    if options.custompackages and options.allpackages:
        print colorize("Error: Specify either the '-p' or the '-o' option, but not both.", 'red')
        sys.exit(1)
    # Since both cannot be true, check which is and return accordingly
    return options.filename, options.custompackages, options.allpackages
Beispiel #9
0
def command_line_run(args_in):
    """ Runs everything needed to execute from the command line, so main method is callable without arg parsing """
    parser = OptionParser(usage="usage: %prog base_url test_filename.yaml [options] ")
    parser.add_option(u"--print-bodies", help="Print all response bodies", action="store", type="string", dest="print_bodies")
    parser.add_option(u"--log", help="Logging level", action="store", type="string")
    parser.add_option(u"--interactive", help="Interactive mode", action="store", type="string")
    parser.add_option(u"--url", help="Base URL to run tests against", action="store", type="string")
    parser.add_option(u"--test", help="Test file to use", action="store", type="string")
    parser.add_option(u'--import_extensions', help='Extensions to import, separated by semicolons', action="store", type="string")
    parser.add_option(u'--vars', help='Variables to set, as a YAML dictionary', action="store", type="string")
    parser.add_option(u'--verbose', help='Put cURL into verbose mode for extra debugging power', action='store_true', default=False, dest="verbose")
    parser.add_option(u'--ssl-insecure', help='Disable cURL host and peer cert verification', action='store_true', default=False, dest="ssl_insecure")
    parser.add_option(u'--absolute-urls', help='Enable absolute URLs in tests instead of relative paths', action="store_true", dest="absolute_urls")

    (args, unparsed_args) = parser.parse_args(args_in)
    args = vars(args)

    # Handle url/test as named, or, failing that, positional arguments
    if not args['url'] or not args['test']:
        if len(unparsed_args) == 2:
            args[u'url'] = unparsed_args[0]
            args[u'test'] = unparsed_args[1]
        elif len(unparsed_args) == 1 and args['url']:
            args['test'] = unparsed_args[0]
        elif len(unparsed_args) == 1 and args['test']:
            args['url'] = unparsed_args[0]
        else:
            parser.print_help()
            parser.error("wrong number of arguments, need both url and test filename, either as 1st and 2nd parameters or via --url and --test")

    args['cwd'] = os.path.realpath(os.path.abspath(os.getcwd()))  # So modules can be loaded from current folder
    main(args)
Beispiel #10
0
def pyres_worker():
    usage = "usage: %prog [options] arg1"
    parser = OptionParser(usage=usage)

    parser.add_option("--host", dest="host", default="localhost")
    parser.add_option("--port",dest="port",type="int", default=6379)
    parser.add_option("-i", '--interval', dest='interval', default=None, help='the default time interval to sleep between runs')
    parser.add_option('-l', '--log-level', dest='log_level', default='info', help='log level.  Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.')
    parser.add_option('-f', dest='logfile', help='If present, a logfile will be used.  "stderr", "stdout", and "syslog" are all special values.')
    parser.add_option('-p', dest='pidfile', help='If present, a pidfile will be used.')
    (options,args) = parser.parse_args()

    if len(args) != 1:
        parser.print_help()
        parser.error("Argument must be a comma seperated list of queues")

    log_level = getattr(logging, options.log_level.upper(), 'INFO')
    setup_logging(procname="pyres_worker", log_level=log_level, filename=options.logfile)
    setup_pidfile(options.pidfile)

    interval = options.interval
    if interval is not None:
        interval = int(interval)

    queues = args[0].split(',')
    server = '%s:%s' % (options.host,options.port)
    Worker.run(queues, server, interval)
Beispiel #11
0
def pyres_manager():
    usage = "usage: %prog [options] arg1"
    parser = OptionParser(usage=usage)
    #parser.add_option("-q", dest="queue_list")
    parser.add_option("--host", dest="host", default="localhost")
    parser.add_option("--port",dest="port",type="int", default=6379)
    parser.add_option("-i", '--interval', dest='interval', default=None, help='the default time interval to sleep between runs')
    parser.add_option('-l', '--log-level', dest='log_level', default='info', help='log level.  Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.')
    parser.add_option("--pool", type="int", dest="pool_size", default=1, help="Number of minions to spawn under the manager.")
    parser.add_option('-f', dest='logfile', help='If present, a logfile will be used.  "stderr", "stdout", and "syslog" are all special values.')
    parser.add_option('-p', dest='pidfile', help='If present, a pidfile will be used.')
    (options,args) = parser.parse_args()

    if len(args) != 1:
        parser.print_help()
        parser.error("Argument must be a comma seperated list of queues")

    log_level = getattr(logging, options.log_level.upper(), 'INFO')
    #logging.basicConfig(level=log_level, format="%(asctime)s: %(levelname)s: %(message)s")

    setup_pidfile(options.pidfile)

    interval = options.interval
    if interval is not None:
        interval = float(interval)

    queues = args[0].split(',')
    server = '%s:%s' % (options.host,options.port)
    Khan.run(pool_size=options.pool_size, queues=queues, server=server, logging_level=log_level, log_file=options.logfile)
Beispiel #12
0
def main(myArgs):
    parser = OptionParser()
    parser.add_option("-b", help="server ip address")
    parser.add_option("-i", help="node id")
    (options, args) = parser.parse_args()
    if options.i is None:
        parser.error(helper())
    nodeid = options.i
    if options.b is None:
        parser.error(helper())
    server = options.b

    serverStrip(server)

    cfg = ConfigParser.RawConfigParser()
    cfg.read('key.cfg')      
    key=dict(cfg.items("Keys"))
    for x in key:
        key[x]=key[x].split("#",1)[0].strip() 
    globals().update(key)  
    
    nodeId = nodeid
    accessKey = accesskey
    secretKey = secretkey

    serverUrl2 = "/api/node/" + nodeId + "/usage"

    headerValue = {}
    headerValue["Accept"] = 'application/json' 
    headerValue["Content-Type"] = 'application/json'

    r = Api.REST(secretKey=secretKey, accessKey=accessKey, url=serverUrl)
    
    serverCheck(serverName, headerValue, r, serverPort, serverUrl2)
Beispiel #13
0
def main():
    from optparse import OptionParser
    parser = OptionParser(usage="usage: %prog [options] channels")

    # IRC connection options
    parser.add_option("-s", "--server",
                      action="store", dest="server",
                      default="irc.freenode.net",
                      help="IRC server to connect to")
    parser.add_option("-p", "--port",
                      action="store", type="int", dest="port", default=None,
                      help="IRC server to connect to")
    parser.add_option("--ssl",
                      action="store_true", dest="ssl", default=False,
                      help="use SSL")
    parser.add_option("--password",
                      action="store", dest="password", default=None,
                      help="server password")
    parser.add_option("-n", "--nick",
                      action="store", dest="nick", default="karmabot",
                      help="nickname to use")
    # Bot options
    parser.add_option("-v", "--verbose",
                      action="store_true", dest="verbose", default=False,
                      help="enable verbose output")
    parser.add_option("-d", "--data",
                      action="store", dest="filename", default="karma.json",
                      help="karma data file name")
    parser.add_option("-t", "--trust",
                      action="append", dest="trusted", default=[],
                      help="trusted hostmasks")
    parser.add_option("-f", "--facets",
                      action="append", dest="facets", default=[],
                      help="additional facets to load")

    (options, channels) = parser.parse_args()

    if not channels:
        parser.error("You must supply some channels to join.")
    else:
        log.msg("Channels to join: %s" % channels)

    if options.verbose:
        log.startLogging(sys.stdout)

    if not options.port:
        options.port = 6667 if not options.ssl else 9999
    
    # FIXME: this needs to be replaced with a real facet manager
    for facet_path in options.facets:
        execfile(facet_path, globals())

    factory = KarmaBotFactory(options.filename, options.nick,
                              channels, options.trusted, options.password)
    if not options.ssl:
        reactor.connectTCP(options.server, options.port, factory)
    else:
        reactor.connectSSL(options.server, options.port,
                           factory, ssl.ClientContextFactory())
    reactor.run()
def standalone_main():
   from optparse import OptionParser

   # Load command line options
   parser = OptionParser(usage="usage: %prog <spectra> <dispersion_in>...")

   parser.add_option( "-o", "--output_file", dest="output_file",
                      metavar="FILE",
                      default='./new_dispersion.dat',
                      help="where to write dispersion file other than default")

   parser.add_option( "-s", "--sounding_id", dest="sounding_id",
                      metavar="ID",
                      help="sounding id of dispersion information")

   parser.add_option( "-z", "--zero_indexing", dest="zero_indexing",
                      action="store_true",
                      help="force zero base indexing")

   # Parse command line arguments
   (options, args) = parser.parse_args()

   if (len(args) < 2):
      parser.error('Must supply spectra filename and dispersion input filename')

   l1b_file     = args[0]
   disp_in_file = args[1]

   if options.zero_indexing:
      index_scheme = 0
   else:
      index_scheme = 1

   create_dispersion_from_ascii(l1b_file, options.output_file, disp_in_file, options.sounding_id, index_scheme)
Beispiel #15
0
def main():
    from clang.cindex import Index
    from pprint import pprint

    from optparse import OptionParser, OptionGroup

    global opts

    parser = OptionParser("usage: %prog [options] {filename} [clang-args*]")
    parser.add_option("", "--show-ids", dest="showIDs",
                      help="Don't compute cursor IDs (very slow)",
                      default=False)
    parser.add_option("", "--max-depth", dest="maxDepth",
                      help="Limit cursor expansion to depth N",
                      metavar="N", type=int, default=None)
    parser.disable_interspersed_args()
    (opts, args) = parser.parse_args()

    if len(args) == 0:
        parser.error('invalid number arguments')

    index = Index.create()
    tu = index.parse(None, args)
    if not tu:
        parser.error("unable to load input")

    pprint(('diags', map(get_diag_info, tu.diagnostics)))
    pprint(('nodes', get_info(tu.cursor)))
Beispiel #16
0
def main():
    from optparse import OptionParser
    parser = OptionParser() #usage=usage)
    parser.add_option("-v", "--verbose", action="count", help="Increment test verbosity (can be used multiple times)")
    parser.add_option("-d", "--debug", action="store_true", default=False, help="Print debugging items")
    parser.add_option("-t", "--test", help="Run only the named test")

    (options, args) = parser.parse_args()

    if args:
        parser.error('no arguments expected')
    
    global CNXNSTRING

    path = dirname(abspath(__file__))
    filename = join(path, 'test.xls')
    assert os.path.exists(filename)
    CNXNSTRING = 'Driver={Microsoft Excel Driver (*.xls)};DBQ=%s;READONLY=FALSE' % filename

    cnxn = pyodbc.connect(CNXNSTRING, autocommit=True)
    print_library_info(cnxn)
    cnxn.close()

    suite = load_tests(ExcelTestCase, options.test)

    testRunner = unittest.TextTestRunner(verbosity=options.verbose)
    result = testRunner.run(suite)
def main(): #IGNORE:R0911
    """ Creates installers for selected platforms. """
    parser = OptionParser("%prog <blast_version> <platform> <installation directory>")
    parser.add_option("-v", "--verbose", action="store_true", default=False,
                      help="Show verbose output", dest="VERBOSE")
    options, args = parser.parse_args()
    if len(args) != 3:
        parser.error("Incorrect number of arguments")
        return 1

    blast_version, platform, installdir = args

    global VERBOSE #IGNORE:W0603
    VERBOSE = options.VERBOSE
    if VERBOSE:
        print "BLAST version", blast_version
        print "Platform:", platform
        print "Installation directory:", installdir

    if platform.startswith("Win"):
        return launch_win_installer_build(installdir, blast_version)                
    if platform.startswith("Linux"):
        return launch_rpm_build(installdir, blast_version)
    if platform == "FreeBSD32" or platform.startswith("SunOS"):
        return do_nothing(platform)
    if platform == "IntelMAC":
        return mac_post_build(installdir, blast_version)
    
    print >> sys.stderr, "Unknown OS identifier: " + platform
    print >> sys.stderr, "Exiting post build script."
    return 2
Beispiel #18
0
def main():
  parser = OptionParser(usage="%prog input.js output.js")
  parser.add_option('-i', '--inplace', action='store_true', default=False, dest='inplace', help='overwrite existing file')
  parser.add_option('-v', '--verbose', action='store_true', default=False, dest='verbose', help='generate verbose output')

  opts, args = parser.parse_args()

  if len(args) < 1:
    if opts.inplace:
      parser.error("No input file for in-place modification")
    inpfl = sys.stdin
  else:
    if not os.path.isfile(args[0]):
      parser.error("Input file not found: %s" % args[0])
    inpfl = open(args[0], 'r')

  if len(args) < 2:
    if not opts.inplace:
      outfl = sys.stdout
  else:
    outfl = open(args[1], 'w')

  if opts.inplace:
    convertInplace(inpfl)
  else:
    convert(inpfl, outfl)
Beispiel #19
0
def do_tag(bopts, bargs):
    """
    dock-pulp tag [options] repo-id image-id tags,with,commas
    dock-pulp tag [options] --remove repo-id image-id
    Tag an image with a tag in a repo"""
    parser = OptionParser(usage=do_tag.__doc__)
    parser.add_option('-r', '--remove', action='store_true', default=False,
        help='remove any tags associated with the image instead')
    opts, args = parser.parse_args(bargs)
    if opts.remove and len(args) != 2:
        parser.error(
            'You must provide a repo and image-id with --remove')
    elif not opts.remove and len(args) != 3:
        parser.error(
            'You must provide a repo, image-id, and comma-separated tags')
    p = pulp_login(bopts)
    # check that the image exists in the repository
    repoinfo = p.listRepos(args[0], content=True)[0]
    if args[1] not in repoinfo['images']:
        log.error('%s does not exist in %s' % (args[1], args[0]))
        sys.exit(1)
    if opts.remove:
        update = {'tag': ':%s' % args[1]}
    else:
        update = {'tag': '%s:%s' % (args[2], args[1])}
    # tags are repository attributes
    p.updateRepo(args[0], update)
    log.info('tagging successful')
Beispiel #20
0
def command_line():
    p = OptionParser()
    p.add_option('-H', '--host', dest='host', action='store',
                 help='IMAP host connect to')
    p.add_option('-u', '--username', dest='username', action='store',
                 help='Username to login with')
    p.add_option('-p', '--password', dest='password', action='store',
                 help='Password to login with')
    p.add_option('-P', '--port', dest='port', action='store', type=int,
                 default=None,
                 help='IMAP port to use (default is 143, or 993 for SSL)')
    p.add_option('-s', '--ssl', dest='ssl', action='store_true', default=False,
                 help='Use SSL connection')
    p.add_option('-f', '--file', dest='file', action='store', default=None,
                 help='Config file (same as livetest)')

    opts, args = p.parse_args()
    if args:
        p.error('unexpected arguments %s' % ' '.join(args))

    if opts.file:
        if opts.host or opts.username or opts.password or opts.port or opts.ssl:
            p.error('If -f/--file is given no other options can be used')
        # Use the options in the config file
        opts = parse_config_file(opts.file)
    else:
        # Get compulsory options if not given on the command line
        for opt_name in ('host', 'username', 'password'):
            if not getattr(opts, opt_name):
                setattr(opts, opt_name, getpass(opt_name + ': '))
        # Options not supported on the command line
        opts.oauth = False
        opts.oauth2 = False
        opts.stream = False
    return opts
Beispiel #21
0
def do_update(bopts, bargs):
    """
    dock-pulp update [options] repo-id [repo-id...]
    Update metadata for a docker image repository"""
    parser = OptionParser(usage=do_update.__doc__)
    parser.add_option('-d', '--description',
        help='update the description for this repository')
    parser.add_option('-i', '--dockerid',
        help='set the docker ID (name) for this repo')
    parser.add_option('-r', '--redirect', help='set the redirect URL')
    parser.add_option('-t', '--title', help='set the title (short desc)')
    opts, args = parser.parse_args(bargs)
    if len(args) < 1:
        parser.error('You must specify a repo ID (not the docker name)')
    p = pulp_login(bopts)
    updates = {}
    if opts.description:
        updates['description'] = opts.description
    if opts.dockerid:
        updates['repo-registry-id'] = opts.dockerid
    if opts.redirect:
        updates['redirect-url'] = opts.redirect
    if opts.title:
        updates['display_name'] = opts.title
    for repo in args:
        p.updateRepo(repo, updates)
        log.info('repo successfully updated')
Beispiel #22
0
def main():
    try:
        cpus = multiprocessing.cpu_count()
    except NotImplementedError:
        cpus = 1
    parser = OptionParser(usage=helptext)
    parser.add_option("-p", "--processes", dest="procs", help="How many chunks to render in parallel. A good number for this is the number of cores in your computer. Default %s" % cpus, default=cpus, action="store", type="int")
    parser.add_option("-z", "--zoom", dest="zoom", help="Sets the zoom level manually instead of calculating it. This can be useful if you have outlier chunks that make your world too big. This value will make the highest zoom level contain (2**ZOOM)^2 tiles", action="store", type="int")
    parser.add_option("-d", "--delete", dest="delete", help="Clear all caches. Next time you render your world, it will have to start completely over again. This is probably not a good idea for large worlds. Use this if you change texture packs and want to re-render everything.", action="store_true")

    options, args = parser.parse_args()

    if len(args) < 1:
        print "You need to give me your world directory"
        parser.print_help()
        sys.exit(1)
    worlddir = args[0]

    if len(args) != 2:
        parser.error("Where do you want to save the tiles?")
    destdir = args[1]

    if options.delete:
        return delete_all(worlddir, destdir)

    # First generate the world's chunk images
    w = world.WorldRenderer(worlddir)
    w.go(options.procs)

    # Now generate the tiles
    q = quadtree.QuadtreeGen(w, destdir, depth=options.zoom)
    q.go(options.procs)
def main():
    usage = "usage: %prog [options] calendar.ics"
    version = "%prog 0.1"
    parser = OptionParser(usage=usage, version=version, description=__doc__)

    parser.add_option("-l", "--label", dest="label", default=u"Rapport d\'activite", 
                      help=u"Titre à faire apparaitre sur le rapport")
    parser.add_option("-r", "--ref-facture", dest="ref_facture", default=u"Référence facture", 
                      help=u"Titre à faire apparaitre sur le rapport")
    parser.add_option("-d", "--date-debut", dest="date_debut", 
                      help=u"date de début de la période au format jj/mm/aaaa.")
    parser.add_option("-f", "--date-fin", dest="date_fin", 
                      help=u"date de fin de la période au format jj/mm/aaaa.")

    (options, args) = parser.parse_args()

    if len(args) != 1:
        parser.error(u"Vous devez passer en argument le chemin d'un calendrier "
                     u"iCal.")
    else:
        from colbert.rapports import rapport_activite
        sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) 

        date_debut = datetime.datetime.strptime(options.date_debut, DATE_FMT).date()
        date_fin = datetime.datetime.strptime(options.date_fin, DATE_FMT).date()
        calendrier = open(args[0], mode="r")
        rapport = rapport_activite(calendrier, 
                                   date_debut,
                                   date_fin,
                                   options.label,
                                   options.ref_facture)

        json.dump(rapport, sys.stdout, default=json_encoder, indent=4)
Beispiel #24
0
def main():

    url = "cmsweb.cern.ch"
    testbed_url = "https://cmsweb-testbed.cern.ch"
    # url = 'https://alan-cloud1.cern.ch'

    # Create option parser
    usage = "usage: %prog [options] [WORKFLOW]"
    parser = OptionParser(usage=usage)
    parser.add_option("-f", "--file", dest="file", default=None, help="Text file of a list of workflows")
    parser.add_option(
        "-m", "--memory", dest="memory", default=None, help="Memory to override the original request memory"
    )

    (options, args) = parser.parse_args()

    wfs = None
    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
    elif args:
        wfs = args
    else:
        parser.error("Provide the Workflow Name")
        sys.exit(1)

    for wf in wfs:
        acdcs = makeAllACDCs(url, wf)
        print "created acdcs"
        print "\n".join(acdcs)
Beispiel #25
0
def parse_commandline():
    usage = "usage: %prog source"
    parser = OptionParser(usage=usage)
    opts,args = parser.parse_args()
    if args == []:
        parser.error("you must supply an URL to crawl")
    return parser
Beispiel #26
0
def main():

    parser = OptionParser()
    parser.add_option("-s", "--sim_id", dest="sim_id", type="string", help="simulation id")
    parser.add_option("-d", "--sim_dirs", dest="sim_dirs", type="string", action="append", help="simulation directories")
    parser.add_option("-b", "--bam_fname", dest="bam_fname", type="string", help="name of the simulated bam file")
    parser.add_option("-o", "--out_dir", dest="out_dir", type="string", help="main output directory")
    parser.add_option("-c", "--config_template", dest="config_template", type="string", help="template file for config.txt")
    (options, args) = parser.parse_args()

    if options.sim_dirs is None and options.sim_id is None:
        parser.error("Specify simulation id or simulation directories")
    if options.sim_dirs is not None and options.sim_id is not None:
        parser.error("Simulation id and simulation directories are mutually exclusive options")
    if options.sim_dirs is not None:
        bam_dirs = options.sim_dirs
    if options.sim_id is not None:
        sim_dir = "/illumina/scratch/tmp/users/ccolombo/simulation/"
        print "Looking for simulation directories in: " + sim_dir
        bam_dirs = [sim_dir + dir for dir in os.listdir(sim_dir) if re.search("sim" + options.sim_id + ".*", dir)]
        if len(bam_dirs) == 0:
            print "No simulation directories found"
    if options.bam_fname is None:
        options.bam_fname = "sorted_Proteus_LP6007590_LP6007591_som_var.bam"
        print "Using default name for simulated bam: " + options.bam_fname
    if options.out_dir is None or not os.path.exists(options.out_dir):
        options.out_dir = "/illumina/build/CNA/CNV/haplotype_simulation/FREEC/"
        print "Using default output directory: " + options.out_dir
    if options.config_template is None or not os.path.exists(options.config_template):
        options.config_template = "/illumina/build/CNA/CNV/haplotype_simulation/FREEC/config_template.txt"
        print "Using default configuration template file: " + options.config_template

    run_FREEC(bam_dirs, options.out_dir, options.bam_fname, options.config_template)
Beispiel #27
0
def main():
    usage = 'usage: %prog [options] <counts file>'
    parser = OptionParser(usage)
    parser.add_option('--int', dest='count_kmers', action='store_true', default=False, help='Kmers were counted as integers w/o the use of quality values [default: %default]')
    parser.add_option('--ratio', dest='ratio', type='int', default=200, help='Likelihood ratio to set trusted/untrusted cutoff [default: %default]')
    parser.add_option('--no_sample', dest='no_sample', action='store_true', default=False, help='Do not sample kmer coverages into kmers.txt because its already done [default: %default]')
    # help='Model kmer coverage as a function of GC content of kmers [default: %default]'
    parser.add_option('--gc', dest='model_gc', action='store_true', default=False, help=SUPPRESS_HELP)
    (options, args) = parser.parse_args()

    if len(args) != 1:
        parser.error('Must provide kmers counts file')
    else:
        ctsf = args[0]

    if options.count_kmers:
        model_cutoff(ctsf, options.ratio)
        print 'Cutoff: %s' % open('cutoff.txt').readline().rstrip()
        
    else:
        if options.model_gc:
            model_q_gc_cutoffs(ctsf, 25000, options.ratio)
        else:
            model_q_cutoff(ctsf, 50000, options.ratio, options.no_sample)
            if os.path.isfile('cutoff.txt'):
                print 'Cutoff: %s' % open('cutoff.txt').readline().rstrip()
            else:
                print >> sys.stderr, 'Optimization of distribution likelihood function to choose k-mer cutoff failed. Inspect the k-mer counts for a clear separation of the error and true k-mer distributions.'
                exit(1)
Beispiel #28
0
def parse_options(argv):
  usage_str = "usage: %prog options domain\n\n" \
    "Hunt domain for URLs, subdomains and emails:\n" \
    "$ %prog -u -s -e example.com\n\n" \
    "Hunt for emails using only Google, a more specific query, and a valid Cookie to bypass anti-bot captcha:\n" \
    "$ %prog -e -p google -x 'google|query|-inurl:index.php example.com' -x 'google|headers|Cookie: GDSESS=..' example.com\n\n" \
    "Hunt for subdomains using only Bing and a specific search:\n" \
    "$ %prog -s -p bing -x 'bing|query|ip:1.2.3.4' example.com\n\n" \
    "Both search engines support the filetype operator:\n" \
    "$ %prog -u -x 'bing,google|query|example.com -filetype:pdf' example.com"

  parser = OptionParser(usage=usage_str)

  parser.add_option('-u', dest='hunt_url', action='store_true', default=False, help='hunt for URLs')
  parser.add_option('-s', dest='hunt_subdomain', action='store_true', default=False, help='hunt for subdomains')
  parser.add_option('-e', dest='hunt_email', action='store_true', default=False, help='hunt for emails')
  parser.add_option('-p', dest='plugins', metavar='id,id2 ...', help='only run specific plugins (default is to run all plugins, each plugin in a separate thread)')
  parser.add_option('-x', dest='extra', action='append', metavar='id|param|val', help='use plugin specific parameters')
  parser.add_option('--debug', dest='debug', action='store_true', default=False, help='print debugging information')

  # TODO to implement...
  #parser.add_option('-l', dest='pluginlist', action='store_true', help='list all available plugins')
  #parser.add_option('-q', dest='pluginusage', metavar='id', help='display plugin usage')

  (opts, args) = parser.parse_args(argv)
  if not (opts.hunt_url or opts.hunt_subdomain or opts.hunt_email):
    parser.error('Missing required option')
  if not args:
    parser.error('Missing required argument')

  return opts, args[0]
Beispiel #29
0
class Command(object):
    def addOption(self, *args, **kargs):
        self.parser.add_option(*args, **kargs)

    def __init__(self, name, description, posArgs):
        self.name = name
        self.description = description
        self.func = None
        self.posArgs = posArgs
        commands[self.name] = self
        commandOrder.append(self.name)
        usage = 'usage: %prog [options]'
        posUsage = ''
        for posArg in posArgs:
            (argName, argDesc) = posArg
            usage += ' %s' % argName
            posUsage += '\n  %s: %s' % posArg
        usage += posUsage
        self.parser = OptionParser(usage=usage, description=description)
        self.addOption('-d', '--debug', dest='debug', action='store_true',
                       help='Verbose output.')

    def parseArgs(self, argv):
        (self.options, self.args) = self.parser.parse_args(argv[2:])
        if len(self.args) != len(self.posArgs):
            self.parser.error('Incorrect number of arguments')
        global debug
        if self.options.debug:
            debug = True

    def runCom(self):
        if not self.func:
            exit('Unimplemented command %s!' % self.name)
        self.func(self.options, self.args)
Beispiel #30
0
def main():
    parser = OptionParser('usage: %prog [options] task')
    parser.add_option("-f", "--config-file", dest='config_file',
        help="Configuration file")
    options, args = parser.parse_args()

    if not (options.config_file):
        parser.error("Please specify a configuration file.")

    logging.config.fileConfig(options.config_file)
    config = ConfigParser()
    config.read(options.config_file)

    session = get_session(config)
    today = date.today()

    entries = session.query(TimeEntry).filter(
        not_(TimeEntry.task.like('Aura %'))).filter(
        or_(TimeEntry.comment == None, TimeEntry.comment == '')).filter(
        TimeEntry.start_dt >= today).filter(
        TimeEntry.start_dt <= (today + timedelta(days=1)))

    grouped_entries = group_entries(entries)

    if grouped_entries:
        print 'Following Non-Aura entries require annotations:'
        print_alerts(session, grouped_entries)
        email_offenders(session, grouped_entries)
Beispiel #31
0
def main():
    usage = "usage: %prog [options] <path to (target).py file>"
    parser = OptionParser(usage=usage)

    # Setup
    setup_group = OptionGroup(parser, "Exploration Setup")
    setup_group.add_option(
        "-i",
        "--input",
        dest="inputs",
        action="store",
        help="Specify initial inputs, default to \'./inputs.py\'",
        default="./inputs.py")
    setup_group.add_option("--stdin",
                           dest="from_stdin",
                           action="store_true",
                           help="Read inputs from stdin instead of a file")
    setup_group.add_option(
        "-e",
        "--entry",
        dest="entry",
        action="store",
        help="Specify entry point, if different than (target).py",
        default=None)
    setup_group.add_option("-m",
                           "--max_iter",
                           dest="iteration",
                           action="store",
                           help="Specify max iterations",
                           default=50)
    setup_group.add_option("-t",
                           "--timeout",
                           dest="timeout",
                           action="store",
                           help="Specify solver timeout (default = 1sec)",
                           default=None)
    setup_group.add_option("--ss",
                           dest="ss",
                           action="store_true",
                           help="Special constraint for add_binays.py",
                           default=None)
    parser.add_option_group(setup_group)

    # Logging configuration
    logging_group = OptionGroup(parser, "Logging Configuration")
    logging_group.add_option("-d",
                             "--debug",
                             dest='debug',
                             action="store_true",
                             help="Enable debug logging")
    logging_group.add_option("--extract",
                             dest='extract',
                             action="store_true",
                             help="Extract bytecode only")
    logging_group.add_option("-q",
                             "--query",
                             dest='query',
                             action="store",
                             help="Store smt queries",
                             default=None)
    logging_group.add_option("--quiet",
                             dest='quiet',
                             action="store_true",
                             help="No logging")
    logging_group.add_option("-l",
                             "--logfile",
                             dest='logfile',
                             action="store",
                             help="Store log",
                             default=None)
    logging_group.add_option("--json",
                             dest='get_json',
                             action="store_true",
                             help="Print JSON format to stdout",
                             default=None)
    parser.add_option_group(logging_group)

    # Solver configuration
    solver_group = OptionGroup(parser, "Solver Configuration")
    solver_group.add_option(
        "-s",
        "--solver",
        dest='solver_type',
        action="store",
        help="Solver=[z3seq, z3str, trauc, cvc4], default to z3",
        default="z3seq")
    parser.add_option_group(solver_group)

    (options, args) = parser.parse_args()
    if len(args) == 0 or not os.path.exists(args[0]):
        parser.error("Missing app to execute")
        sys.exit(1)
    """
    if options.solver_type != "z3" and options.solver_type != "cvc4":
        parser.error("Solver can only be z3 or cvc4")
        sys.exit(1)
    """

    if options.debug:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO

    logfile = options.logfile
    if logfile is not None:
        logging.basicConfig(
            filename=options.logfile,
            level=log_level,
            format='%(asctime)s  %(name)s\t%(levelname)s\t%(message)s',
            datefmt='%m/%d/%Y %I:%M:%S %p')
    elif options.quiet:
        logging.basicConfig(filename="/dev/null")
    else:
        if options.get_json:
            logging.basicConfig(
                filename="/dev/null",
                level=log_level,
                format='  %(name)s\t%(levelname)s\t%(message)s')
        else:
            logging.basicConfig(
                level=log_level,
                format='  %(name)s\t%(levelname)s\t%(message)s')

    base_name = os.path.basename(args[0])
    filename = os.path.abspath(args[0])
    path = filename.replace(base_name, "")
    module = base_name.replace(".py", "")
    query = options.query

    inputs_space = {}
    if options.from_stdin:
        exec(sys.stdin.read(), inputs_space)
    else:
        inputs_file = options.inputs
        inputs_file_full = os.path.abspath(options.inputs)
        exec(open(inputs_file_full).read(), inputs_space)

    engine = ExplorationEngine(path, filename, module, options.entry,
                               inputs_space["INI_ARGS"], query,
                               options.solver_type, options.ss)

    if options.extract:
        engine.extract()
        return

    engine.explore(int(options.iteration), options.timeout)

    if options.quiet:
        return

    if not options.get_json:
        print()
        print("Generated inputs")
        for inputs in engine.input_sets:
            print(inputs)
        if len(engine.error_sets) != 0:
            print()
            print("Error inputs")
            for inputs in engine.error_sets:
                print(inputs)
        print()
        engine.print_coverage()
    else:
        print(engine.result_to_json())

    print(engine.in_ret_sets)