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


Python subprocess.check_output方法代码示例

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


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

示例1: _run_test_script

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def _run_test_script(self, filename='mytestscript.py',
                         interpreter=sys.executable):
        # Absolute file path:
        fn = self.tempdir + filename
        try:
            output = check_output([interpreter, fn],
                                  env=self.env, stderr=STDOUT)
        except CalledProcessError as e:
            with open(fn) as f:
                msg = (
                    'Error running the command %s\n'
                    '%s\n'
                    'Contents of file %s:\n'
                    '\n'
                    '%s') % (
                        ' '.join([interpreter, fn]),
                        'env=%s' % self.env,
                        fn,
                        '----\n%s\n----' % f.read(),
                    )
            raise VerboseCalledProcessError(msg, e.returncode, e.cmd, output=e.output)
        return output


# Decorator to skip some tests on Python 2.6 ... 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:27,代码来源:base.py

示例2: train

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def train(dir, docker_tag, image_name):
    """
    Trains ML model(s) locally

    :param dir: [str], source root directory
    :param docker_tag: [str], the Docker tag for the image
    :param image_name: [str], The name of the Docker image
    """
    sagify_module_path = os.path.join(dir, 'sagify_base')
    local_train_script_path = os.path.join(sagify_module_path, 'local_test', 'train_local.sh')
    test_path = os.path.join(sagify_module_path, 'local_test', 'test_dir')

    if not os.path.isdir(test_path):
        raise ValueError("This is not a sagify directory: {}".format(dir))

    output = subprocess.check_output(
        [
            "{}".format(local_train_script_path),
            "{}".format(os.path.abspath(test_path)),
            docker_tag,
            image_name
        ]
    )
    logger.debug(output) 
开发者ID:Kenza-AI,项目名称:sagify,代码行数:26,代码来源:local.py

示例3: deploy

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def deploy(dir, docker_tag, image_name):
    """
    Deploys ML models(s) locally

    :param dir: [str], source root directory
    :param docker_tag: [str], the Docker tag for the image
    :param image_name: [str], The name of the Docker image
    """
    sagify_module_path = os.path.join(dir, 'sagify_base')
    local_deploy_script_path = os.path.join(sagify_module_path, 'local_test', 'deploy_local.sh')
    test_path = os.path.join(sagify_module_path, 'local_test', 'test_dir')

    if not os.path.isdir(test_path):
        raise ValueError("This is not a sagify directory: {}".format(dir))

    output = subprocess.check_output(
        [
            "{}".format(local_deploy_script_path),
            "{}".format(os.path.abspath(test_path)),
            docker_tag,
            image_name
        ]
    )
    logger.debug(output) 
开发者ID:Kenza-AI,项目名称:sagify,代码行数:26,代码来源:local.py

示例4: _run_test_script

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def _run_test_script(self, filename='mytestscript.py',
                         interpreter=sys.executable):
        # Absolute file path:
        fn = self.tempdir + filename
        try:
            output = check_output([interpreter, fn],
                                  env=self.env, stderr=STDOUT)
        except CalledProcessError as e:
            with open(fn) as f:
                msg = (
                    'Error running the command %s\n'
                    '%s\n'
                    'Contents of file %s:\n'
                    '\n'
                    '%s') % (
                        ' '.join([interpreter, fn]),
                        'env=%s' % self.env,
                        fn,
                        '----\n%s\n----' % f.read(),
                    )
            if not hasattr(e, 'output'):
                # The attribute CalledProcessError.output doesn't exist on Py2.6
                e.output = None
            raise VerboseCalledProcessError(msg, e.returncode, e.cmd, output=e.output)
        return output


# Decorator to skip some tests on Python 2.6 ... 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:30,代码来源:base.py

示例5: push

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def push(dir, docker_tag, aws_region, iam_role_arn, aws_profile, external_id, image_name):
    """
    Push Docker image to AWS ECS

    :param dir: [str], source root directory
    :param docker_tag: [str], the Docker tag for the image
    :param aws_region: [str], the AWS region to push the image to
    :param iam_role_arn: [str], the AWS role used to push the image to ECR
    :param aws_profile: [str], the AWS profile used to push the image to ECR
    :param external_id: [str], Optional external id used when using an IAM role
    :param image_name: [str], The name of the Docker image
    """

    sagify_module_path = os.path.relpath(os.path.join(dir, 'sagify_base/'))
    push_script_path = os.path.join(sagify_module_path, 'push.sh')

    if not os.path.isfile(push_script_path):
        raise ValueError("This is not a sagify directory: {}".format(dir))

    output = subprocess.check_output([
                                     "{}".format(push_script_path),
                                     docker_tag,
                                     aws_region,
                                     iam_role_arn,
                                     aws_profile,
                                     external_id,
                                     image_name])
    logger.debug(output) 
开发者ID:Kenza-AI,项目名称:sagify,代码行数:30,代码来源:push.py

示例6: _futurize_test_script

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def _futurize_test_script(self, filename='mytestscript.py', stages=(1, 2),
                              all_imports=False, from3=False,
                              conservative=False):
        params = []
        stages = list(stages)
        if all_imports:
            params.append('--all-imports')
        if from3:
            script = 'pasteurize.py'
        else:
            script = 'futurize.py'
            if stages == [1]:
                params.append('--stage1')
            elif stages == [2]:
                params.append('--stage2')
            else:
                assert stages == [1, 2]
            if conservative:
                params.append('--conservative')
            # No extra params needed

        # Absolute file path:
        fn = self.tempdir + filename
        call_args = [sys.executable, script] + params + ['-w', fn]
        try:
            output = check_output(call_args, stderr=STDOUT, env=self.env)
        except CalledProcessError as e:
            with open(fn) as f:
                msg = (
                    'Error running the command %s\n'
                    '%s\n'
                    'Contents of file %s:\n'
                    '\n'
                    '%s') % (
                        ' '.join(call_args),
                        'env=%s' % self.env,
                        fn,
                        '----\n%s\n----' % f.read(),
                    )
            ErrorClass = (FuturizeError if 'futurize' in script else PasteurizeError)
            raise ErrorClass(msg, e.returncode, e.cmd, output=e.output)
        return output 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:44,代码来源:base.py

示例7: build

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def build(source_dir, requirements_dir, image_name, docker_tag, python_version):
    """
    Builds a Docker image that contains code under the given source root directory.

    Assumes that Docker is installed and running locally.

    :param source_dir: [str], source root directory
    :param requirements_dir: [str], path to requirements.txt
    :param image_name: [str], The name of the Docker image
    :param docker_tag: [str], the Docker tag for the image
    """
    sagify_module_path = os.path.relpath(os.path.join(source_dir, 'sagify_base/'))

    build_script_path = os.path.join(sagify_module_path, 'build.sh')
    dockerfile_path = os.path.join(sagify_module_path, 'Dockerfile')

    train_file_path = os.path.join(sagify_module_path, 'training', 'train')
    serve_file_path = os.path.join(sagify_module_path, 'prediction', 'serve')
    executor_file_path = os.path.join(sagify_module_path, 'executor.sh')

    if not os.path.isfile(build_script_path) or not os.path.isfile(train_file_path) or not \
            os.path.isfile(serve_file_path):
        raise ValueError("This is not a sagify directory: {}".format(source_dir))

    os.chmod(train_file_path, 0o777)
    os.chmod(serve_file_path, 0o777)
    os.chmod(executor_file_path, 0o777)

    target_dir_name = os.path.basename(os.path.normpath(source_dir))

    output = subprocess.check_output(
        [
            "{}".format(build_script_path),
            "{}".format(os.path.relpath(source_dir)),
            "{}".format(os.path.relpath(target_dir_name)),
            "{}".format(dockerfile_path),
            "{}".format(os.path.relpath(requirements_dir)),
            docker_tag,
            image_name,
            python_version
        ]
    )
    logger.debug(output) 
开发者ID:Kenza-AI,项目名称:sagify,代码行数:45,代码来源:build.py

示例8: _futurize_test_script

# 需要导入模块: from future.moves import subprocess [as 别名]
# 或者: from future.moves.subprocess import check_output [as 别名]
def _futurize_test_script(self, filename='mytestscript.py', stages=(1, 2),
                              all_imports=False, from3=False,
                              conservative=False):
        params = []
        stages = list(stages)
        if all_imports:
            params.append('--all-imports')
        if from3:
            script = 'pasteurize.py'
        else:
            script = 'futurize.py'
            if stages == [1]:
                params.append('--stage1')
            elif stages == [2]:
                params.append('--stage2')
            else:
                assert stages == [1, 2]
            if conservative:
                params.append('--conservative')
            # No extra params needed

        # Absolute file path:
        fn = self.tempdir + filename
        call_args = [sys.executable, script] + params + ['-w', fn]
        try:
            output = check_output(call_args, stderr=STDOUT, env=self.env)
        except CalledProcessError as e:
            with open(fn) as f:
                msg = (
                    'Error running the command %s\n'
                    '%s\n'
                    'Contents of file %s:\n'
                    '\n'
                    '%s') % (
                        ' '.join(call_args),
                        'env=%s' % self.env,
                        fn,
                        '----\n%s\n----' % f.read(),
                    )
            ErrorClass = (FuturizeError if 'futurize' in script else PasteurizeError)

            if not hasattr(e, 'output'):
                # The attribute CalledProcessError.output doesn't exist on Py2.6
                e.output = None
            raise ErrorClass(msg, e.returncode, e.cmd, output=e.output)
        return output 
开发者ID:alfa-addon,项目名称:addon,代码行数:48,代码来源:base.py


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