def main(): l18n.init() parser = ArghParser() parser.add_argument('-a', '--auth', action='store_true', help=_('Authenticate and show all problems' ' on this machine')) parser.add_argument('-v', '--version', action='version', version=config.VERSION) parser.add_commands([ backtrace, di_install, gdb, info, list_problems, remove, report, retrace, status, ]) argcomplete.autocomplete(parser) try: parser.dispatch() except KeyboardInterrupt: sys.exit(1) sys.exit(0)
def main(): logging_config(detail="high") parser = ArghParser(description="Utilities for working with tabular files") parser.add_commands([ filter_rows ] ) parser.dispatch()
def main(): logging_config(detail="high") parser = ArghParser(description="Utilities for manipulating FASTA files") parser.add_commands([ rec_filter ] ) parser.dispatch()
def main(): """Use argh to dispatch to your subcommands.""" from argh import ArghParser # sudo apt-get install python3-argh parser = ArghParser() # Sorting makes the output of --help better: parser.add_commands(sorted(subcommand.s, key=lambda f: f.__name__)) # parser.add_commands(subcommand.s) parser.dispatch()
def main(): logging_helper.logging_config(detail="high") parser = ArghParser() parser.add_commands([ remove_missing_seqs ] ) parser.dispatch()
def main(argv=None): """ Main method / entry point """ if argv is None: argv = sys.argv[1:] description = "SSL Karttarekisteri KML tool" parser = ArghParser(description=description) parser.add_commands([convert, download]) parser.dispatch(argv=argv)
def main(): logging_config(detail="high") parser = ArghParser(description="Utilities for analysing output of annotation consensus classifier") parser.add_commands([ as_tab ] ) parser.dispatch()
def __call__(self, **kwargs): parser = ArghParser() commands = [ full_release, publish_cfg_files, update_distribution_changelog, ] parser.add_commands(commands) parser.dispatch()
def main(): parser = ArghParser() parser.add_commands( ( module_list, module_install, module_uninstall, module_enable, module_disable ), namespace='module', title='Module commands', description='Group of commands related to listing or (un)installing modules' ) ini_file='production.ini' if 'NP_INI_FILE' in os.environ: ini_file = os.environ['NP_INI_FILE'] ini_name='netprofile' if 'NP_INI_NAME' in os.environ: ini_name = os.environ['NP_INI_NAME'] parser.add_argument('--ini-file', '-i', default=ini_file, help='Specify .ini file to use') parser.add_argument('--application', '-a', default=ini_name, help='Default app section of .ini file to use') parser.dispatch()
def __call__(self, **kwargs): parser = ArghParser() parser.add_commands( [checkPypi, checkPackageForUpdates, checkAllPackagesForUpdates, pulls, changelog, create_launchpad_release, check_checkout]) parser.dispatch()
def main(): """Shell entry point for execution""" try: argparser = ArghParser() argparser.add_commands([ phase1_install, phase2_install, ]) argparser.dispatch() except KeyboardInterrupt: sys.exit(0)
def __call__(self, **kwargs): parser = ArghParser() parser.add_commands( [checkPypi, checkPackageForUpdates, checkAllPackagesForUpdates, pulls, changelog, create_launchpad_release, check_checkout, append_jenkins_build_number_to_package_version]) parser.dispatch()
def main(): hc.setup() opt = "stdin_buffer_lines" buffer = 0 buffering = False #if opt in CONFIG: # buffering = True # buffer = int(CONFIG[opt]) if not sys.stdin.isatty(): db = get_database() cbuffer = 0 # FIXME: should handle g-code & stuff while True: line = sys.stdin.readline() if not line: break path, value = line.split(' ', 1) if ' ' in value: # timestamp present dt_in, value = value.split() dt = parse_timestamp(dt_in) else: dt = now() #print(o) cbuffer += 1 sys.exit(0) #logging.basicConfig(level=logging.DEBUG) #logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) logging.basicConfig(level=logging.INFO) parser = ArghParser() parser.add_commands([ send, shell, server, monitor, uimon, uipcb, uiprobe, ]) argcomplete.autocomplete(parser) try: parser.dispatch() except KeyboardInterrupt: sys.exit(1)
def get_base_parser(): dist = pkg_resources.get_distribution("awstools") parser = ArghParser(version=dist.version) parser.add_argument( '--config', default=None, help="path of an alternative configuration file") parser.add_argument( '--settings', default=None, help="path of the application settings configuration file") return parser
def main(): """Shell entry point for execution""" try: argparser = ArghParser() argparser.add_commands([ do_template_test, do_create_docs, do_template_init, ]) argparser.dispatch() except KeyboardInterrupt: sys.exit(0)
def main(): parser = ArghParser(description='Simple static gallery generator.') parser.add_commands([init, build, serve]) parser.add_argument('--version', action='version', version='%(prog)s {}'.format(__version__)) parser.dispatch()
def main(): config_file = os.environ.get('GIT_SPY', '~/.gitspy') if os.environ.has_key('HOME'): config_file = config_file.replace('~', os.environ.get('HOME')) if not os.path.exists(config_file): config_fp = open(config_file, 'w+') else: config_fp = open(config_file, 'r') commands = Commands(config_fp) parser = ArghParser() parser.add_commands(commands) parser.dispatch() config_fp.close()
def main(): parser = ArghParser() parser.add_argument('-v', '--version', action='version', version=__version__) enabled_commands = [init, build, watch, po, runserver] parser.add_commands(enabled_commands) parser.dispatch()
def main(): reload(sys) sys.setdefaultencoding("utf-8") parser = ArghParser(description='Simple static gallery generator.') parser.add_commands([init, build, serve]) parser.add_argument('--version', action='version', version='%(prog)s {}'.format(__version__)) parser.dispatch()
def main(): commands = pack, watch, shell, libs names = [f.__name__ for f in commands] + [ 'help' ] parser = ArghParser() parser.add_argument('-v', '--version', action='version', version=VERSION, help='Show zeta version') parser.add_commands(commands) argv = sys.argv[1:] if argv and not argv[0] in names and not argv[0] in ['-v', '--version']: argv.insert(0, 'pack') parser.dispatch(argv)
def test_register_commands_quiet_and_verbose_together_systemexit(monkeypatch): """Test that register_commands with quiet and verbose raises SystemExit.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def verbosity(quiet, verbose): pass cli.register_commands('testing', [verbosity]) with pytest.raises(SystemExit): cli.parser.parse_args(['testing', 'verbosity', '-q', '-v'])
def test_register_commands_verbose(monkeypatch, arguments, expected): """Test that register_commands handles quiet.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def verbosity(verbose): pass cli.register_commands('testing', [verbosity]) args = cli.parser.parse_args(['testing', 'verbosity'] + arguments) assert args.verbose == expected
def main(): """ Main entrypoint for console_script (commandline script) """ parser = ArghParser() parser.add_argument('-v', '--version', action='version', version=client_version) enabled_commands = [register] parser.add_commands(enabled_commands) parser.dispatch()
def test_register_commands_keyword_only_conflicts(monkeypatch): """Test register_commands with key-only arguments with conflicts.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def keyword(*, arg1=1, arg2=2): pass cli.register_commands('testing', [keyword]) with pytest.raises(SystemExit): cli.parser.parse_args(['testing', 'keyword', '-a', '1'])
def test_register_commands(monkeypatch): """Test register_commands with no arguments.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def simple(): pass cli.register_commands('testing', [simple]) args = cli.parser.parse_args(['testing', 'simple']) assert args
def test_register_commands_keyword(monkeypatch, arguments, a, b): """Test register_commands with keyword arguments.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def keyword(a=1, b=2): pass cli.register_commands('testing', [keyword]) args = cli.parser.parse_args(['testing', 'keyword'] + arguments) assert args.a == a assert args.b == b
def test_register_commands_positional(monkeypatch): """Test register_commands with positional arguments.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def positional(a, b): pass cli.register_commands('testing', [positional]) args = cli.parser.parse_args(['testing', 'positional', '1', '2']) assert args.a == '1' assert args.b == '2'
def main(): """ Main entrypoint for console_script (commandline script) """ parser = ArghParser() parser.add_argument('-v', '--version', action='version', version=client_version) enabled_commands = [pull, push] parser.add_commands(enabled_commands) parser.dispatch()
def main(): """ Main entrypoint for console_script (commandline script) """ parser = ArghParser() parser.add_argument("-v", "--version", action="version", version=client_version) enabled_commands = [register] parser.add_commands(enabled_commands) parser.dispatch()
def test_register_commands_keyword_only(monkeypatch, arguments, first, second): """Test register_commands with keyword-only arguments.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def keyword(*, first=1, second=2): pass cli.register_commands('testing', [keyword]) args = cli.parser.parse_args(['testing', 'keyword'] + arguments) assert args.first == first assert args.second == second
def vast_ai(): functionality = [ VastAPI.create_account, VastAPI.set_api_key, VastAPI.login ] p = ArghParser() p.add_commands(functionality) p.dispatch()
def main(): """Main application entrypoint""" parser = ArghParser(parents=[COMMON_PARSER]) set_default_command(parser, upload) completion.autocomplete(parser) # Peek CLI arguments and globally enable debugging args = parser.parse_args() if args.debug: logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s' ) # Cut down suds logs logging.getLogger('suds').setLevel(logging.WARNING) if args.version: print_version() return parser.dispatch()
def test_register_commands_quiet_and_verbose(monkeypatch, arguments, quiet, verbose): """Test that register_commands handles quiet and verbose.""" monkeypatch.setattr(cli, 'parser', ArghParser('testing')) def verbosity(quiet, verbose): pass cli.register_commands('testing', [verbosity]) args = cli.parser.parse_args(['testing', 'verbosity', arguments]) assert args.quiet == quiet assert args.verbose == verbose
def eventparser_entry(): parser = ArghParser(parents=[COMMON_PARSER]) parser.set_default_command(eventparser) completion.autocomplete(parser) # Parse ahead args = parser.parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s') parser.dispatch()
def main(): parser = ArghParser(description=__doc__) parser.add_commands([report, me]) try: parser.dispatch() except Exception as e: raise logger.error('Runtime exception: %s' % e) sys.exit(1)
def main(): l18n.init() parser = ArghParser() parser.add_argument( "-a", "--auth", action="store_true", help=_("Authenticate and show all problems" " on this machine") ) parser.add_argument("-v", "--version", action="version", version=config.VERSION) parser.add_commands([backtrace, di_install, gdb, info, list_problems, remove, report, retrace, status]) argcomplete.autocomplete(parser) try: parser.dispatch() except KeyboardInterrupt: sys.exit(1) sys.exit(0)
def main(): from snaptastic import __version__ if '--version' in sys.argv: print 'Snaptastic version %s' % __version__ p = ArghParser() commands = [make_snapshots, mount_snapshots, check_backups, list_volumes, unmount_snapshots, clean, test] p.add_commands(commands) p.dispatch()
def __main__(): parser = ArghParser() parser.add_commands( sorted([ v for k, v in globals().items() if not k.startswith("_") and not k == "main" and isfunction(v) and v.__module__ == "__main__" ], key=lambda a: a.__name__)) parser.dispatch()
def get_base_parser(): dist = pkg_resources.get_distribution("awstools") parser = ArghParser(version=dist.version) parser.add_argument('--config', default=None, help="path of an alternative configuration file") parser.add_argument( '--settings', default=None, help="path of the application settings configuration file") return parser
def main(): parser = ArghParser() parser.add_argument('-v', '--version', action='version', version=__version__) enabled_commands = [init, build, watch, po] # Enabling runserver command if cherrypy is installed try: import cherrypy except ImportError: pass else: from optimus.cli.runserver import runserver enabled_commands.append(runserver) parser.add_commands(enabled_commands) parser.dispatch()
def main(): """ Main entrypoint for the application. Parses the command-line arguments the dispatches the correct methods. """ parser = ArghParser(parents=[COMMON_PARSER]) parser.add_commands( [exporttracks, checktoken, allaccessimport, exportplaylist]) args = parser.parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s') parser.dispatch()
def __call__(self, **kwargs): parser = ArghParser() parser.add_commands( [checkPypi, checkPackageForUpdates, checkAllPackagesForUpdates, pulls, changelog, create_launchpad_release, check_checkout, append_jenkins_build_number_to_package_version, set_package_version]) parser.dispatch()
def vast(): vast = VastAPI() functionality = [ vast.change_bid, vast.create_instance, vast.destroy_instance, vast.label_instance, vast.list_machine, vast.remove_defjob, vast.set_defjob, vast.set_min_bid, vast.show_instances, vast.show_machines, vast.start_instance, vast.stop_instance, vast.unlist_machine, vast.search_offers ] p = ArghParser() p.add_commands(functionality) p.dispatch()
def main(): """Shell entry point for execution""" try: argparser = ArghParser() argparser.add_commands([ test, docs, init, lint, ]) argparser.dispatch() except KeyboardInterrupt: sys.exit(0)
def eventparser_entry(): parser = ArghParser(parents=[COMMON_PARSER]) parser.set_default_command(eventparser) completion.autocomplete(parser) # Parse ahead args = parser.parse_args() if args.debug: logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s' ) parser.dispatch()
def main(): logging_config(detail="high") parser = ArghParser() ref_down = RefseqDownloader() parser.add_commands([ ref_down.checkout ] ) parser.add_commands([ ref_down.list_remote_files, ref_down.download_file, ref_down.wf_generate, ref_down.extract_fasta_header ], namespace="internal", title="Commands used internally by the application" ) parser.dispatch()
def main(*argv): resources.init("Praxa", getenv('INSTANCE_NAME', "Praxa")) if not isdir(resources.user.path): makedirs(resources.user.path) arguments = list(argv) if not arguments: from sys import argv arguments = argv[1:] parser = ArghParser() parser.add_help = True parser.add_commands([dump, load], namespace="env", title="Environment Manipulation") parser.add_commands([vexec]) # the default if len(arguments): if arguments[0] not in ('env', 'dump', 'load', 'exec'): arguments.insert(0, 'exec') parser.dispatch(argv=arguments) return 0
def main(): opt = "stdin_buffer_lines" buffer = 0 buffering = False #if opt in CONFIG: # buffering = True # buffer = int(CONFIG[opt]) if not sys.stdin.isatty(): db = get_database() cbuffer = 0 # FIXME: should handle g-code & stuff while True: line = sys.stdin.readline() if not line: break path, value = line.split(' ', 1) if ' ' in value: # timestamp present dt_in, value = value.split() dt = parse_timestamp(dt_in) else: dt = now() #print(o) cbuffer += 1 sys.exit(0) #logging.basicConfig(level=logging.DEBUG) #logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) logging.basicConfig(level=logging.INFO) parser = ArghParser() parser.add_commands([ shell, monitor, uimon, uipcb, uiprobe, ]) argcomplete.autocomplete(parser) try: parser.dispatch() except KeyboardInterrupt: sys.exit(1)
def main(): parser = ArghParser(parents=[COMMON_PARSER]) parser.add_commands( [ ting ] ) completion.autocomplete(parser) # Parse ahead args = parser.parse_args() if args.debug: logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s' ) parser.dispatch()
def main(): """ Main entrypoint for the application. Parses the command-line arguments the dispatches the correct methods. """ parser = ArghParser(parents=[COMMON_PARSER]) parser.add_commands( [ exporttracks, checktoken, allaccessimport, exportplaylist ] ) args = parser.parse_args() if args.debug: logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s' ) parser.dispatch()
#!/usr/bin/python3 __author__ = 'meatpuppet' import logging from argh import ArghParser from snip import terminal from argh.completion import autocomplete # todo: incremental indexing https://whoosh.readthedocs.org/en/latest/indexing.html def web(): from snip.web import web import webbrowser webbrowser.open('http://localhost:5000') web.app.run() if __name__ == "__main__": parser = ArghParser() parser.add_commands([terminal.pull, terminal.show, terminal.search, terminal.index, web]) autocomplete(parser) parser.dispatch()
remote_user=default_remote_user, region=default_region, remote_control_dir=default_remote_control_dir): master = master or get_master(cluster_name, region=region) ssh_call(user=remote_user, host=master, key_file=key_file, args=[ '''for i in {remote_control_dir}/*/RUNNING; do pid=$(cat $i) children=$(pgrep -P $pid) sudo kill $pid $children || true done >& /dev/null || true'''.format( remote_control_dir=remote_control_dir) ]) parser = ArghParser() parser.add_commands([ launch, destroy, get_master, ssh_master, tag_cluster_instances, health_check ]) parser.add_commands([ job_run, job_attach, wait_for_job, kill_job, killall_jobs, collect_job_results ], namespace="jobs") if __name__ == '__main__': parser.dispatch()
ignore_directories=args.ignore_directories, stop_signal=stop_signal, kill_after=args.kill_after) handler.start() observer = Observer(timeout=args.timeout) observe_with(observer, handler, args.directories, args.recursive) handler.stop() epilog = """Copyright 2011 Yesudeep Mangalapilly <*****@*****.**>. Copyright 2012 Google, Inc. Licensed under the terms of the Apache license, version 2.0. Please see LICENSE in the source code for more information.""" parser = ArghParser(epilog=epilog) parser.add_commands([tricks_from, tricks_generate_yaml, log, shell_command, auto_restart]) parser.add_argument('--version', action='version', version='%(prog)s ' + VERSION_STRING) def main(): """Entry-point function.""" parser.dispatch()
def main(): ''' The main method of Barman ''' p = ArghParser() p.add_argument('-v', '--version', action='version', version=barman.__version__) p.add_argument( '-c', '--config', help= 'uses a configuration file (defaults: $HOME/.barman.conf, /etc/barman.conf)' ) p.add_argument('-q', '--quiet', help='be quiet', action='store_true') p.add_commands([ cron, list_server, show_server, status, check, backup, list_backup, show_backup, list_files, recover, delete, ]) try: p.dispatch(pre_call=global_config, output_file=_output_stream) except Exception: msg = "ERROR: Unhandled exception. See log file for more details." logging.exception(msg) raise SystemExit(msg)
def main(): """ The main method of Barman """ p = ArghParser(epilog='Barman by 2ndQuadrant (www.2ndQuadrant.com)') p.add_argument( '-v', '--version', action='version', version='%s\n\nBarman by 2ndQuadrant (www.2ndQuadrant.com)' % barman.__version__) p.add_argument('-c', '--config', help='uses a configuration file ' '(defaults: %s)' % ', '.join(barman.config.Config.CONFIG_FILES), default=SUPPRESS) p.add_argument('-q', '--quiet', help='be quiet', action='store_true') p.add_argument('-d', '--debug', help='debug output', action='store_true') p.add_argument('-f', '--format', help='output format', choices=output.AVAILABLE_WRITERS.keys(), default=output.DEFAULT_WRITER) p.add_commands([ archive_wal, backup, check, cron, delete, diagnose, get_wal, list_backup, list_files, list_server, rebuild_xlogdb, receive_wal, recover, show_backup, show_server, replication_status, status, switch_xlog, ]) # noinspection PyBroadException try: p.dispatch(pre_call=global_config) except KeyboardInterrupt: msg = "Process interrupted by user (KeyboardInterrupt)" output.error(msg) except Exception as e: msg = "%s\nSee log file for more details." % e output.exception(msg) # cleanup output API and exit honoring output.error_occurred and # output.error_exit_code output.close_and_exit()
def main(): from argh import ArghParser parser = ArghParser() parser.add_commands([to_jbrowse]) parser.dispatch()