Python optparse.OptionParser() Examples

The following are code examples for showing how to use optparse.OptionParser(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: Ansible-Example-AB2018   Author: umit-ozturk   File: req_file.py    MIT License 6 votes vote down vote up
def build_parser(line):
    """
    Return a parser for parsing requirement lines
    """
    parser = optparse.OptionParser(add_help_option=False)

    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ
    for option_factory in option_factories:
        option = option_factory()
        parser.add_option(option)

    # By default optparse sys.exits on parsing errors. We want to wrap
    # that in our own exception.
    def parser_exit(self, msg):
        # add offending line
        msg = 'Invalid requirement: %s\n%s' % (line, msg)
        raise RequirementsFileParseError(msg)
    parser.exit = parser_exit

    return parser 
Example 2
Project: flasky   Author: RoseOu   File: cmdline.py    MIT License 6 votes vote down vote up
def __init__(self, action, options=None, defaults=None, usage=None,
                cmd=None, description=None
                ):
        """Create an OptionParser for a coverage command.

        `action` is the slug to put into `options.actions`.
        `options` is a list of Option's for the command.
        `defaults` is a dict of default value for options.
        `usage` is the usage string to display in help.
        `cmd` is the command name, if different than `action`.
        `description` is the description of the command, for the help text.

        """
        if usage:
            usage = "%prog " + usage
        super(CmdOptionParser, self).__init__(
            prog="coverage %s" % (cmd or action),
            usage=usage,
            description=description,
        )
        self.set_defaults(actions=[action], **(defaults or {}))
        if options:
            self.add_options(options)
        self.cmd = cmd or action 
Example 3
Project: MFEprimer_linux   Author: nick-youngblut   File: DegenerateSeqConvetor.py    MIT License 6 votes vote down vote up
def get_opt():
    '''Handle options'''
    usage = 'Usage: %prog [options]'

    version = '%prog Version: ' + '%s [%s]' % (Version, Date)
    parser = OptionParser(usage=usage, version=version)
    parser.add_option('-i', '--infile', dest='infile', help='Input file anme. [String]')
    parser.add_option('-o', '--outfile', dest='outfile', default=sys.stdout, help='Output file anme. [String]')
    [options, args] = parser.parse_args()

    if len(args) > 1:
        parser.error('Incorrect argument, add" "-h" for help.')

    if not options.infile:
        parser.error('Input degenerate sequence file needed, add" "-h" for help.')

    return options 
Example 4
Project: MFEprimer_linux   Author: nick-youngblut   File: PenultimateTable.py    MIT License 6 votes vote down vote up
def get_opt():
    '''Handle options'''
    usage = 'Usage: %prog [options]'

    version = '%prog Version: ' + '%s [%s]' % (Version, Date)
    parser = OptionParser(usage=usage, version=version)
    parser.add_option('-i', '--infile', dest='infile', help='Input file name. [String]')
    parser.add_option('-o', '--outfile', dest='outfile', help='Output file name. [String]')
    [options, args] = parser.parse_args()

    if len(args) > 1:
        parser.error('Incorrect argument, add" "-h" for help.')

    if not options.infile:
        pass

    return options 
Example 5
Project: Trusted-Platform-Module-nova   Author: BU-NU-CLOUD-SP16   File: cleanup_sm_locks.py    Apache License 2.0 6 votes vote down vote up
def _parse_args():
    parser = optparse.OptionParser()
    parser.add_option("-d", "--dry-run",
                      action="store_true", dest="dry_run", default=False,
                      help="don't actually remove locks")
    parser.add_option("-l", "--limit",
                      action="store", type='int', dest="limit",
                      default=sys.maxint,
                      help="max number of locks to delete (default: no limit)")
    parser.add_option("-v", "--verbose",
                      action="store_true", dest="verbose", default=False,
                      help="don't print status messages to stdout")

    options, args = parser.parse_args()

    try:
        days_old = int(args[0])
    except (IndexError, ValueError):
        parser.print_help()
        sys.exit(1)

    return options, days_old 
Example 6
Project: sic   Author: Yanixos   File: req_file.py    GNU General Public License v3.0 6 votes vote down vote up
def build_parser():
    """
    Return a parser for parsing requirement lines
    """
    parser = optparse.OptionParser(add_help_option=False)

    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ
    for option_factory in option_factories:
        option = option_factory()
        parser.add_option(option)

    # By default optparse sys.exits on parsing errors. We want to wrap
    # that in our own exception.
    def parser_exit(self, msg):
        raise RequirementsFileParseError(msg)
    parser.exit = parser_exit

    return parser 
Example 7
Project: bigquerylayers   Author: smandaric   File: cli.py    GNU General Public License v3.0 6 votes vote down vote up
def parse_cli(self):
        """Parse the CLI options

        :returns: (cli_opts, cli_args)
        """

        parser = OptionParser(usage=self.usage, description=self.description)

        parser.add_option('-i', '--input', type='string', help=self.input_help)

        if self.has_output:
            parser.add_option('-o', '--output', type='string', help=self.output_help)

        parser.add_option('--keyform',
                          help='Key format of the %s key - default PEM' % self.keyname,
                          choices=('PEM', 'DER'), default='PEM')

        (cli, cli_args) = parser.parse_args(sys.argv[1:])

        if len(cli_args) != self.expected_cli_args:
            parser.print_help()
            raise SystemExit(1)

        return cli, cli_args 
Example 8
Project: zabbix   Author: xiaomatech   File: redis_status_analyze.py    MIT License 6 votes vote down vote up
def get_options():
    usage = "usage: %prog [options]"
    OptionParser = optparse.OptionParser
    parser = OptionParser(usage)
    parser.add_option("-H","--host",action="store",type="string",\
        dest="redis_host",default=None,help="Redis Server redis_host")
    parser.add_option("-p","--port",action="store",type="int",\
        dest="redis_port",default=6379,help="Redis Server Port")
    parser.add_option("-a","--auth",action="store",type="string",\
        dest="redis_pass",default=None,help="Redis Server Pass")
    parser.add_option("-z","--zabbix_server",action="store",type="string",\
        dest="zabbix_server",default="127.0.0.1",help="redis_host or IP address of Zabbix server.Default is 127.0.0.1")
    parser.add_option("-P","--zabbix_port",action="store",type="int",\
        dest="zabbix_port",default=10051,help="Specify port number of server trapper running on the server. Default is 10051")
    parser.add_option("-c","--zabbix_config",action="store",type="string",\
        dest="zabbix_config",default=None,help="Absolute path to the zabbix configuration file")
    options, args = parser.parse_args()
    return options, args 
Example 9
Project: AshsSDK   Author: thehappydinoa   File: req_file.py    MIT License 6 votes vote down vote up
def build_parser():
    """
    Return a parser for parsing requirement lines
    """
    parser = optparse.OptionParser(add_help_option=False)

    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ
    for option_factory in option_factories:
        option = option_factory()
        parser.add_option(option)

    # By default optparse sys.exits on parsing errors. We want to wrap
    # that in our own exception.
    def parser_exit(self, msg):
        raise RequirementsFileParseError(msg)
    parser.exit = parser_exit

    return parser 
Example 10
Project: AshsSDK   Author: thehappydinoa   File: cli.py    MIT License 6 votes vote down vote up
def parse_cli(self):
        """Parse the CLI options

        :returns: (cli_opts, cli_args)
        """

        parser = OptionParser(usage=self.usage, description=self.description)

        parser.add_option('-i', '--input', type='string', help=self.input_help)

        if self.has_output:
            parser.add_option('-o', '--output', type='string', help=self.output_help)

        parser.add_option('--keyform',
                          help='Key format of the %s key - default PEM' % self.keyname,
                          choices=('PEM', 'DER'), default='PEM')

        (cli, cli_args) = parser.parse_args(sys.argv[1:])

        if len(cli_args) != self.expected_cli_args:
            parser.print_help()
            raise SystemExit(1)

        return cli, cli_args 
Example 11
Project: InsightAgent   Author: insightfinder   File: get_logs_elasticsearch.py    Apache License 2.0 6 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-v", "--verbose",
                      action="store_true", dest="verbose", help="Enable verbose logging")
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    (options, args) = parser.parse_args()

    params = dict()

    if options.serverUrl is None:
        params['serverUrl'] = 'https://app.insightfinder.com'
    else:
        params['serverUrl'] = options.serverUrl

    if options.homepath is None:
        params['homepath'] = os.getcwd()
    params['logLevel'] = logging.INFO
    if options.verbose:
        params['log_level'] = logging.DEBUG

    return params 
Example 12
Project: define   Author: SethDusek   File: define.py    BSD 2-Clause "Simplified" License 6 votes vote down vote up
def get_args():
    arg = optparse.OptionParser(version='%prog ' + __version__)
    arg.add_option("-a", "--audio", action="store_true",
                   help='audio playback for the the search result',
                   default=False)
    arg.add_option("-t", "--thesaurus", action="store_true",
                   help='show search results using thesaurus', default=False)
    arg.add_option("-u", "--urban", action="store_true",
                   help='show search results using urbandictionary.com',
                   default=False)
    arg.add_option("-w", "--wordnet", action="store_true",
                   help='show search results using wordnet')
    arg.add_option("-l", "--local", action="store_true",
                   help='show search results using local dict and dictd',
                   default=False)
    arg.add_option("-k", "--wiktionary", action="store_true",
                   help='show search results using wiktionary')
    return arg.parse_args(argv) 
Example 13
Project: ngo-addons-backport   Author: camptocamp   File: test_js.py    GNU Affero General Public License v3.0 6 votes vote down vote up
def run(self, args):
        self.parser = parser = optparse.OptionParser()
        parser.add_option("-d", "--database", dest="db_name", default=False, help="specify the database name")
        parser.add_option("--xmlrpc-port", dest="xmlrpc_port", default=8069, help="specify the TCP port for the XML-RPC protocol", type="int")
        # proably need to add both --superadmin-password and --database-admin-password
        self.parser.parse_args(args)

        # test ony uses db_name xmlrpc_port admin_passwd, so use the server one for the actual parsing

        config = openerp.tools.config
        config.parse_config(args)
        # needed until runbot is fixed
        config['db_password'] = config['admin_passwd']

        # run js tests
        openerp.netsvc.init_alternative_logger()
        suite = unittest2.TestSuite()
        suite.addTests(unittest2.TestLoader().loadTestsFromModule(openerp.addons.web.tests.test_js))
        r = unittest2.TextTestRunner(verbosity=2).run(suite)
        if r.errors or r.failures:
            sys.exit(1)

# vim:et:ts=4:sw=4: 
Example 14
Project: pyblish-win   Author: pyblish   File: hotshotmain.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def main(args):
    parser = optparse.OptionParser(__doc__)
    parser.disable_interspersed_args()
    parser.add_option("-p", "--profile", action="store", default=PROFILE,
                      dest="profile", help='Specify profile file to use')
    (options, args) = parser.parse_args(args)

    if len(args) == 0:
        parser.print_help("missing script to execute")
        return 1

    filename = args[0]
    return run_hotshot(filename, options.profile, args[1:]) 
Example 15
Project: pyblish-win   Author: pyblish   File: diff.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def main():

    usage = "usage: %prog [options] fromfile tofile"
    parser = optparse.OptionParser(usage)
    parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)')
    parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff')
    parser.add_option("-m", action="store_true", default=False, help='Produce HTML side by side diff (can use -c and -l in conjunction)')
    parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff')
    parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)')
    (options, args) = parser.parse_args()

    if len(args) == 0:
        parser.print_help()
        sys.exit(1)
    if len(args) != 2:
        parser.error("need to specify both a fromfile and tofile")

    n = options.lines
    fromfile, tofile = args

    fromdate = time.ctime(os.stat(fromfile).st_mtime)
    todate = time.ctime(os.stat(tofile).st_mtime)
    fromlines = open(fromfile, 'U').readlines()
    tolines = open(tofile, 'U').readlines()

    if options.u:
        diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
    elif options.n:
        diff = difflib.ndiff(fromlines, tolines)
    elif options.m:
        diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile,tofile,context=options.c,numlines=n)
    else:
        diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)

    sys.stdout.writelines(diff) 
Example 16
Project: pyblish-win   Author: pyblish   File: profile.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def main():
    usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('-o', '--outfile', dest="outfile",
        help="Save stats to <outfile>", default=None)
    parser.add_option('-s', '--sort', dest="sort",
        help="Sort order when printing to stdout, based on pstats.Stats class",
        default=-1)

    if not sys.argv[1:]:
        parser.print_usage()
        sys.exit(2)

    (options, args) = parser.parse_args()
    sys.argv[:] = args

    if len(args) > 0:
        progname = args[0]
        sys.path.insert(0, os.path.dirname(progname))
        with open(progname, 'rb') as fp:
            code = compile(fp.read(), progname, 'exec')
        globs = {
            '__file__': progname,
            '__name__': '__main__',
            '__package__': None,
        }
        runctx(code, globs, None, options.outfile, options.sort)
    else:
        parser.print_usage()
    return parser

# When invoked as main program, invoke the profiler on a script 
Example 17
Project: pyblish-win   Author: pyblish   File: uu.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def test():
    """uuencode/uudecode main program"""

    import optparse
    parser = optparse.OptionParser(usage='usage: %prog [-d] [-t] [input [output]]')
    parser.add_option('-d', '--decode', dest='decode', help='Decode (instead of encode)?', default=False, action='store_true')
    parser.add_option('-t', '--text', dest='text', help='data is text, encoded format unix-compatible text?', default=False, action='store_true')

    (options, args) = parser.parse_args()
    if len(args) > 2:
        parser.error('incorrect number of arguments')
        sys.exit(1)

    input = sys.stdin
    output = sys.stdout
    if len(args) > 0:
        input = args[0]
    if len(args) > 1:
        output = args[1]

    if options.decode:
        if options.text:
            if isinstance(output, basestring):
                output = open(output, 'w')
            else:
                print sys.argv[0], ': cannot do -t to stdout'
                sys.exit(1)
        decode(input, output)
    else:
        if options.text:
            if isinstance(input, basestring):
                input = open(input, 'r')
            else:
                print sys.argv[0], ': cannot do -t from stdin'
                sys.exit(1)
        encode(input, output) 
Example 18
Project: Flask-Python-GAE-Login-Registration   Author: orymeyer   File: serving.py    Apache License 2.0 5 votes vote down vote up
def main():
    '''A simple command-line interface for :py:func:`run_simple`.'''

    # in contrast to argparse, this works at least under Python < 2.7
    import optparse
    from werkzeug.utils import import_string

    parser = optparse.OptionParser(
        usage='Usage: %prog [options] app_module:app_object')
    parser.add_option('-b', '--bind', dest='address',
                      help='The hostname:port the app should listen on.')
    parser.add_option('-d', '--debug', dest='use_debugger',
                      action='store_true', default=False,
                      help='Use Werkzeug\'s debugger.')
    parser.add_option('-r', '--reload', dest='use_reloader',
                      action='store_true', default=False,
                      help='Reload Python process if modules change.')
    options, args = parser.parse_args()

    hostname, port = None, None
    if options.address:
        address = options.address.split(':')
        hostname = address[0]
        if len(address) > 1:
            port = address[1]

    if len(args) != 1:
        sys.stdout.write('No application supplied, or too much. See --help\n')
        sys.exit(1)
    app = import_string(args[0])

    run_simple(
        hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
        application=app, use_reloader=options.use_reloader,
        use_debugger=options.use_debugger
    ) 
Example 19
Project: Flask-Python-GAE-Login-Registration   Author: orymeyer   File: serving.py    Apache License 2.0 5 votes vote down vote up
def main():
    '''A simple command-line interface for :py:func:`run_simple`.'''

    # in contrast to argparse, this works at least under Python < 2.7
    import optparse
    from werkzeug.utils import import_string

    parser = optparse.OptionParser(
        usage='Usage: %prog [options] app_module:app_object')
    parser.add_option('-b', '--bind', dest='address',
                      help='The hostname:port the app should listen on.')
    parser.add_option('-d', '--debug', dest='use_debugger',
                      action='store_true', default=False,
                      help='Use Werkzeug\'s debugger.')
    parser.add_option('-r', '--reload', dest='use_reloader',
                      action='store_true', default=False,
                      help='Reload Python process if modules change.')
    options, args = parser.parse_args()

    hostname, port = None, None
    if options.address:
        address = options.address.split(':')
        hostname = address[0]
        if len(address) > 1:
            port = address[1]

    if len(args) != 1:
        sys.stdout.write('No application supplied, or too much. See --help\n')
        sys.exit(1)
    app = import_string(args[0])

    run_simple(
        hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
        application=app, use_reloader=options.use_reloader,
        use_debugger=options.use_debugger
    ) 
Example 20
Project: ecscale   Author: omerxx   File: ecscale.py    MIT License 5 votes vote down vote up
def lambda_handler(event, context):
    parser = OptionParser()
    parser.add_option("-a", "--access-key", dest="AWS_ACCESS_KEY_ID", help="Provide AWS access key")
    parser.add_option("-s", "--secret-key", dest="AWS_SECRET_ACCESS_KEY", help="Provide AWS secret key")
    parser.add_option("-d", "--dry-run", action="store_true", dest="DRY_RUN", default=False, help="Dry run the process")
    (options, args) = parser.parse_args()

    if options.AWS_ACCESS_KEY_ID and options.AWS_SECRET_ACCESS_KEY:
        os.environ['AWS_ACCESS_KEY_ID'] = options.AWS_ACCESS_KEY_ID
        os.environ['AWS_SECRET_ACCESS_KEY'] = options.AWS_SECRET_ACCESS_KEY
    elif options.AWS_ACCESS_KEY_ID or options.AWS_SECRET_ACCESS_KEY:
        print 'AWS key or secret are missing'

    runType = 'dry' if options.DRY_RUN else 'normal'
    main(run=runType) 
Example 21
Project: Ansible-Example-AB2018   Author: umit-ozturk   File: baseparser.py    MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.name = kwargs.pop('name')

        isolated = kwargs.pop("isolated", False)
        self.config = Configuration(isolated)

        assert self.name
        optparse.OptionParser.__init__(self, *args, **kwargs) 
Example 22
Project: 2015-SpaceInvaders-Bot-Python   Author: EntelectChallenge   File: ez_setup.py    MIT License 5 votes vote down vote up
def _parse_args():
    """Parse the command line for options."""
    parser = optparse.OptionParser()
    parser.add_option(
        '--user', dest='user_install', action='store_true', default=False,
        help='install in user site package (requires Python 2.6 or later)')
    parser.add_option(
        '--download-base', dest='download_base', metavar="URL",
        default=DEFAULT_URL,
        help='alternative URL from where to download the setuptools package')
    parser.add_option(
        '--insecure', dest='downloader_factory', action='store_const',
        const=lambda: download_file_insecure, default=get_best_downloader,
        help='Use internal, non-validating downloader'
    )
    parser.add_option(
        '--version', help="Specify which version to download",
        default=DEFAULT_VERSION,
    )
    parser.add_option(
    	'--to-dir',
    	help="Directory to save (and re-use) package",
    	default=DEFAULT_SAVE_DIR,
    )
    options, args = parser.parse_args()
    # positional arguments are ignored
    return options 
Example 23
Project: flasky   Author: RoseOu   File: baseparser.py    MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.config = ConfigParser.RawConfigParser()
        self.name = kwargs.pop('name')
        self.files = self.get_config_files()
        if self.files:
            self.config.read(self.files)
        assert self.name
        optparse.OptionParser.__init__(self, *args, **kwargs) 
Example 24
Project: flasky   Author: RoseOu   File: serving.py    MIT License 5 votes vote down vote up
def main():
    '''A simple command-line interface for :py:func:`run_simple`.'''

    # in contrast to argparse, this works at least under Python < 2.7
    import optparse
    from werkzeug.utils import import_string

    parser = optparse.OptionParser(
        usage='Usage: %prog [options] app_module:app_object')
    parser.add_option('-b', '--bind', dest='address',
                      help='The hostname:port the app should listen on.')
    parser.add_option('-d', '--debug', dest='use_debugger',
                      action='store_true', default=False,
                      help='Use Werkzeug\'s debugger.')
    parser.add_option('-r', '--reload', dest='use_reloader',
                      action='store_true', default=False,
                      help='Reload Python process if modules change.')
    options, args = parser.parse_args()

    hostname, port = None, None
    if options.address:
        address = options.address.split(':')
        hostname = address[0]
        if len(address) > 1:
            port = address[1]

    if len(args) != 1:
        sys.stdout.write('No application supplied, or too much. See --help\n')
        sys.exit(1)
    app = import_string(args[0])

    run_simple(
        hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
        application=app, use_reloader=options.use_reloader,
        use_debugger=options.use_debugger
    ) 
Example 25
Project: pastebin-monitor   Author: fabiospampinato   File: pastebin_crawler.py    GNU General Public License v2.0 5 votes vote down vote up
def parse_input():
    parser = OptionParser()
    parser.add_option('-r', '--refresh-time', help='Set the refresh time (default: 30)', dest='refresh_time', type='int', default=30)
    parser.add_option('-d', '--delay-time', help='Set the delay time (default: 1)', dest='delay', type='float', default=1)
    parser.add_option('-b', '--ban-wait-time', help='Set the ban wait time (default: 5)', dest='ban_wait', type='int', default=5)
    parser.add_option('-f', '--flush-after-x-refreshes', help='Set the number of refreshes after which memory is flushed (default: 100)', dest='flush_after_x_refreshes', type='int', default=100)
    parser.add_option('-c', '--connection-timeout', help='Set the connection timeout waiting time (default: 60)', dest='connection_timeout', type='float', default=60)
    (options, args) = parser.parse_args()
    return options.refresh_time, options.delay, options.ban_wait, options.flush_after_x_refreshes, options.connection_timeout 
Example 26
Project: MFEprimer_linux   Author: nick-youngblut   File: FastaFormatParser.py    MIT License 5 votes vote down vote up
def get_opt():
    '''Options and args'''
    usage = 'Usage: %prog fasta_format_file'
    version = '%prog' + ' %s [%s]' % (Version, Date)
    parser = OptionParser(usage=usage, version=version)
    [options, args] = parser.parse_args()
    if len(args) != 1:
        parser.error('Incorrect argument, add "-h" for help.')

    return options, args 
Example 27
Project: MFEprimer_linux   Author: nick-youngblut   File: FastaSimpleFormatParser.py    MIT License 5 votes vote down vote up
def get_opt():
    '''Options and args'''
    usage = 'Usage: %prog fasta_format_file'
    version = '%prog' + ' %s [%s]' % (Version, Date)
    parser = OptionParser(usage=usage, version=version)
    [options, args] = parser.parse_args()
    if len(args) != 1:
        parser.error('Incorrect argument, add "-h" for help.')

    return options, args 
Example 28
Project: MFEprimer_linux   Author: nick-youngblut   File: mfe_index_db.py    MIT License 5 votes vote down vote up
def optget():
    '''parse options'''
    parser = OptionParser()
    parser.add_option("-f", "--file", dest = "filename", help = "DNA file in fasta to be indexed")
    parser.add_option("-k", "--k", dest = "k", type='int', help = "K mer , default is 9", default = 9)

    (options, args) = parser.parse_args()

    if not options.filename:
        print_usage()
        exit()	

    return options 
Example 29
Project: Trusted-Platform-Module-nova   Author: BU-NU-CLOUD-SP16   File: install_venv_common.py    Apache License 2.0 5 votes vote down vote up
def parse_args(self, argv):
        """Parses command-line arguments."""
        parser = optparse.OptionParser()
        parser.add_option('-n', '--no-site-packages',
                          action='store_true',
                          help="Do not inherit packages from global Python "
                               "install.")
        return parser.parse_args(argv[1:])[0] 
Example 30
Project: whatwaff   Author: SVelizDonoso   File: whatwaff.py    MIT License 5 votes vote down vote up
def help():
    # Menu de opciones del script
	parser = optparse.OptionParser('Uso: python %prog [options]( Ejemplo: python %prog -u http://www.sitioprueba.com/)')
	parser.add_argument('-u','--url', action='store', dest='url',help='URL del Servidor')
	parser.add_argument('--headsec', action='store', dest='hsec',help='Listar Seguridad Cabeceras HTTP')
	parser.add_argument('--version', action='version', version='%(prog)s 1.0')
        return parser.parse_args() 
Example 31
Project: sic   Author: Yanixos   File: baseparser.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.config = configparser.RawConfigParser()
        self.name = kwargs.pop('name')
        self.isolated = kwargs.pop("isolated", False)
        self.files = self.get_config_files()
        if self.files:
            self.config.read(self.files)
        assert self.name
        optparse.OptionParser.__init__(self, *args, **kwargs) 
Example 32
Project: AshsSDK   Author: thehappydinoa   File: baseparser.py    MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.config = configparser.RawConfigParser()
        self.name = kwargs.pop('name')
        self.isolated = kwargs.pop("isolated", False)
        self.files = self.get_config_files()
        if self.files:
            self.config.read(self.files)
        assert self.name
        optparse.OptionParser.__init__(self, *args, **kwargs) 
Example 33
Project: AshsSDK   Author: thehappydinoa   File: frontend.py    MIT License 5 votes vote down vote up
def __init__(self, components=(), defaults=None, read_config_files=None,
                 *args, **kwargs):
        """
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        """

        self.lists = {}
        """Set of list-type settings."""

        self.config_files = []
        """List of paths of applied configuration files."""

        optparse.OptionParser.__init__(
            self, option_class=Option, add_help_option=None,
            formatter=optparse.TitledHelpFormatter(width=78),
            *args, **kwargs)
        if not self.version:
            self.version = self.version_template
        # Make an instance copy (it will be modified):
        self.relative_path_settings = list(self.relative_path_settings)
        self.components = (self,) + tuple(components)
        self.populate_from_components(self.components)
        self.set_defaults_from_dict(defaults or {})
        if read_config_files and not self.defaults['_disable_config']:
            try:
                config_settings = self.get_standard_config_settings()
            except ValueError, error:
                self.error(SafeString(error))
            self.set_defaults_from_dict(config_settings.__dict__) 
Example 34
Project: InsightAgent   Author: insightfinder   File: getmetrics_sysdig.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-c", "--chunkLines",
                      action="store", dest="chunkLines", help="Timestamps per chunk for historical data.")
    parser.add_option("-l", "--logLevel",
                      action="store", dest="logLevel", help="Change log verbosity(WARNING: 0, INFO: 1, DEBUG: 2)")
    (options, args) = parser.parse_args()

    params = dict()
    if options.serverUrl is None:
        params['serverUrl'] = 'http://stg.insightfinder.com'
    else:
        params['serverUrl'] = options.serverUrl
    if options.chunkLines is None:
        params['chunkLines'] = 50
    else:
        params['chunkLines'] = int(options.chunkLines)
    params['logLevel'] = logging.INFO
    if options.logLevel == '0':
        params['logLevel'] = logging.WARNING
    elif options.logLevel == '1':
        params['logLevel'] = logging.INFO
    elif options.logLevel >= '2':
        params['logLevel'] = logging.DEBUG

    return params

#
# Read and parse InsightFinder config from config.ini
# 
Example 35
Project: InsightAgent   Author: insightfinder   File: getmetrics_hadoop.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-c", "--chunkLines",
                      action="store", dest="chunkLines", help="Timestamps per chunk for historical data.")
    parser.add_option("-l", "--logLevel",
                      action="store", dest="logLevel", help="Change log verbosity(WARNING: 0, INFO: 1, DEBUG: 2)")
    (options, args) = parser.parse_args()

    params = {}
    if options.serverUrl is None:
        params['serverUrl'] = 'https://app.insightfinder.com'
    else:
        params['serverUrl'] = options.serverUrl
    if options.chunkLines is None:
        params['chunkLines'] = 50
    else:
        params['chunkLines'] = int(options.chunkLines)
    params['logLevel'] = logging.INFO
    if options.logLevel == '0':
        params['logLevel'] = logging.WARNING
    elif options.logLevel == '1':
        params['logLevel'] = logging.INFO
    elif options.logLevel >= '2':
        params['logLevel'] = logging.DEBUG

    return params 
Example 36
Project: InsightAgent   Author: insightfinder   File: parseSendData.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    parser.add_option("-w", "--server_url",
                      action="store", dest="server_url", help="Server Url")
    parser.add_option("-l", "--chunk_lines",
                      action="store", dest="chunk_lines", help="Max number of lines in chunk")
    parser.add_option("-m", "--max_in_tag",
                      action="store", dest="max_in_tag", help="Max number of one tag can have")
    (options, args) = parser.parse_args()

    parameters = {}
    if options.homepath is None:
        parameters['homepath'] = os.getcwd()
    else:
        parameters['homepath'] = options.homepath
    if options.server_url == None:
        parameters['server_url'] = 'https://app.insightfinder.com'
    else:
        parameters['server_url'] = options.server_url
    if options.chunk_lines is None:
        parameters['chunk_lines'] = 1000
    else:
        parameters['chunk_lines'] = int(options.chunk_lines)
    if options.max_in_tag is None:
        parameters['max_in_tag'] = 200
    else:
        parameters['max_in_tag'] = int(options.max_in_tag)
    return parameters 
Example 37
Project: InsightAgent   Author: insightfinder   File: getlogs_Pufa.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    parser.add_option("-w", "--server_url",
                      action="store", dest="server_url", help="Server Url")
    parser.add_option("-l", "--chunk_lines",
                      action="store", dest="chunk_lines", help="Max number of lines in chunk")
    parser.add_option("-m", "--max_in_tag",
                      action="store", dest="max_in_tag", help="Max number of one tag can have")
    (options, args) = parser.parse_args()

    parameters = {}
    if options.homepath is None:
        parameters['homepath'] = os.getcwd()
    else:
        parameters['homepath'] = options.homepath
    if options.server_url == None:
        parameters['server_url'] = 'https://app.insightfinder.com'
    else:
        parameters['server_url'] = options.server_url
    if options.chunk_lines is None:
        parameters['chunk_lines'] = 1000
    else:
        parameters['chunk_lines'] = int(options.chunk_lines)
    if options.max_in_tag is None:
        parameters['max_in_tag'] = 200
    else:
        parameters['max_in_tag'] = int(options.max_in_tag)
    return parameters 
Example 38
Project: InsightAgent   Author: insightfinder   File: collectdReportMetrics.py    Apache License 2.0 5 votes vote down vote up
def get_input_from_user():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    parser.add_option("-w", "--server_url",
                      action="store", dest="server_url", help="Server Url")
    parser.add_option("-l", "--log_level",
                      action="store", dest="log_level", help="Change log verbosity(WARNING: 0, INFO: 1, DEBUG: 2)")
    (options, args) = parser.parse_args()

    params = {}

    params['homepath'] = os.getcwd() if not options.homepath else options.homepath
    params['server_url'] = 'http://127.0.0.1:8080' if not options.server_url else options.server_url
    # For calling reportCustomMetrics from '../common' directory.
    sys.path.insert(0, os.path.join(params['homepath'], 'common'))

    params['log_level'] = logging.INFO
    if options.log_level == '0':
        params['log_level'] = logging.WARNING
    elif options.log_level == '1':
        params['log_level'] = logging.INFO
    elif options.log_level >= '2':
        params['log_level'] = logging.DEBUG

    params['datadir'] = "data/"
    return params 
Example 39
Project: InsightAgent   Author: insightfinder   File: getincident_kafka.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    parser.add_option("-t", "--timeout",
                      action="store", dest="timeout", help="Timeout in seconds. Default is 30")
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-l", "--chunkLines",
                      action="store", dest="chunkLines", help="Max number of lines in chunk")
    parser.add_option("-p", "--project",
                      action="store", dest="project", help="Insightfinder Project to send data to")
    (options, args) = parser.parse_args()

    parameters = {}
    if options.homepath is None:
        parameters['homepath'] = os.getcwd()
    else:
        parameters['homepath'] = options.homepath
    if options.serverUrl is None:
        parameters['serverUrl'] = 'https://app.insightfinder.com'
    else:
        parameters['serverUrl'] = options.serverUrl
    if options.timeout is None:
        parameters['timeout'] = 86400
    else:
        parameters['timeout'] = int(options.timeout)
    if options.chunkLines is None:
        parameters['chunk_lines'] = 1000
    else:
        parameters['chunk_lines'] = int(options.chunkLines)
    if options.project is None:
        parameters['project'] = None
    else:
        parameters['project'] = options.project

    return parameters 
Example 40
Project: InsightAgent   Author: insightfinder   File: getmetrics_hbase.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-c", "--chunkLines",
                      action="store", dest="chunkLines", help="Timestamps per chunk for historical data.")
    parser.add_option("-l", "--logLevel",
                      action="store", dest="logLevel", help="Change log verbosity(WARNING: 0, INFO: 1, DEBUG: 2)")
    (options, args) = parser.parse_args()

    params = {}
    if options.serverUrl is None:
        params['serverUrl'] = 'https://app.insightfinder.com'
    else:
        params['serverUrl'] = options.serverUrl
    if options.chunkLines is None:
        params['chunkLines'] = 50
    else:
        params['chunkLines'] = int(options.chunkLines)
    params['logLevel'] = logging.INFO
    if options.logLevel == '0':
        params['logLevel'] = logging.WARNING
    elif options.logLevel == '1':
        params['logLevel'] = logging.INFO
    elif options.logLevel >= '2':
        params['logLevel'] = logging.DEBUG

    return params 
Example 41
Project: InsightAgent   Author: insightfinder   File: getlogs_kafka.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    parser.add_option("-t", "--timeout",
                      action="store", dest="timeout", help="Timeout in seconds. Default is 30")
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-l", "--chunkLines",
                      action="store", dest="chunkLines", help="Max number of lines in chunk")
    parser.add_option("-p", "--project",
                      action="store", dest="project", help="Insightfinder Project to send data to")
    (options, args) = parser.parse_args()

    parameters = {}
    if options.homepath is None:
        parameters['homepath'] = os.getcwd()
    else:
        parameters['homepath'] = options.homepath
    if options.serverUrl is None:
        parameters['serverUrl'] = 'https://app.insightfinder.com'
    else:
        parameters['serverUrl'] = options.serverUrl
    if options.timeout is None:
        parameters['timeout'] = 86400
    else:
        parameters['timeout'] = int(options.timeout)
    if options.chunkLines is None:
        parameters['chunk_lines'] = 1000
    else:
        parameters['chunk_lines'] = int(options.chunkLines)
    if options.project is None:
        parameters['project'] = None
    else:
        parameters['project'] = options.project

    return parameters 
Example 42
Project: InsightAgent   Author: insightfinder   File: getmetrics_kvm.py    Apache License 2.0 5 votes vote down vote up
def getParameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    (options, args) = parser.parse_args()

    if options.homepath is None:
        homePath = os.getcwd()
    else:
        homePath = options.homepath

    return homePath 
Example 43
Project: InsightAgent   Author: insightfinder   File: getmetrics_jolokia.py    Apache License 2.0 5 votes vote down vote up
def getParameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
                      action="store", dest="homepath", help="Directory to run from")
    (options, args) = parser.parse_args()

    if options.homepath is None:
        homePath = os.getcwd()
    else:
        homePath = options.homepath

    return homePath 
Example 44
Project: InsightAgent   Author: insightfinder   File: getmetrics_datadog.py    Apache License 2.0 5 votes vote down vote up
def get_parameters():
    usage = "Usage: %prog [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-w", "--serverUrl",
                      action="store", dest="serverUrl", help="Server Url")
    parser.add_option("-c", "--chunkLines",
                      action="store", dest="chunkLines", help="Timestamps per chunk for historical data.")
    parser.add_option("-l", "--logLevel",
                      action="store", dest="logLevel", help="Change log verbosity(WARNING: 0, INFO: 1, DEBUG: 2)")
    (options, args) = parser.parse_args()

    params = {}
    if options.serverUrl is None:
        params['serverUrl'] = 'https://app.insightfinder.com'
    else:
        params['serverUrl'] = options.serverUrl
    if options.chunkLines is None:
        params['chunkLines'] = 50
    else:
        params['chunkLines'] = int(options.chunkLines)
    params['logLevel'] = logging.INFO
    if options.logLevel == '0':
        params['logLevel'] = logging.WARNING
    elif options.logLevel == '1':
        params['logLevel'] = logging.INFO
    elif options.logLevel >= '2':
        params['logLevel'] = logging.DEBUG

    return params 
Example 45
Project: Old-school-processing   Author: cianfrocco-lab   File: estimateCTF_CTFFIND3.py    MIT License 5 votes vote down vote up
def setupParserOptions():
        parser = optparse.OptionParser()
        parser.set_usage("%prog --input=<micros> --apix=<pixelSize> --mag=<magnification> --cs=<cs>")
        parser.add_option("--input",dest="micros",type="string",metavar="FILE",
                help="Wild card containing absolute path to .mrc micrographs ('/path/micro/*.mrc')")
        parser.add_option("--apix",dest="apix",type="float", metavar="FLOAT",
                help="Pixel size of micrographs")
	parser.add_option("--mag",dest="mag",type="int", metavar="INT",
                help="Magnification of micrographs")
	parser.add_option("--cs",dest="cs",type="float", metavar="float",
                help="Cs of microscope (mm)")
        parser.add_option("--kev",dest="kev",type="int", metavar="INT",
                help="Accelerating voltage (keV)")
	parser.add_option("--ampContrast",dest="contrast",type="float", metavar="FLOAT",
                help="Amplitude contrast (0.07 - cryo; 0.15 - neg. stain)")
	parser.add_option("--relionoutput", action="store_true",dest="relion",default=False,
                help="Flag to save CTFFIND output log files compatible with Relion for particle extraction")
	parser.add_option("-d", action="store_true",dest="debug",default=False,
                help="debug")
        options,args = parser.parse_args()

        if len(args) > 0:
                parser.error("Unknown commandline options: " +str(args))

        if len(sys.argv) < 3:
                parser.print_help()
                sys.exit()
        params={}
        for i in parser.option_list:
                if isinstance(i.dest,str):
                        params[i.dest] = getattr(options,i.dest)
        return params

#============================= 
Example 46
Project: Old-school-processing   Author: cianfrocco-lab   File: estimateCTF_CTFTILT.py    MIT License 5 votes vote down vote up
def setupParserOptions():
        parser = optparse.OptionParser()
        parser.set_usage("%prog --input=<micros> --output=<outputfile> --apix=<pixelSize> --tilt=<tilt> --mag=<magnification> --cs=<cs> --kev=<kev> --ampContrast=<amp>")
        parser.add_option("--input",dest="micros",type="string",metavar="FILE",
                help="Wild card containing absolute path to .mrc tilted micrographs ('/path/micro/*.mrc')")
	parser.add_option("--output",dest="output",type="string",metavar="FILE",
                help="Output filename")
        parser.add_option("--apix",dest="apix",type="float", metavar="FLOAT",
                help="Pixel size of micrographs")
	parser.add_option("--tilt",dest="tilt",type="int", metavar="int",
                help="Estimate of tilt angle")
	parser.add_option("--mag",dest="mag",type="int", metavar="INT",
                help="Magnification of micrographs")
	parser.add_option("--cs",dest="cs",type="float", metavar="float",
                help="Cs of microscope (mm)")
        parser.add_option("--kev",dest="kev",type="int", metavar="INT",
                help="Accelerating voltage (keV)")
	parser.add_option("--ampContrast",dest="contrast",type="float", metavar="FLOAT",
                help="Amplitude contrast (0.07 - cryo; 0.15 - neg. stain)")
	parser.add_option("-d", action="store_true",dest="debug",default=False,
                help="debug")
        options,args = parser.parse_args()

        if len(args) > 0:
                parser.error("Unknown commandline options: " +str(args))

        if len(sys.argv) < 3:
                parser.print_help()
                sys.exit()
        params={}
        for i in parser.option_list:
                if isinstance(i.dest,str):
                        params[i.dest] = getattr(options,i.dest)
        return params

#============================= 
Example 47
Project: Old-school-processing   Author: cianfrocco-lab   File: calculate_difference_density.py    MIT License 5 votes vote down vote up
def setupParserOptions():
        parser = optparse.OptionParser()
        parser.set_usage("%prog --input1=[input] --input2=[input] --type=2D/3D")
        parser.add_option("--input1",dest="input1",type="string",metavar="FILE",
                help="Image/Volume from which input2 will be subtracted. (2D or 3D input, .spi or .mrc format)")
        parser.add_option("--input2",dest="input2",type="string",metavar="FILE",
                help="Image/Volume that wil be subtracted from input1 econd input will be subtracted. (2D or 3D input, .spi or .mrc format)")
	parser.add_option("--type",dest="type",type="string",metavar="TYPE",
                help="Input type: 2D or 3D.")
	parser.add_option("-d", action="store_true",dest="debug",default=False,
                help="debug")
        options,args = parser.parse_args()

        if len(args) > 0:
                parser.error("Unknown commandline options: " +str(args))

        if len(sys.argv) < 3:
                parser.print_help()
                sys.exit()
        params={}
        for i in parser.option_list:
                if isinstance(i.dest,str):
                        params[i.dest] = getattr(options,i.dest)
        return params

#============================= 
Example 48
Project: Old-school-processing   Author: cianfrocco-lab   File: threshold_mask_volume.py    MIT License 5 votes vote down vote up
def setupParserOptions():
        parser = optparse.OptionParser()
        parser.set_usage("%prog -v <volume> --thresh=<threshold> --dilate=<dilate>")
        parser.add_option("-v",dest="vol",type="string",metavar="FILE",
                help="Volume to be threshold-masked (.mrc or .spi)")
        parser.add_option("--thresh",dest="thresh",type="float", metavar="float",
                help="Value to threshold the map density to create mask. (Retrieved from Chimera's volume viewer histogram value when viewing struture)")
        parser.add_option("--dilate",dest="dilate",type="int", metavar="INT",default=4,
                help="Amount (in pixels) to expand the thresholded structure to create a shape mask. (Default=4)")
        parser.add_option("--savemask",action='store_true',dest="savemask",default=False,
                help="Flag to save mask generated during threshold & masking of input volume.")
        parser.add_option("-d", action="store_true",dest="debug",default=False,
                help="debug")
        options,args = parser.parse_args()

        if len(args) > 0:
                parser.error("Unknown commandline options: " +str(args))

        if len(sys.argv) < 3:
                parser.print_help()
                sys.exit()
        params={}
        for i in parser.option_list:
                if isinstance(i.dest,str):
                        params[i.dest] = getattr(options,i.dest)
        return params

#============================= 
Example 49
Project: Old-school-processing   Author: cianfrocco-lab   File: compare_avgs_to_3Dmodel.py    MIT License 5 votes vote down vote up
def setupParserOptions():
        parser = optparse.OptionParser()
        parser.set_usage("%prog -i <stack.img> --num=[number of class averages] --boxsize=[boxsize of data] -v <volume>")
        parser.add_option("-i",dest="stack",type="string",metavar="FILE",
                help="Stack of 2D class averages in .img format.")
        parser.add_option("--num",dest="numParts",type="int", metavar="INT",
                help="Number of class averages")
	parser.add_option("--boxsize",dest="boxsize",type="int", metavar="INT",
                help="Boxsize of particles and 3D model")
	parser.add_option("-v",dest="vol",type="string",metavar="FILE",
                help="3D volume to be aligned to 2D averages (.mrc or .spi format)")
        parser.add_option("--angstep",dest="angstep",type="int", metavar="INT",default=10,
                help="Angular step for projecting 3D model (Default=10 degrees)")
	parser.add_option("-d", action="store_true",dest="debug",default=False,
                help="debug")
        options,args = parser.parse_args()

        if len(args) > 0:
                parser.error("Unknown commandline options: " +str(args))

        if len(sys.argv) < 3:
                parser.print_help()
                sys.exit()
        params={}
        for i in parser.option_list:
                if isinstance(i.dest,str):
                        params[i.dest] = getattr(options,i.dest)
        return params

#============================= 
Example 50
Project: Old-school-processing   Author: cianfrocco-lab   File: make_tilt_pair_file.py    MIT License 5 votes vote down vote up
def setupParserOptions():
        parser = optparse.OptionParser()
        parser.set_usage("%prog -p <path/to/images> -o <output> --Uext=[untiltExtension] --Text=[tiltExtension]")
        parser.add_option("-p",dest="path",type="string",metavar="FILE",
                help="Absolute path to the folder containing tilt-mates")
	parser.add_option("-o",dest="output",type="string",metavar="FILE",
                help="Output file to contain tilt mates")
	parser.add_option("--Uext",dest="Uext",type="string", metavar="STRING",
                help="Untilted micrograph extension (e.g. '00', 'u')")
	parser.add_option("--Text",dest="Text",type="string", metavar="STRING",
                help="Tilted micrograph extension (e.g. '01', 't')")
        parser.add_option("--leginon",action="store_true",dest="leginon",default=False,
		help="Flag if tilt mates came from leginon")
	parser.add_option("-d", action="store_true",dest="debug",default=False,
                help="debug")
        options,args = parser.parse_args()

        if len(args) > 1:
                parser.error("Unknown commandline options: " +str(args))

        if len(sys.argv) < 4:
                parser.print_help()
                sys.exit()
        params={}
        for i in parser.option_list:
                if isinstance(i.dest,str):
                        params[i.dest] = getattr(options,i.dest)
        return params
#=============================