Python optparse.OptionParser() Examples
The following are 30 code examples for showing how to use optparse.OptionParser(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
optparse
, or try the search function
.
Example 1
Project: open-sesame Author: swabhs File: semafor_evaluation.py License: Apache License 2.0 | 7 votes |
def main(): e_parser = OptionParser() e_parser.add_option("--e_mode", dest="e_mode", type="choice", choices=["convert_conll_to_fe", "count_frame_elements", "compare_fefiles"], default="convert_conll_to_fe") e_parser.add_option("--conll_file", type="str", metavar="FILE") e_parser.add_option("--fe_file", type="str", metavar="FILE") e_parser.add_option("--fe_file_other", type="str", metavar="FILE") e_options, _ = e_parser.parse_args() if e_options.e_mode == "convert_conll_to_fe": assert e_options.conll_file and e_options.fe_file convert_conll_to_frame_elements(e_options.conll_file, e_options.fe_file) elif e_options.e_mode == "count_frame_elements": assert e_options.fe_file count_frame_elements(e_options.fe_file) elif e_options.e_mode == "compare_fefiles": assert e_options.fe_file and e_options.fe_file_other compare_fefiles(e_options.fe_file, e_options.fe_file_other)
Example 2
Project: macops Author: google File: experiments.py License: Apache License 2.0 | 6 votes |
def ParseOptions(argv): """Parse command-line options.""" parser = optparse.OptionParser(usage='%prog [options]') parser.add_option('-D', '--debug', action='store_true', default=False) parser.add_option('-F', '--formatted', action='store_true', default=False, help=('Output experiments as one "experiment,status" ' 'per line')) parser.add_option( '-e', '--enable', action='store', dest='manually_enable', help='Comma-delimited list of experiments to manually enable.') parser.add_option( '-d', '--disable', action='store', dest='manually_disable', help='Comma-delimited list of experiments to manually enable.') parser.add_option( '-r', '--recommended', action='store', dest='recommended', help='Comma-delimited list of experiments to no longer manually manage.') opts, args = parser.parse_args(argv) return opts, args
Example 3
Project: delocate Author: matthew-brett File: delocate_fuse.py License: BSD 2-Clause "Simplified" License | 6 votes |
def main(): parser = OptionParser( usage="%s WHEEL1 WHEEL2\n\n" % sys.argv[0] + __doc__, version="%prog " + __version__) parser.add_option( Option("-w", "--wheel-dir", action="store", type='string', help="Directory to store delocated wheels (default is to " "overwrite WHEEL1 input)")) parser.add_option( Option("-v", "--verbose", action="store_true", help="Show libraries copied during fix")) (opts, wheels) = parser.parse_args() if len(wheels) != 2: parser.print_help() sys.exit(1) wheel1, wheel2 = [abspath(expanduser(wheel)) for wheel in wheels] if opts.wheel_dir is None: out_wheel = wheel1 else: out_wheel = pjoin(abspath(expanduser(opts.wheel_dir)), basename(wheel1)) fuse_wheels(wheel1, wheel2, out_wheel)
Example 4
Project: InsightAgent Author: insightfinder File: getmetrics_zipkin.py License: Apache License 2.0 | 6 votes |
def get_cli_config_vars(): """ get CLI options """ usage = "Usage: %prog [options]" parser = OptionParser(usage=usage) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Enable verbose logging") parser.add_option("-t", "--testing", action="store_true", dest="testing", help="Set to testing mode (do not send data)." " Automatically turns on verbose logging") (options, args) = parser.parse_args() config_vars = dict() config_vars['testing'] = False if options.testing: config_vars['testing'] = True config_vars['logLevel'] = logging.INFO if options.verbose or options.testing: config_vars['logLevel'] = logging.DEBUG return config_vars
Example 5
Project: esmlab Author: NCAR File: print_versions.py License: Apache License 2.0 | 6 votes |
def main(): from optparse import OptionParser parser = OptionParser() parser.add_option( '-j', '--json', metavar='FILE', nargs=1, help='Save output as JSON into file, pass in ' "'-' to output to stdout", ) (options, args) = parser.parse_args() if options.json == '-': options.json = True show_versions(as_json=options.json) return 0
Example 6
Project: jawfish Author: war-and-code File: main.py License: MIT License | 6 votes |
def _getOptParser(self): import optparse parser = optparse.OptionParser() parser.prog = self.progName parser.add_option('-v', '--verbose', dest='verbose', default=False, help='Verbose output', action='store_true') parser.add_option('-q', '--quiet', dest='quiet', default=False, help='Quiet output', action='store_true') if self.failfast != False: parser.add_option('-f', '--failfast', dest='failfast', default=False, help='Stop on first fail or error', action='store_true') if self.catchbreak != False: parser.add_option('-c', '--catch', dest='catchbreak', default=False, help='Catch ctrl-C and display results so far', action='store_true') if self.buffer != False: parser.add_option('-b', '--buffer', dest='buffer', default=False, help='Buffer stdout and stderr during tests', action='store_true') return parser
Example 7
Project: trelby Author: trelby File: do_tests.py License: GNU General Public License v2.0 | 6 votes |
def main(): parser = optparse.OptionParser(version = "%%prog %s" % VERSION) parser.add_option("--file", dest="file", help="FILE to test") parser.add_option("--function", dest="func", help="FUNCTION to test") parser.add_option("--file-at-a-time", action="store_true", dest="faat", default = False, help="run tests from each file in the same" " process (faster, but coarser if tests fail)") (opts, args) = parser.parse_args() if opts.file: return doTest(opts) else: return doTests(opts) # returns a list of all function names from the given file that start with # "test".
Example 8
Project: sslyze Author: nabla-c0d3 File: command_line_parser.py License: GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, sslyze_version: str) -> None: """Generate SSLyze's command line parser. """ self._parser = OptionParser(version=sslyze_version, usage=self.SSLYZE_USAGE) # Add generic command line options to the parser self._add_default_options() # Add plugin .ie scan command options to the parser scan_commands_group = OptionGroup(self._parser, "Scan commands", "") for option in self._get_plugin_scan_commands(): scan_commands_group.add_option(f"--{option.option}", help=option.help, action=option.action) self._parser.add_option_group(scan_commands_group) # Add the --regular command line parameter as a shortcut if possible self._parser.add_option( "--regular", action="store_true", dest=None, help=f"Regular HTTPS scan; shortcut for --{'--'.join(self.REGULAR_CMD)}", )
Example 9
Project: llvm-zorg Author: llvm File: main.py License: Apache License 2.0 | 6 votes |
def action_runserver(name, args): """run a llvmlab instance""" import llvmlab from optparse import OptionParser, OptionGroup parser = OptionParser("%%prog %s [options]" % name) parser.add_option("", "--reloader", dest="reloader", default=False, action="store_true", help="use WSGI reload monitor") parser.add_option("", "--debugger", dest="debugger", default=False, action="store_true", help="use WSGI debugger") parser.add_option("", "--profiler", dest="profiler", default=False, action="store_true", help="enable WSGI profiler") (opts, args) = parser.parse_args(args) if len(args) != 0: parser.error("invalid number of arguments") app = llvmlab.ui.app.App.create_standalone() if opts.debugger: app.debug = True if opts.profiler: app.wsgi_app = werkzeug.contrib.profiler.ProfilerMiddleware( app.wsgi_app, stream = open('profiler.log', 'w')) app.run(use_reloader = opts.reloader, use_debugger = opts.debugger)
Example 10
Project: bugbuzz-python Author: fangpenlin File: ez_setup.py License: MIT License | 6 votes |
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, ) options, args = parser.parse_args() # positional arguments are ignored return options
Example 11
Project: Quiver-alfred Author: danielecook File: pwiz.py License: MIT License | 6 votes |
def get_option_parser(): parser = OptionParser(usage='usage: %prog [options] database_name') ao = parser.add_option ao('-H', '--host', dest='host') ao('-p', '--port', dest='port', type='int') ao('-u', '--user', dest='user') ao('-P', '--password', dest='password', action='store_true') engines = sorted(DATABASE_MAP) ao('-e', '--engine', dest='engine', default='postgresql', choices=engines, help=('Database type, e.g. sqlite, mysql or postgresql. Default ' 'is "postgresql".')) ao('-s', '--schema', dest='schema') ao('-t', '--tables', dest='tables', help=('Only generate the specified tables. Multiple table names should ' 'be separated by commas.')) ao('-i', '--info', dest='info', action='store_true', help=('Add database information and other metadata to top of the ' 'generated file.')) ao('-o', '--preserve-order', action='store_true', dest='preserve_order', help='Model definition column ordering matches source table.') return parser
Example 12
Project: arctic Author: man-group File: arctic_enable_sharding.py License: GNU Lesser General Public License v2.1 | 6 votes |
def main(): usage = """usage: %prog [options] arg1=value, arg2=value Enables sharding on the specified arctic library. """ setup_logging() parser = optparse.OptionParser(usage=usage) parser.add_option("--host", default='localhost', help="Hostname, or clustername. Default: localhost") parser.add_option("--library", help="The name of the library. e.g. 'arctic_jblackburn.lib'") (opts, _) = parser.parse_args() if not opts.library or '.' not in opts.library: parser.error('must specify the full path of the library e.g. arctic_jblackburn.lib!') print("Enabling-sharding: %s on mongo %s" % (opts.library, opts.host)) c = pymongo.MongoClient(get_mongodb_uri(opts.host)) credentials = get_auth(opts.host, 'admin', 'admin') if credentials: authenticate(c.admin, credentials.user, credentials.password) store = Arctic(c) enable_sharding(store, opts.library)
Example 13
Project: arctic Author: man-group File: arctic_list_libraries.py License: GNU Lesser General Public License v2.1 | 6 votes |
def main(): usage = """usage: %prog [options] [prefix ...] Lists the libraries available in a user's database. If any prefix parameters are given, list only libraries with names that start with one of the prefixes. Example: %prog --host=hostname rgautier """ setup_logging() parser = optparse.OptionParser(usage=usage) parser.add_option("--host", default='localhost', help="Hostname, or clustername. Default: localhost") (opts, args) = parser.parse_args() store = Arctic(opts.host) for name in sorted(store.list_libraries()): if (not args) or [n for n in args if name.startswith(n)]: print(name)
Example 14
Project: linter-pylama Author: AtomLinter File: config.py License: MIT License | 6 votes |
def _expand_default(self, option): """Patch OptionParser.expand_default with custom behaviour This will handle defaults to avoid overriding values in the configuration file. """ if self.parser is None or not self.default_tag: return option.help optname = option._long_opts[0][2:] try: provider = self.parser.options_manager._all_options[optname] except KeyError: value = None else: optdict = provider.get_option_def(optname) optname = provider.option_attrname(optname, optdict) value = getattr(provider.config, optname, optdict) value = utils._format_option_value(optdict, value) if value is optparse.NO_DEFAULT or not value: value = self.NO_DEFAULT_VALUE return option.help.replace(self.default_tag, str(value))
Example 15
Project: ecscale Author: omerxx File: ecscale.py License: MIT License | 5 votes |
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 16
Project: cherrypy Author: cherrypy File: daemon.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def run(): """Run cherryd CLI.""" from optparse import OptionParser p = OptionParser() p.add_option('-c', '--config', action='append', dest='config', help='specify config file(s)') p.add_option('-d', action='store_true', dest='daemonize', help='run the server as a daemon') p.add_option('-e', '--environment', dest='environment', default=None, help='apply the given config environment') p.add_option('-f', action='store_true', dest='fastcgi', help='start a fastcgi server instead of the default HTTP ' 'server') p.add_option('-s', action='store_true', dest='scgi', help='start a scgi server instead of the default HTTP server') p.add_option('-x', action='store_true', dest='cgi', help='start a cgi server instead of the default HTTP server') p.add_option('-i', '--import', action='append', dest='imports', help='specify modules to import') p.add_option('-p', '--pidfile', dest='pidfile', default=None, help='store the process id in the given file') p.add_option('-P', '--Path', action='append', dest='Path', help='add the given paths to sys.path') options, args = p.parse_args() if options.Path: for p in options.Path: sys.path.insert(0, p) start(options.config, options.daemonize, options.environment, options.fastcgi, options.scgi, options.pidfile, options.imports, options.cgi)
Example 17
Project: pastebin-monitor Author: fabiospampinato File: pastebin_crawler.py License: GNU General Public License v2.0 | 5 votes |
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 18
Project: macops Author: google File: ds.py License: Apache License 2.0 | 5 votes |
def main(): parser = OptionParser() parser.add_option('-e', '--expandgroup', dest='groupname', help='Get group membership') parser.add_option('-l', '--ldapserver', dest='ldap_server', help='LDAP server to query for nested groups', default=None) (options, unused_args) = parser.parse_args() if options.groupname: print GetGroupMembership(options.groupname, ldap_server=options.ldap_server) else: parser.print_help()
Example 19
Project: delocate Author: matthew-brett File: delocate_path.py License: BSD 2-Clause "Simplified" License | 5 votes |
def main(): parser = OptionParser( usage="%s PATH_TO_ANALYZE\n\n" % sys.argv[0] + __doc__, version="%prog " + __version__) parser.add_options([ Option("-L", "--lib-path", action="store", type='string', help="Output subdirectory path to copy library dependencies"), Option("-d", "--dylibs-only", action="store_true", help="Only analyze files with known dynamic library " "extensions")]) (opts, paths) = parser.parse_args() if len(paths) < 1: parser.print_help() sys.exit(1) if opts.lib_path is None: opts.lib_path = '.dylibs' lib_filt_func = 'dylibs-only' if opts.dylibs_only else None multi = len(paths) > 1 for path in paths: if multi: print(path) # evaluate paths relative to the path we are working on lib_path = os.path.join(path, opts.lib_path) delocate_path(path, lib_path, lib_filt_func)
Example 20
Project: delocate Author: matthew-brett File: delocate_listdeps.py License: BSD 2-Clause "Simplified" License | 5 votes |
def main(): parser = OptionParser( usage="%s WHEEL_OR_PATH_TO_ANALYZE\n\n" % sys.argv[0] + __doc__, version="%prog " + __version__) parser.add_options([ Option("-a", "--all", action="store_true", help="Show all dependencies, including system libs"), Option("-d", "--depending", action="store_true", help="Show libraries depending on dependencies")]) (opts, paths) = parser.parse_args() if len(paths) < 1: parser.print_help() sys.exit(1) multi = len(paths) > 1 for path in paths: if multi: print(path + ':') indent = ' ' else: indent = '' if isdir(path): lib_dict = tree_libs(path) lib_dict = stripped_lib_dict(lib_dict, realpath(getcwd()) + psep) else: lib_dict = wheel_libs(path) keys = sorted(lib_dict) if not opts.all: keys = [key for key in keys if filter_system_libs(key)] if not opts.depending: if len(keys): print(indent + ('\n' + indent).join(keys)) continue i2 = indent + ' ' for key in keys: print(indent + key + ':') libs = lib_dict[key] if len(libs): print(i2 + ('\n' + i2).join(libs))
Example 21
Project: delocate Author: matthew-brett File: delocate_patch.py License: BSD 2-Clause "Simplified" License | 5 votes |
def main(): parser = OptionParser( usage="%s WHEEL_FILENAME PATCH_FNAME\n\n" % sys.argv[0] + __doc__, version="%prog " + __version__) parser.add_option( Option("-w", "--wheel-dir", action="store", type='string', help="Directory to store patched wheel (default is to " "overwrite input)")) parser.add_option( Option("-v", "--verbose", action="store_true", help="Print input and output wheels")) (opts, args) = parser.parse_args() if len(args) != 2: parser.print_help() sys.exit(1) wheel, patch_fname = args if opts.wheel_dir: wheel_dir = expanduser(opts.wheel_dir) if not exists(wheel_dir): os.makedirs(wheel_dir) else: wheel_dir = None if opts.verbose: print('Patching: {0} with {1}'.format(wheel, patch_fname)) if wheel_dir: out_wheel = pjoin(wheel_dir, basename(wheel)) else: out_wheel = wheel patch_wheel(wheel, patch_fname, out_wheel) if opts.verbose: print("Patched wheel {0} to {1}:".format( wheel, out_wheel))
Example 22
Project: InsightAgent Author: insightfinder File: getmessages_kafka2.py License: Apache License 2.0 | 5 votes |
def get_cli_config_vars(): """ get CLI options. use of these options should be rare """ usage = 'Usage: %prog [options]' parser = OptionParser(usage=usage) """ ## not ready. parser.add_option('--threads', default=1, action='store', dest='threads', help='Number of threads to run') """ parser.add_option('-q', '--quiet', action='store_true', dest='quiet', help='Only display warning and error log messages') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='Enable verbose logging') parser.add_option('-t', '--testing', action='store_true', dest='testing', help='Set to testing mode (do not send data).' + ' Automatically turns on verbose logging') (options, args) = parser.parse_args() """ # not ready try: threads = int(options.threads) except ValueError: threads = 1 """ config_vars = { 'threads': 1, 'testing': False, 'log_level': logging.INFO } if options.testing: config_vars['testing'] = True if options.verbose or options.testing: config_vars['log_level'] = logging.DEBUG elif options.quiet: config_vars['log_level'] = logging.WARNING return config_vars
Example 23
Project: InsightAgent Author: insightfinder File: getmetrics_sysdig.py License: Apache License 2.0 | 5 votes |
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 24
Project: InsightAgent Author: insightfinder File: getmetrics_hadoop.py License: Apache License 2.0 | 5 votes |
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 25
Project: InsightAgent Author: insightfinder File: getmetrics_nfdump.py License: Apache License 2.0 | 5 votes |
def getParameters(): 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", "--serverUrl", action="store", dest="serverUrl", help="Server Url") parser.add_option("-p", "--profilePath", action="store", dest="profilePath", help="Server Url") (options, args) = parser.parse_args() parameters = {} if options.homepath is None: parameters['homepath'] = os.getcwd() else: parameters['homepath'] = options.homepath if options.serverUrl == None: parameters['serverUrl'] = 'https://app.insightfinder.com' else: parameters['serverUrl'] = options.serverUrl if options.profilePath == None: parameters['profilePath'] = '/data/nfsen/profiles-data/live' else: parameters['profilePath'] = options.profilePath return parameters
Example 26
Project: InsightAgent Author: insightfinder File: configure.py License: Apache License 2.0 | 5 votes |
def get_config_ini(): """ get config file from cli option """ parser = OptionParser() parser.add_option('-c', '--config', action='store', dest='config', default='config.ini', help='Path to the config file to use. Defaults to config.ini') (options, args) = parser.parse_args() if not os.path.isfile(options.config): shutil.copyfile('./config.ini.template', options.config) return options.config
Example 27
Project: InsightAgent Author: insightfinder File: configure.py License: Apache License 2.0 | 5 votes |
def get_config_ini(): """ get config file from cli option """ parser = OptionParser() parser.add_option('-c', '--config', action='store', dest='config', default='config.ini', help='Path to the config file to use. Defaults to config.ini') (options, args) = parser.parse_args() if not os.path.isfile(options.config): shutil.copyfile('./config.ini.template', options.config) return options.config
Example 28
Project: InsightAgent Author: insightfinder File: getlogs_Pufa.py License: Apache License 2.0 | 5 votes |
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 29
Project: InsightAgent Author: insightfinder File: collectdReportMetrics.py License: Apache License 2.0 | 5 votes |
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 30
Project: InsightAgent Author: insightfinder File: split_files.py License: Apache License 2.0 | 5 votes |
def main(): """ Example:python2 split_files.py -i "test.csv" -t "2018-10-03 22:50:00,2018-10-03 23:59:00" """ usage = "Usage: %prog [options]" parser = OptionParser(usage=usage) parser.add_option("-i", "--infile", action="store", dest="in_file_path", help="File to split.") parser.add_option("-t", "--time_range", action="store", dest="time_range", help="Time range to filter.") (options, args) = parser.parse_args() in_file_path = options.in_file_path time_range = options.time_range if in_file_path is None: in_file_path = "test.csv" print 'Input file path: ' + in_file_path if time_range: handle_csv_filter(in_file_path, time_range) else: handle_csv_split(in_file_path) print "\nFinished"