当前位置: 首页>>代码示例>>Python>>正文


Python sys.args方法代码示例

本文整理汇总了Python中sys.args方法的典型用法代码示例。如果您正苦于以下问题:Python sys.args方法的具体用法?Python sys.args怎么用?Python sys.args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


在下文中一共展示了sys.args方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pack

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def pack(mol):
    '''Pack the input args of :class:`Mole` to a dict.

    Note this function only pack the input arguments (not the entire Mole
    class).  Modifications to mol._atm, mol._bas, mol._env are not tracked.
    Use :func:`dumps` to serialize the entire Mole object.
    '''
    mdic = {'atom'    : mol.atom,
            'unit'    : mol.unit,
            'basis'   : mol.basis,
            'charge'  : mol.charge,
            'spin'    : mol.spin,
            'symmetry': mol.symmetry,
            'nucmod'  : mol.nucmod,
            'nucprop' : mol.nucprop,
            'ecp'     : mol.ecp,
            '_nelectron': mol._nelectron,
            'verbose' : mol.verbose}
    return mdic 
开发者ID:pyscf,项目名称:pyscf,代码行数:21,代码来源:mole.py

示例2: _update_from_cmdargs_

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def _update_from_cmdargs_(mol):
    # Ipython shell conflicts with optparse
    # pass sys.args when using ipython
    try:
        __IPYTHON__
        #sys.stderr.write('Warn: Ipython shell catchs sys.args\n')
        return
    except Exception:
        pass

    if not mol._built: # parse cmdline args only once
        opts = cmd_args.cmd_args()

        if opts.verbose:
            mol.verbose = opts.verbose
        if opts.max_memory:
            mol.max_memory = opts.max_memory

        if opts.output:
            mol.output = opts.output 
开发者ID:pyscf,项目名称:pyscf,代码行数:22,代码来源:mole.py

示例3: apply

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def apply(self, fn, *args, **kwargs):
        if callable(fn):
            return lib.StreamObject.apply(self, fn, *args, **kwargs)
        elif isinstance(fn, (str, unicode)):
            method = getattr(self, fn.upper())
            return method(*args, **kwargs)
        else:
            raise TypeError('First argument of .apply method must be a '
                            'function/class or a name (string) of a method.') 
开发者ID:pyscf,项目名称:pyscf,代码行数:11,代码来源:mole.py

示例4: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def __init__(self, method, args, args_bak):
        self.method = method
        self.args = args
        self.args_bak = args_bak 
开发者ID:pyscf,项目名称:pyscf,代码行数:6,代码来源:mole.py

示例5: __enter__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def __enter__(self):
        self.method(*self.args) 
开发者ID:pyscf,项目名称:pyscf,代码行数:4,代码来源:mole.py

示例6: _run_zopkio

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def _run_zopkio(self, args):
    import sys, os.path
    pwd = os.path.abspath('.')
    try:
      os.chdir(os.path.join(os.path.dirname(__file__),".."))
      sys.args = args
      print("Running 'zopkio %s %s'"%(args.testfile, args.nopassword))
      from zopkio import __main__ as main
      succeeded, failed = main.call_main(args)
    except:
      os.chdir( pwd )
      raise
    else:
      return succeeded, failed 
开发者ID:linkedin,项目名称:Zopkio,代码行数:16,代码来源:test_zopkio.py

示例7: test_zopkio_launch

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def test_zopkio_launch(self):
    """
    Run server client test suites and
    compare to expected outcome on test failures/successes
    """
    runtime.reset_all()
    args = Args()
    args.testfile = "./examples/server_client/server_client.py"
    succeeded, failed = self._run_zopkio(args)
    self.assertTrue( succeeded >= 4)
    self.assertTrue( failed >= 12) 
开发者ID:linkedin,项目名称:Zopkio,代码行数:13,代码来源:test_zopkio.py

示例8: _reset_service_password_and_respawn

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def _reset_service_password_and_respawn(osutils):
        """Avoid pass the hash attacks from cloned instances."""
        credentials = osutils.reset_service_password()
        if not credentials:
            return

        service_domain, service_user, service_password = credentials
        _, current_user = osutils.get_current_user()
        # Notes(alexcoman): No need to check domain as password reset applies
        # to local users only.
        if current_user != service_user:
            LOG.debug("No need to respawn process. Current user: "
                      "%(current_user)s. Service user: "
                      "%(service_user)s",
                      {"current_user": current_user,
                       "service_user": service_user})
            return

        # Note(alexcoman): In order to avoid conflicts caused by the logging
        # handlers being shared between the current process and the new one,
        # any logging handlers for the current logger object will be closed.
        # By doing so, the next time the logger is called, it will be created
        # under the newly updated process, thus avoiding any issues or
        # conflicts where the logging can't be done.
        logging.release_logging_handlers("cloudbaseinit")

        # Note(alexcoman): In some edge cases the sys.args doesn't contain
        # the python executable. In order to avoid this kind of issue the
        # sys.executable will be injected into the arguments if it's necessary.
        arguments = sys.argv + ["--noreset_service_password"]
        if os.path.basename(arguments[0]).endswith(".py"):
            arguments.insert(0, sys.executable)

        LOG.info("Respawning current process with updated credentials.")
        token = osutils.create_user_logon_session(
            service_user, service_password, service_domain,
            logon_type=osutils.LOGON32_LOGON_BATCH)
        exit_code = osutils.execute_process_as_user(token, arguments)
        LOG.info("Process execution ended with exit code: %s", exit_code)
        sys.exit(exit_code) 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:42,代码来源:init.py

示例9: main

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def main(args=None):
    """
    The main script entry point

    :param list[str] args: the raw arguments list. When not provided
        it defaults to sys.args[1:]
    """
    config = parse_arguments(args)

    # Do connectivity test if requested
    if config.test:
        connectivity_test(config)
        return  # never reached

    # Check WAL destination is not a directory
    if os.path.isdir(config.wal_path):
        exit_with_error("WAL_PATH cannot be a directory: %s" %
                        config.wal_path)

    try:
        # Execute barman put-wal through the ssh connection
        ssh_process = RemotePutWal(config, config.wal_path)
    except EnvironmentError as exc:
        exit_with_error('Error executing ssh: %s' % exc)
        return  # never reached

    # Wait for termination of every subprocess. If CTRL+C is pressed,
    # terminate all of them
    RemotePutWal.wait_for_all()

    # If the command succeeded exit here
    if ssh_process.returncode == 0:
        return

    # Report the exit code, remapping ssh failure code (255) to 3
    if ssh_process.returncode == 255:
        exit_with_error("Connection problem with ssh", 3)
    else:
        exit_with_error("Remote 'barman put-wal' command has failed!",
                        ssh_process.returncode) 
开发者ID:2ndquadrant-it,项目名称:barman,代码行数:42,代码来源:walarchive.py

示例10: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def __init__(self, *args, **kwargs):
        super(ChecksumTarInfo, self).__init__(*args, **kwargs)
        self.data_checksum = None 
开发者ID:2ndquadrant-it,项目名称:barman,代码行数:5,代码来源:walarchive.py

示例11: parse_args

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def parse_args(args=None, parser=None):
    """Parse arguments from sys.argv

    Passing in your own argparser can be user to extend the parser.

    Keyword Args:
        args: override for sys.argv
        parser: Supply your own argparser instance
    """
    parser = parser or create_parser()
    return parser.parse_args(args or sys.argv[1:])


# --- Validators --- 
开发者ID:moderngl,项目名称:moderngl-window,代码行数:16,代码来源:__init__.py

示例12: fitargs

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def fitargs():
    """
    returns the ['cmd-args-list'] dictionary
    :return: dictionary or None
    """
    return fitcfg().get('cmd-args-list', None) 
开发者ID:RackHD,项目名称:RackHD,代码行数:8,代码来源:fit_common.py

示例13: _get_parser_options

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def _get_parser_options(args=None, version="Prototype"):
		"""
		Parsing of passed arguments.

		@param args: Passed arguemnts

		@return: any
		"""
		description = """
	#######################################
	#    GenomeAnnotationPipeline         #
	#    Version {}#
	#######################################

	Pipeline for the extraction of marker genes, clustering and taxonomic classification""".format(version.ljust(25))
		parser = argparse.ArgumentParser(
			usage="python %(prog)s configuration_file_path",
			version="MetagenomeSimulationPipeline TC {}".format(version),
			description=description,
			formatter_class=argparse.RawTextHelpFormatter)
		parser.add_argument(
			"-verbose", "--verbose",
			action='store_true',
			default=False,
			help="display more information!")
		parser.add_argument(
			"-debug", "--debug_mode",
			action='store_true',
			default=False,
			help="tmp folders will not be deleted!")
		parser.add_argument(
			"-log", "--logfile",
			type=str,
			default=None,
			help="pipeline output will written to this log file")

		group_input = parser.add_argument_group('optional config arguments')
		group_input.add_argument(
			"-p", "--max_processors",
			default=None,
			type=int,
			help="number of available processors")
		group_input.add_argument("-s", "--phase", default=None, type=int, choices=[0, 1, 2, 3], help='''
0 -> Full run (Default)
1 -> Marker gene extraction
2 -> Gene alignment and clustering
3 -> Annotation of Genomes
''')
		group_input = parser.add_argument_group('required')
		group_input.add_argument("config_file", type=str, default=None, help="path to the configuration file of the pipeline")

		if args is None:
			return parser.parse_args()
		else:
			return parser.parse_args(args) 
开发者ID:CAMI-challenge,项目名称:CAMISIM,代码行数:57,代码来源:argumenthandler_ga.py

示例14: get_filters

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def get_filters(args,) -> Sequence[Callable[[InstanceConfig], bool]]:
    """Figures out which filters to apply from an args object, and returns them

    :param args: args object
    :returns: list of functions that take an instance config and returns if the instance conf matches the filter
    """
    filters = []

    if args.service:
        filters.append(lambda conf: conf.get_service() in args.service.split(","))

    if args.clusters:
        filters.append(lambda conf: conf.get_cluster() in args.clusters.split(","))

    if args.instances:
        filters.append(lambda conf: conf.get_instance() in args.instances.split(","))

    if args.deploy_group:
        filters.append(
            lambda conf: conf.get_deploy_group() in args.deploy_group.split(",")
        )

    if args.registration:
        normalized_regs = normalize_registrations(
            service=args.service, registrations=args.registration.split(",")
        )
        filters.append(
            lambda conf: any(
                reg in normalized_regs
                for reg in (
                    conf.get_registrations()
                    if hasattr(conf, "get_registrations")
                    else []
                )
            )
        )

    if args.owner:
        owners = args.owner.split(",")

        filters.append(
            # If the instance owner is None, check the service owner, else check the instance owner
            lambda conf: get_team(
                overrides={}, service=conf.get_service(), soa_dir=args.soa_dir
            )
            in owners
            if conf.get_team() is None
            else conf.get_team() in owners
        )

    return filters 
开发者ID:Yelp,项目名称:paasta,代码行数:53,代码来源:status.py

示例15: paasta_status

# 需要导入模块: import sys [as 别名]
# 或者: from sys import args [as 别名]
def paasta_status(args) -> int:
    """Print the status of a Yelp service running on PaaSTA.
    :param args: argparse.Namespace obj created from sys.args by cli"""
    soa_dir = args.soa_dir
    system_paasta_config = load_system_paasta_config()

    return_codes = [0]
    tasks = []
    clusters_services_instances = apply_args_filters(args)
    for cluster, service_instances in clusters_services_instances.items():
        for service, instances in service_instances.items():
            all_flink = all(i == FlinkDeploymentConfig for i in instances.values())
            actual_deployments: Mapping[str, str]
            if all_flink:
                actual_deployments = {}
            else:
                actual_deployments = get_actual_deployments(service, soa_dir)
            if all_flink or actual_deployments:
                deploy_pipeline = list(get_planned_deployments(service, soa_dir))
                tasks.append(
                    (
                        report_status_for_cluster,
                        dict(
                            service=service,
                            cluster=cluster,
                            deploy_pipeline=deploy_pipeline,
                            actual_deployments=actual_deployments,
                            instance_whitelist=instances,
                            system_paasta_config=system_paasta_config,
                            verbose=args.verbose,
                        ),
                    )
                )
            else:
                print(missing_deployments_message(service))
                return_codes.append(1)

    with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
        tasks = [executor.submit(t[0], **t[1]) for t in tasks]  # type: ignore
        for future in concurrent.futures.as_completed(tasks):  # type: ignore
            return_code, output = future.result()
            print("\n".join(output))
            return_codes.append(return_code)

    return max(return_codes) 
开发者ID:Yelp,项目名称:paasta,代码行数:47,代码来源:status.py


注:本文中的sys.args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。