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


Python Popen.wait方法代码示例

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


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

示例1: display

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def display( screen ):
    ppm_name = 'pic.ppm'
    save_ppm( screen, ppm_name )
    try:
        Popen.wait(Popen( ['display', ppm_name], stdin=PIPE, stdout = PIPE ))
    except WindowsError:
        Popen.wait(Popen( ['imdisplay', ppm_name], stdin=PIPE, stdout = PIPE ))
开发者ID:RJZheng1,项目名称:didactic-parakeet,代码行数:9,代码来源:display.py

示例2: submit_job

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def submit_job(command, params, test_run=False):
    from subprocess import Popen, PIPE

    clear_directories('inputs', 'stdout', 'stderr')

    with open(params_path, 'w') as file:
        json.dump(params, file)

    qsub_command = (
            'qsub',
            '-cwd',
            '-S', '/bin/sh',
            '-o', 'stdout',
            '-e', 'stderr',
            '-l', 'h_rt=6:00:00' if not test_run else 'h_rt=0:30:00',
            '-l', 'mem_free=1G',
            '-l', 'arch=linux-x64',
            '-l', 'netapp=1G',
            '-t', '1-{0}'.format(len(params)),
            '-N', command,
    )

    process = Popen(qsub_command, stdin=PIPE)
    process.stdin.write('module load imp-fast;')
    process.stdin.write('PYTHONPATH=.:$PYTHONPATH;')
    process.stdin.write('/netapp/home/kale/.local/bin/python2.7 ' + command)
    process.stdin.close()
    process.wait()
开发者ID:kalekundert,项目名称:ChromosomeModeling,代码行数:30,代码来源:utils.py

示例3: get_cmdline

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
    def get_cmdline(self, proc):
        if mozinfo.os == "win":
            # The psutil.cmdline() implementation on Windows is pretty busted,
            # in particular it doesn't handle getting the command line of a
            # 64-bit process from a 32-bit python process very well.
            #
            # Instead we just shell out the WMIC command which works rather
            # well.
            cmd = "WMIC path win32_process where handle='%d' get Commandline" % (proc.pid)
            process = Popen(cmd.split(), stdout=PIPE)
            (output, err) = process.communicate()
            process.wait()

            # The output of WMIC is something like:
            #   Commandline
            #
            #
            #   path/to/exe --args etc

            buf = StringIO.StringIO(output)
            buf.readline()  # header
            for line in buf:
                if line.strip():
                    return line.strip()

            # If all else fails, just return the executable path.
            return p.exe()
        else:
            return " ".join(proc.cmdline())
开发者ID:EricRahm,项目名称:atsy,代码行数:31,代码来源:stats.py

示例4: config

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def config(output='/opt/canopsis/var/backups'):
	logger = logging.getLogger()
	logger.debug('Config Backup start')
	logger.debug('Output: %s' % output)
	
	logger.debug('Create output dir if not exists')
	if not os.path.exists(output):
		os.makedirs(output)	

	logger.debug('Create temp dir')
	archive_name = 'backup_config'
	tmp_dir = mkdtemp(prefix='/opt/canopsis/tmp/')

	logger.debug('Create file with installed packages')
	export_output = Popen('pkgmgr export', shell=True, stdout=PIPE)
	export_output.wait()
	f = open('/opt/canopsis/etc/.packages', 'w')
	f.writelines(export_output.stdout.read())
	f.close()

	logger.debug('Copy config files into tmp folder')
	shutil.copytree('/opt/canopsis/etc', '%s/%s' % (tmp_dir, archive_name))
	
	logger.debug('Create archive into %s' % output)
	logger.debug('Archive name: %s' % archive_name)
	shutil.make_archive('%s/%s' % (output, archive_name),
						'zip',
						tmp_dir)

	logger.debug('Remove temp dir')
	shutil.rmtree(tmp_dir)

	logger.debug('Config Backup finished')
开发者ID:dmichau,项目名称:canopsis,代码行数:35,代码来源:task_backup.py

示例5: get_rpm_names_from_specfile

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def get_rpm_names_from_specfile(spec_path, source_dir, other=[]):
  cmd = ['rpmspec', '-q', '-D', '_sourcedir %s' % source_dir] + other + \
        ['--qf', '%{NAME}\t%{VERSION}\n%{PROVIDES}\t%{VERSION}\n', spec_path]
  pid = Popen(cmd, stdout=PIPE, stderr=PIPE)
  stdout = pid.communicate()[0][:-1] #get rid of trailing newline
  pid.wait()
  return map(lambda x:x.split('\t'), stdout.splitlines())
开发者ID:andyneff,项目名称:dockmock,代码行数:9,代码来源:search_local.py

示例6: run

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
 def run(self):
     giza_cmd = ['mgiza', self.input()['src2tgt.gizacfg'].fn]
     src2tgt_p = Popen(giza_cmd)
     giza_cmd = ['mgiza', self.input()['tgt2src.gizacfg'].fn]
     tgt2src_p = Popen(giza_cmd)
     src2tgt_p.wait()
     tgt2src_p.wait()
开发者ID:d2207197,项目名称:smttoktag,代码行数:9,代码来源:gentask_giza.py

示例7: exec_interpreter

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def exec_interpreter(code, interp='python'):
    """(str) -> (str, str, int)

       Execute given @code using given interpreter.
       :returns: touple (stdout, strerr, return code).

       .. TODO::
          * Use non-blocking poll instead of wait.
          * Timeout killing
    """
    try:
        p = Popen((interp,), stdin=PIPE, stdout=PIPE, stderr=PIPE)
    except Exception as e:
        return ('',
                'Cannot start interpreter({0}) pipe. Got exception: {1}'.format(interp, str(e)),
                666)
    try:
        p.stdin.write(code)
    except Exception as e:
        return ('',
                'Cannot write to interpreter({0}) pipe. Got exception: {1}'.format(interp, str(e)),
                666)
    p.stdin.close()
    p.wait()
    return (p.stdout.read(), p.stderr.read(), p.returncode)
开发者ID:AOrazaev,项目名称:orazaev,代码行数:27,代码来源:executils.py

示例8: MongodbPlugin

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
class MongodbPlugin(object):

    def __init__(self):
        self.mongo = None
        self.tmpdir = tempfile.mkdtemp()

    def pytest_sessionstart(self, session):
        port = session.config.getvalue('mongodb_port')
        self.mongo = Popen(["mongod", "--dbpath", self.tmpdir,
                            "--port", str(port)],
                           stdin=PIPE, stdout=PIPE, stderr=PIPE)

        for each in range(10):
            if 'waiting for connections' in self.mongo.stdout.readline():
                break
        else:
            raise OSError('Mongodb start timeout.')

    def pytest_sessionfinish(self, session):
        if self.mongo is not None:
            try:
                self.mongo.kill()
                self.mongo.communicate()
                self.mongo.wait()
            finally:
                shutil.rmtree(self.tmpdir)
开发者ID:knsd,项目名称:pytest-mongodb,代码行数:28,代码来源:__init__.py

示例9: cp_file

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def cp_file(from_file, to_file):
    # when copying state.bssid to state, use tor user
    #os.system("sudo -u %s -H cp %s %s" % (TOR_USER, from_file, to_file))
    #shutil.copy2(from_file, to_file)
    p = Popen(['cp', '-p', '--preserve', from_file, to_file])
    p.wait()
    logger.info("cp %s %s" % (from_file, to_file))
开发者ID:isislovecruft,项目名称:tordyguards,代码行数:9,代码来源:tor_change_state.py

示例10: test_exit_status_regular_exit

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def test_exit_status_regular_exit(exit_status, both_debug_modes, both_setsid_modes):
    """dumb-init should exit with the same exit status as the process that it
    supervises when that process exits normally.
    """
    proc = Popen(('dumb-init', 'sh', '-c', 'exit {0}'.format(exit_status)))
    proc.wait()
    assert proc.returncode == exit_status
开发者ID:asottile,项目名称:dumb-init,代码行数:9,代码来源:exit_status_test.py

示例11: compilemc

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
 def compilemc(self, shortest=False):
     print ("Compiling model checker: gcc ... -o pan pan.c")
     if shortest:
         proc = Popen(['gcc', '-o2', '-DSAFETY', '-DCOLLAPSE', '-DVECTORSZ=100000', '-DREACH', '-o', 'pan', 'pan.c'])
     else:
         proc = Popen(['gcc', '-o2', '-DSAFETY', '-DCOLLAPSE', '-DVECTORSZ=100000', '-o', 'pan', 'pan.c'])
     proc.wait()
开发者ID:ClementGGuy,项目名称:orcc,代码行数:9,代码来源:modelchecking.py

示例12: test_exit_status_terminated_by_signal

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def test_exit_status_terminated_by_signal(signal, both_debug_modes, both_setsid_modes):
    """dumb-init should exit with status 128 + signal when the child process is
    terminated by a signal.
    """
    proc = Popen(('dumb-init', 'sh', '-c', 'kill -{0} $$'.format(signal)))
    proc.wait()
    assert proc.returncode == 128 + signal
开发者ID:asottile,项目名称:dumb-init,代码行数:9,代码来源:exit_status_test.py

示例13: read_url_with_cache

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def read_url_with_cache(url, kt_user, kt_pass, kt_file_cache):
    "Read a kontagent file possibly from a cache (store in dir KT_FILECACHE)"
    f = filenameify(url)
    filepath = os.path.join(kt_file_cache, f)
    if os.path.exists(filepath):
        log.info('Kontagent: cache hit: %s', filepath)
        return filepath
    else:
        tmpfile = os.path.join(kt_file_cache, str(hash(url)) + '.tmp')
        command = ['wget', '--user', kt_user, '--password', kt_pass, '-q', '-O', tmpfile, url]
        p = Popen(command, stdin=PIPE)
        p.stdin.close()
        p.wait()
        if p.returncode != 0:
            raise Exception('Unable to retrieve %s' % url)
        if not os.path.exists(os.path.dirname(filepath)):
            try:
                #ensure base directory exists.
                os.makedirs(os.path.dirname(filepath))
            except OSError, e:
                if e.errno == 17:  # File Exists.
                    pass
                else:
                    raise e
        if os.stat(tmpfile).st_size > 0:
            os.rename(tmpfile, filepath)
            log.info('Kontagent: cache store: %s', filepath)
            return filepath
        else:
            raise Exception('Failed to retrieve url %s' % url)
开发者ID:MaNDRaXe,项目名称:PyBabe,代码行数:32,代码来源:kontagent.py

示例14: stop

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
  def stop(self, job_id, configs={}):
    """
    Stops a Samza job using the bin/kill-yarn-job.sh script.

    param: job_id -- A unique ID used to idenitfy a Samza job.
    param: configs -- Map of config key/values pairs. Valid keys include:

    package_id: The package_id for the package that contains the code for job_id.
    Usually, the package_id refers to the .tgz job tarball that contains the
    code necessary to run job_id.
    """
    configs = self._get_merged_configs(configs)
    self._validate_configs(configs, ['package_id'])

    # Get configs.
    package_id = configs.get('package_id')

    # Get the application_id for the job.
    application_id = self.app_ids.get(job_id)

    # Kill the job, if it's been started, or WARN and return if it's hasn't.
    if not application_id:
      logger.warn("Can't stop a job that was never started: {0}".format(job_id))
    else:
      command = "{0} {1}".format(os.path.join(package_id, "bin/kill-yarn-job.sh"), application_id)
      env = self._get_env_vars(package_id)
      p = Popen(command.split(' '), stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env)
      p.wait()
      assert p.returncode == 0, "Command returned non-zero exit code ({0}): {1}".format(p.returncode, command)
开发者ID:bringhurst,项目名称:samza,代码行数:31,代码来源:samza_job_yarn_deployer.py

示例15: exec_cmd2

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import wait [as 别名]
def exec_cmd2(cmd_args, *args, **kwargs):
    """
    Similar to ``exec_cmd``, however does not capture stdout, stderr (therefore
    allowing it to print to console).  All additional ``*args`` and
    ``**kwargs`` are passed directly to ``subprocess.Popen``.  See `Subprocess
    <http://docs.python.org/library/subprocess.html>`_ for more information
    on the features of ``Popen()``.

    Args:
        cmd_args (list): List of command line arguments

    Other Parameters:
        args: Additional arguments are passed to ``Popen()``
        kwargs: Additional keyword arguments are passed to ``Popen()``

    Returns:
        int: The integer return code of the command.

    Example:

        .. code-block:: python

            from cement.utils import shell

            exitcode = shell.exec_cmd2(['echo', 'helloworld'])

    """
    proc = Popen(cmd_args, *args, **kwargs)
    proc.wait()
    return proc.returncode
开发者ID:datafolklabs,项目名称:cement,代码行数:32,代码来源:shell.py


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