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


Python sh.ErrorReturnCode方法代码示例

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


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

示例1: test_dash_in_project_slug

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_dash_in_project_slug(cookies):
    ctx = {'project_slug': "my-package"}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
        sh.python(['setup.py', 'build_sphinx'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例2: test_double_quotes_in_name_and_description

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_double_quotes_in_name_and_description(cookies):
    ctx = {'project_short_description': '"double quotes"',
           'full_name': '"name"name'}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例3: test_single_quotes_in_name_and_description

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_single_quotes_in_name_and_description(cookies):
    ctx = {'project_short_description': "'single quotes'",
           'full_name': "Mr. O'Keeffe"}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例4: test_space_in_project_slug

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_space_in_project_slug(cookies):
    ctx = {'project_slug': "my package"}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
        sh.python(['setup.py', 'build_sphinx'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例5: test_install

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_install(cookies):
    project = cookies.bake()

    assert project.exit_code == 0
    assert project.exception is None

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:17,代码来源:test_project.py

示例6: test_building_documentation_apidocs

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_building_documentation_apidocs(cookies):
    project = cookies.bake(extra_context={'apidoc': 'yes'})

    assert project.exit_code == 0
    assert project.exception is None

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'build_sphinx'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd)

    apidocs = project.project.join('docs', '_build', 'html', 'apidocs')

    assert apidocs.join('my_python_project.html').isfile()
    assert apidocs.join('my_python_project.my_python_project.html').isfile() 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_project.py

示例7: __init__

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def __init__(self, device_dict):
        """
        init device with device dict
        """
        diff = set(device_dict.keys()) - set(YAMLKeyword.__dict__.keys())
        if len(diff) > 0:
            six.print_('Wrong key detected:')
            six.print_(diff)
            raise KeyError(str(diff))
        self.__dict__.update(device_dict)
        if self.system == SystemType.android:
            pass
        elif self.system == SystemType.arm_linux:
            try:
                sh.ssh('-q', '%s@%s' % (self.username, self.address),
                       'exit')
            except sh.ErrorReturnCode as e:
                six.print_('device connect failed, '
                           'please check your authentication',
                           file=sys.stderr)
                raise e

    #####################
    #  public interface #
    ##################### 
开发者ID:XiaoMi,项目名称:mobile-ai-bench,代码行数:27,代码来源:device.py

示例8: run_command_using_sh

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def run_command_using_sh(cmd, env, kwargs):
    "install the sh module in the system Python to have better debugging of CbCommon module installation (pip install sh)"
    import sh
    command_stdout = ''
    command_stderr = ''
    current_working_directory = kwargs.get('cwd')
    executable_file = cmd[0]
    command_args = cmd[1:]
    command_runner = sh.Command(executable_file)
    try:
        output = command_runner(*command_args, _cwd=current_working_directory, _env=env, _out=command_stdout)
        retcode = output.exit_code
    except sh.ErrorReturnCode as e:
        print("sh e.stderr:{}".format(e.stderr))
        retcode = 1
        command_stderr = e.stderr
        print("command STDOUT:{}".format(command_stdout))
        print("command STDOUT:{}".format(command_stderr))
    return command_stderr, command_stdout, retcode 
开发者ID:xBrite,项目名称:flyingcloud,代码行数:21,代码来源:process.py

示例9: rollback

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def rollback(self, paths, msg="Rolling-Back"):
        """
            Rollback last commit to restore previous.
            configuration and commit changes automatically
        """
        for path in paths:
            global git
            wogit = git.bake("-C", "{0}".format(path))
            if os.path.isdir(path):
                if not os.path.isdir(path + "/.git"):
                    Log.error(
                        self, "Unable to find a git repository at {0}"
                              .format(path))
                try:
                    Log.debug(
                        self, "WOGit: git stash --include-untracked at {0}"
                              .format(path))
                    wogit.stash("push", "--include-untracked", "-m {0}"
                                .format(msg))
                except ErrorReturnCode as e:
                    Log.debug(self, "{0}".format(e))
                    Log.error(self, "Unable to git reset at {0} "
                              .format(path))
            else:
                Log.debug(self, "WOGit: Path {0} not present".format(path)) 
开发者ID:WordOps,项目名称:WordOps,代码行数:27,代码来源:git.py

示例10: clone

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def clone(self, repo, path, branch='master'):
        """Equivalent to git clone """
        if not os.path.exists('{0}'.format(path)):
            global git
            try:
                git.clone(
                    '{0}'.format(repo),
                    '{0}'.format(path),
                    '--branch={0}'.format(branch),
                    '--depth=1')
            except ErrorReturnCode as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "Unable to git clone at {0} "
                          .format(path))
        else:
            Log.debug(self, "WOGit: Path {0} already exist".format(path)) 
开发者ID:WordOps,项目名称:WordOps,代码行数:18,代码来源:git.py

示例11: test_execute_and_kill_execution

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_execute_and_kill_execution(self):
        """
        Tests the kill execution option by asserting the execution pid doesn't
        exist.
        """
        dsl_path = resource('dsl/write_pid_node.yaml')
        dep = self.deploy(dsl_path, wait=False, client=self.client)
        do_retries(verify_deployment_env_created, 30, deployment_id=dep.id)
        execution = self.client.executions.start(deployment_id=dep.id,
                                                 workflow_id='install')
        pid = do_retries(self.read_manager_file, file_path='/tmp/pid.txt')
        path = '/proc/{}/status'.format(pid)
        execution = self.client.executions.cancel(execution.id,
                                                  force=True, kill=True)
        self.assertEquals(Execution.KILL_CANCELLING, execution.status)
        # If the process is still running docl.read_file will raise an error.
        # We use do_retries to give the kill cancel operation time to kill
        # the process.
        do_retries(self.assertRaises, excClass=ErrorReturnCode,
                   callableObj=self.read_manager_file,
                   file_path=path) 
开发者ID:cloudify-cosmo,项目名称:cloudify-manager,代码行数:23,代码来源:test_executions.py

示例12: test_custom_yaml

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def test_custom_yaml():
    from sh import ErrorReturnCode, chmod, ldap2pg, rm

    LDAP2PG_CONFIG = 'my-test-ldap2pg.yml'
    rm('-f', LDAP2PG_CONFIG)
    with pytest.raises(ErrorReturnCode):
        ldap2pg(_env=dict(os.environ, LDAP2PG_CONFIG=LDAP2PG_CONFIG))

    yaml = YAML_FMT % os.environ
    with open(LDAP2PG_CONFIG, 'w') as fo:
        fo.write(yaml)

    # Purge env from value set in file. Other are reads from ldaprc.
    # Ensure world readable password is denied
    with pytest.raises(ErrorReturnCode):
        ldap2pg(config=LDAP2PG_CONFIG, _env=ldapfree_env())

    # And that fixing file mode do the trick.
    chmod('0600', LDAP2PG_CONFIG)
    ldap2pg('--config', LDAP2PG_CONFIG, _env=ldapfree_env()) 
开发者ID:dalibo,项目名称:ldap2pg,代码行数:22,代码来源:test_config.py

示例13: build_dockerfile

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def build_dockerfile(self, tag, dockerfile='Dockerfile'):
        log.debug("Running docker build for {}".format(tag))
        cache_flag = '--no-cache=True' if self.no_cache else '--no-cache=False'
        cmds = ['-f', dockerfile, '-t', tag, '--rm', cache_flag, '.']
        log.info("Starting build, this may take some time, please wait...")

        try:
            if utils.VERBOSE:
                self.docker.run_docker_sh('build', cmds, _out=lambda x: log.debug(x.strip()))
            else:
                self.docker.run_docker_sh('build', cmds)
        except sh.ErrorReturnCode as e:
            log.error("Couldn't complete build")
            log.error("Build error - {}".format(e.stderr.decode('utf-8').strip()))
            if not utils.VERBOSE:
                log.error("Build Traceback - \n{}".format(e.stdout.decode('utf-8').strip()))
            raise RuntimeError("Docker Build failed") from None 
开发者ID:nstack,项目名称:stackhut,代码行数:19,代码来源:builder.py

示例14: build_stress

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def build_stress(stress_revision, name=None):
    # Build a stress revision

    try:
        git_id = sh.git('--git-dir={home}/fab/cassandra.git'
                        .format(home=HOME), 'rev-parse', stress_revision).strip()
    except sh.ErrorReturnCode:
        raise AssertionError('Invalid stress_revision: {}'.format(stress_revision))

    path = os.path.join(CASSANDRA_STRESS_PATH, git_id)
    if not os.path.exists(path):
        logger.info("Building cassandra-stress '{}' in '{}'.".format(stress_revision, path))
        os.makedirs(path)
        sh.tar(
            sh.git("--git-dir={home}/fab/cassandra.git".format(home=HOME), "archive", git_id),
            'x', '-C', path
        )
        antcmd('-Dbasedir={}'.format(path), '-f', '{}/build.xml'.format(path),
               'realclean', 'jar', _env={"JAVA_TOOL_OPTIONS": "-Dfile.encoding=UTF8",
                                         "JAVA_HOME": JAVA_HOME})

    name = name if name else stress_revision
    return {name: git_id} 
开发者ID:datastax,项目名称:cstar_perf,代码行数:25,代码来源:benchmark.py

示例15: restore_schema

# 需要导入模块: import sh [as 别名]
# 或者: from sh import ErrorReturnCode [as 别名]
def restore_schema(self, restore_schema_path):
        """Function to restore schema in scylladb from a cql file. This can be
        done manually also directly via cqlsh. This just abstracts the
        interface and is only expected to run on a new/clean cluster.

        :param restore_schema_path: The path of the cql file to be imported in
                                    scylladb
        :returns: Nothing
        :rtype: None

        """
        try:
            self.cqlsh.bake('-f')(restore_schema_path)
        except ErrorReturnCode as e:
            logger.error("Error while restoring schema")
            log_shell_exception_and_exit(e) 
开发者ID:helpshift,项目名称:scyllabackup,代码行数:18,代码来源:snapshot.py


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