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


Python subprocess32.check_call方法代码示例

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


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

示例1: _rmtree_fast

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def _rmtree_fast(path, ignore_errors=False):
  """
  Delete a file or directory. Uses rsync to delete directories, which
  is among the fastest ways possible to delete large numbers of
  files. Note it can remove some read-only files.

  slashroot.in/which-is-the-fastest-method-to-delete-files-in-linux
  """
  if ignore_errors and not os.path.exists(path):
    return
  if os.path.isdir(path) and not os.path.islink(path):
    with temp_output_dir("empty.", always_clean=True) as empty_dir:
      popenargs = ["rsync", "-r", "--delete", empty_dir + '/', path]
      subprocess.check_call(popenargs)
    os.rmdir(path)
  else:
    os.unlink(path) 
开发者ID:vivlabs,项目名称:instaclone,代码行数:19,代码来源:instaclone.py

示例2: _autodetect_unzip_command

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def _autodetect_unzip_command():
  unzip_cmd = None
  unzip_output = None
  try:
    unzip_output = subprocess.check_output(["unzip", "-v"])
    unzip_cmd = "unzip -q $ARCHIVE"
  except subprocess.CalledProcessError as e:
    pass

  # On MacOS Yosemite, unzip does not support Zip64, but ditto is available.
  # See: https://github.com/vivlabs/instaclone/issues/1
  if not unzip_cmd or not unzip_output or unzip_output.find("ZIP64_SUPPORT") < 0:
    log.debug("did not find 'unzip' with Zip64 support; trying ditto")
    try:
      # ditto has no simple flag to check its version and exit with 0 status code.
      subprocess.check_call(["ditto", "-c", "/dev/null", tempfile.mktemp()])
      unzip_cmd = "ditto -x -k $ARCHIVE ."
    except subprocess.CalledProcessError as e:
      log.debug("did not find ditto")

  if not unzip_cmd:
    raise ArchiveError("Archive handling requires 'unzip' or 'ditto' in path")

  log.debug("unzip command: %s", unzip_cmd)
  return unzip_cmd 
开发者ID:vivlabs,项目名称:instaclone,代码行数:27,代码来源:archives.py

示例3: _upload_file

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def _upload_file(command_template, local_path, remote_loc):
  popenargs = shell_expand_to_popen(command_template,
                                    dict_merge(os.environ,
                                               {"REMOTE": remote_loc,
                                                "LOCAL": local_path}))
  log.info("uploading: %s", " ".join(popenargs))
  # TODO: Find a way to support force here (e.g. add or remove -f to s4cmd)
  subprocess.check_call(popenargs, stdout=SHELL_OUTPUT, stderr=SHELL_OUTPUT,
                        stdin=DEV_NULL) 
开发者ID:vivlabs,项目名称:instaclone,代码行数:11,代码来源:instaclone.py

示例4: _download_file

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def _download_file(command_template, remote_loc, local_path):
  with atomic_output_file(local_path, make_parents=True) as temp_target:
    popenargs = shell_expand_to_popen(command_template,
                                      dict_merge(os.environ,
                                                 {"REMOTE": remote_loc,
                                                  "LOCAL": temp_target}))
    log.info("downloading: %s", " ".join(popenargs))
    # TODO: Find a way to support force here.
    subprocess.check_call(popenargs, stdout=SHELL_OUTPUT, stderr=SHELL_OUTPUT,
                          stdin=DEV_NULL) 
开发者ID:vivlabs,项目名称:instaclone,代码行数:12,代码来源:instaclone.py

示例5: _rsync_dir

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def _rsync_dir(source_dir, target_dir, chmod=None):
  """
  Use rsync to clone source_dir to target_dir.
  Preserves the original owners and permissions.
  As an optimization, rsync also allows perms to be partly modified
  as files are synced.
  """
  popenargs = ["rsync", "-a", "--delete"]
  if chmod:
    popenargs.append("--chmod=%s" % chmod)
  popenargs.append(source_dir.rstrip('/') + '/')
  popenargs.append(target_dir)
  log.info("using rsync for faster copy")
  log.debug("rsync: %r" % popenargs)
  subprocess.check_call(popenargs) 
开发者ID:vivlabs,项目名称:instaclone,代码行数:17,代码来源:instaclone.py

示例6: unzip_dir

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def unzip_dir(source_archive, target_dir):
  popenargs = shell_expand_to_popen(_autodetect_unzip_command(), {"ARCHIVE": source_archive, "DIR": target_dir})
  cd_to = target_dir
  log.debug("using cwd: %s", cd_to)
  log.info("decompress: %s", " ".join(popenargs))
  subprocess.check_call(popenargs, cwd=cd_to, stdout=SHELL_OUTPUT, stderr=SHELL_OUTPUT, stdin=DEV_NULL) 
开发者ID:vivlabs,项目名称:instaclone,代码行数:8,代码来源:archives.py

示例7: up_node1

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def up_node1():
    subproc.check_call(['vagrant', 'destroy', '-f', 'node1'])
    subproc.check_call(['vagrant', 'up', 'node1', '--no-provision'])
    yield "node1 is ready"

    print("Destroying node1...")
    subproc.call(['vagrant', 'destroy', '-f', 'node1'])
    print("Node1 is destroyed.") 
开发者ID:laincloud,项目名称:lain,代码行数:10,代码来源:conftest.py

示例8: up_node2

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def up_node2():
    subproc.check_call(['vagrant', 'destroy', '-f', 'node2'])
    subproc.check_call(['vagrant', 'up', 'node2'])
    yield "node2 is ready"

    print("Destroying node2...")
    subproc.call(['vagrant', 'destroy', '-f', 'node2'])
    print("Node2 is destroyed.") 
开发者ID:laincloud,项目名称:lain,代码行数:10,代码来源:conftest.py

示例9: up_node3

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def up_node3():
    subproc.check_call(['vagrant', 'destroy', '-f', 'node3'])
    subproc.check_call(['vagrant', 'up', 'node3'])
    yield "node3 is ready"

    print("Destroying node3...")
    subproc.call(['vagrant', 'destroy', '-f', 'node3'])
    print("Node3 is destroyed.") 
开发者ID:laincloud,项目名称:lain,代码行数:10,代码来源:conftest.py

示例10: bootstrap

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def bootstrap(up_node1):
    subproc.check_call([
        'vagrant', 'ssh', 'node1', '-c',
        'sudo /vagrant/bootstrap --pypi-mirror -m https://l2ohopf9.mirror.aliyuncs.com -r docker.io/laincloud --vip={}'.
        format(CONFIG.vip)
    ]) 
开发者ID:laincloud,项目名称:lain,代码行数:8,代码来源:conftest.py

示例11: prepare_demo_images

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def prepare_demo_images(bootstrap):
    subproc.check_call([
        'vagrant', 'ssh', 'node1', '-c',
        'sudo sh /vagrant/bootstrap_test/prepare_demo_images.sh'
    ]) 
开发者ID:laincloud,项目名称:lain,代码行数:7,代码来源:conftest.py

示例12: chmod_native

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def chmod_native(path, mode_expression, recursive=False):
  """
  This is ugly and will only work on POSIX, but the built-in Python os.chmod support
  is very minimal, and neither supports fast recursive chmod nor "+X" type expressions,
  both of which are slow for large trees. So just shell out.
  """
  popenargs = ["chmod"]
  if recursive:
    popenargs.append("-R")
  popenargs.append(mode_expression)
  popenargs.append(path)
  subprocess.check_call(popenargs) 
开发者ID:jlevy,项目名称:strif,代码行数:14,代码来源:strif.py

示例13: check_call

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def check_call(cmdline, environ=(), runas=None, **kwargs):
    """Runs command wrapping subprocess.check_call.

    :param cmdline:
        Command to run
    :type cmdline:
        ``list``
    :param environ:
        *optional* Environ variable to set prior to running the command
    :type environ:
        ``dict``
    :param runas:
        *optional* Run as user.
    :type runas:
        ``str``
    """
    _LOGGER.debug('check_call environ: %r, runas: %r, %r',
                  environ, runas, cmdline)

    args = _alias_command(cmdline)
    if runas:
        s6_setguid = _resolve('s6_setuidgid')
        args = s6_setguid + [runas] + args

    # Setup a copy of the environ with the provided overrides
    cmd_environ = dict(os.environ.items())
    cmd_environ.update(environ)

    try:
        rc = subprocess.check_call(args, close_fds=_CLOSE_FDS, env=cmd_environ,
                                   **kwargs)
        _LOGGER.debug('Finished, rc: %d', rc)
        return rc
    except CalledProcessError as exc:
        _LOGGER.error('Command failed: rc:%d', exc.returncode)
        raise 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:38,代码来源:subproc.py

示例14: handle_message

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def handle_message(tm2source, bucket, s3_url, body):
    msg = json.loads(body.decode('utf-8'))
    task_id = msg['id']
    mbtiles_file = task_id + '.mbtiles'

    source = 'tmsource://' + os.path.abspath(tm2source)
    sink = 'mbtiles://' + os.path.abspath(mbtiles_file)

    tilelive_cmd = []
    if msg['type'] == 'pyramid':
        tilelive_cmd = render_pyramid(msg, source, sink)
    elif msg['type'] == 'list':
        tilelive_cmd = render_list(msg, source, sink)
    else:
        raise ValueError("Message must be either of type pyramid or list")

    render_timeout = int(os.getenv('RENDER_TIMEOUT', 5 * 60))
    _, render_time = timing(subprocess.check_call, tilelive_cmd,
                            timeout=render_timeout)
    print('Render MBTiles: {}'.format(naturaltime(render_time)))

    _, optimize_time = timing(optimize_mbtiles, mbtiles_file)
    print('Optimize MBTiles: {}'.format(naturaltime(optimize_time)))

    _, upload_time = timing(upload_mbtiles, bucket, mbtiles_file)
    print('Upload MBTiles : {}'.format(naturaltime(upload_time)))

    download_link = s3_url(mbtiles_file)
    print('Uploaded {} to {}'.format(
        naturalsize(os.path.getsize(mbtiles_file)),
        download_link
    ))

    os.remove(mbtiles_file)

    return create_result_message(task_id, download_link, msg) 
开发者ID:osm2vectortiles,项目名称:osm2vectortiles,代码行数:38,代码来源:export_remote.py

示例15: actualSolve

# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import check_call [as 别名]
def actualSolve(self, lp):
        """Solve a well formulated lp problem"""
        if not self.executable(self.path):
            raise PulpSolverError("PuLP: cannot execute "+self.path)

        # TODO: should we use tempfile instead?
        if not self.keepFiles:
            pid = os.getpid()
            tmpLp = os.path.join(self.tmpDir, "%d-pulp.lp" % pid)
            tmpSol = os.path.join(self.tmpDir, "%d-pulp.sol" % pid)
        else:
            tmpLp = lp.name + "-pulp.lp"
            tmpSol = lp.name + "-pulp.sol"

        lp.writeLP(tmpLp)
        proc = [
            'scip', '-c', 'read "%s"' % tmpLp, '-c', 'optimize',
            '-c', 'write solution "%s"' % tmpSol, '-c', 'quit'
        ]
        proc.extend(self.options)
        if not self.msg:
            proc.append('-q')

        self.solution_time = clock()
        subprocess.check_call(proc, stdout=sys.stdout, stderr=sys.stderr)
        self.solution_time += clock()

        if not os.path.exists(tmpSol):
            raise PulpSolverError("PuLP: Error while executing "+self.path)

        lp.status, values = self.readsol(tmpSol)

        # Make sure to add back in any 0-valued variables SCIP leaves out.
        finalVals = {}
        for v in lp.variables():
            finalVals[v.name] = values.get(v.name, 0.0)

        lp.assignVarsVals(finalVals)

        if not self.keepFiles:
            for f in (tmpLp, tmpSol):
                try:
                    os.remove(f)
                except:
                    pass

        return lp.status 
开发者ID:QuantEcon,项目名称:MatchingMarkets.py,代码行数:49,代码来源:solvers.py


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