• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subprocess32.call函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run_experiment

    def run_experiment(self, timeout, filename):
        status, value, db = self.get_status(filename)
        if status == Experiment.DONE: return
        if status == Experiment.TIMEOUT and value >= int(timeout): return

        # remove output and timeout files
        if os.path.isfile(filename): os.unlink(filename)
        timeout_filename = "{}.timeout".format(filename)
        if os.path.isfile(timeout_filename): os.unlink(timeout_filename)

        print("Performing {}... ".format(self.name), end='')
        sys.stdout.flush()

        try:
            with open(filename, 'w+') as out:
                call(self.call, stdout=out, stderr=out, timeout=timeout)
        except KeyboardInterrupt:
            os.unlink(filename)
            print("interrupted!")
            sys.exit()
        except OSError:
            os.unlink(filename)
            print("OS failure! (missing executable?)")
            sys.exit()
        except TimeoutExpired:
            with open(timeout_filename, 'w') as to: to.write(str(timeout))
            print("timeout!")
        else:
            status, value, db = self.get_status(filename)
            if status == Experiment.DONE: print("done; {}!".format(value))
            else: print("not done!")
        time.sleep(2)
开发者ID:utwente-fmt,项目名称:sylvan-sttt,代码行数:32,代码来源:exp.py


示例2: sketchupl

def sketchupl(firmware):
    sketchpath = os.path.join(sdir, "sketches", firmware)
    if os.path.exists(sketchpath):
        errorkey = int(time.time())
        cuser = g.user.nickname
        if host == "win":
            output = subprocess.call(
                [rfpath, "-h", host, "-s", sketchpath, "-r", "-e", errorkey, "-c", cuser], shell=True
            )
            print "********************************************************************"
            print output
            print "********************************************************************"
        else:
            output = subprocess.call(
                ["%s -h %s -s %s -r -e %s -c %s" % (rfpath, host, sketchpath, errorkey, cuser)], shell=True
            )
            print "********************************************************************"
            print output
            print "********************************************************************"
        if output == 0:
            print "Subprocess call complete with " + str(output) + " errors"
            return messagereturn(cuser, errorkey, None, "fullcycle")
        else:
            print "Error uploading firmware to devices"
            print "ERROR 4: Subprocess call complete with " + str(output) + " errors"
            return messagereturn(cuser, errorkey, None, "fullcycle")
    else:
        # Firmware specified does not exist, explicitly handled through messagereturn
        print sketchpath
        return messagereturn(None, None, 34, None)
开发者ID:squarenomad,项目名称:webot,代码行数:30,代码来源:serialcon.py


示例3: perform_git_install

def perform_git_install(use_pyqt5):
    """
    Performs a git-based install.
    """
    if not IS_ROOT:
        root_warning()
    if use_pyqt5:
        if PYTHON3_OK:
            run_cmd = ("make", "PYQT=5", "PYTHON=python3")
        else:
            run_cmd = ("make", "PYQT=5")
    else:
        if PYTHON3_OK:
            run_cmd = ("make", "PYTHON=python3")
        else:
            run_cmd = ("make")
    try:
        code = subprocess.call(run_cmd)
    except OSError as errmsg:
        if errmsg.errno == errno.ENOENT:
            print("\nError: 'make' not found. It's either not installed or "
                  "not in the PATH environment variable like expected.")
            return
    if code == 0:
        print("\nCustomizer has been built from git.")
    else:
        print("\nCustomizer could not build properly. If this is caused"
              " by edits you have made to the code you can try the repair"
              " option from the Maintenance submenu")
    if not IS_ROOT:
        code = subprocess.call(("sudo", "make", "install"))
        if code == 0:
            print("\nCustomizer has been installed from git.")
        else:
            print("The installation has failed.")
开发者ID:clearkimura,项目名称:Customizer,代码行数:35,代码来源:installer.py


示例4: run_command

 def run_command(self, thefile):
     new_command = []
     for item in self.command:
         if item == "%f":
             item = thefile
         new_command.append(item)
     subprocess.call(new_command)
开发者ID:11110101,项目名称:when-changed,代码行数:7,代码来源:whenchanged.py


示例5: execute_link

def execute_link(link_cmd_args, record_byproducts):
  """
  <Purpose>
    Executes the passed command plus arguments in a subprocess and returns
    the return value of the executed command. If the specified standard output
    and standard error of the command are recorded and also returned to the
    caller.

  <Arguments>
    link_cmd_args:
            A list where the first element is a command and the remaining
            elements are arguments passed to that command.
    record_byproducts:
            A bool that specifies whether to redirect standard output and
            and standard error to a temporary file which is returned to the
            caller (True) or not (False).

  <Exceptions>
    TBA (see https://github.com/in-toto/in-toto/issues/6)

  <Side Effects>
    Executes passed command in a subprocess and redirects stdout and stderr
    if specified.

  <Returns>
    - A dictionary containg standard output and standard error of the
      executed command, called by-products.
      Note: If record_byproducts is False, the dict values are empty strings.
    - The return value of the executed command.
  """
  # XXX: The first approach only redirects the stdout/stderr to a tempfile
  # but we actually want to duplicate it, ideas
  #  - Using a pipe won't work because processes like vi will complain
  #  - Wrapping stdout/sterr in Python does not work because the suprocess
  #    will only take the fd and then uses it natively
  #  - Reading from /dev/stdout|stderr, /dev/tty is *NIX specific

  # Until we come up with a proper solution we use a flag and let the user
  # decide if s/he wants to see or store stdout/stderr
  # btw: we ignore them in the layout anyway

  if record_byproducts:
    # XXX: Use SpooledTemporaryFile if we expect very large outputs
    stdout_file = tempfile.TemporaryFile()
    stderr_file = tempfile.TemporaryFile()

    return_value = subprocess.call(link_cmd_args,
        stdout=stdout_file, stderr=stderr_file)

    stdout_file.seek(0)
    stderr_file.seek(0)

    stdout_str = stdout_file.read()
    stderr_str = stderr_file.read()

  else:
      return_value = subprocess.call(link_cmd_args)
      stdout_str = stderr_str = ""

  return {"stdout": stdout_str, "stderr": stderr_str}, return_value
开发者ID:team-ferret,项目名称:pip-toto,代码行数:60,代码来源:runlib.py


示例6: superpose

    def superpose(self):
        """superpose and copy the referenced protein and ligand
        """
        result = json.loads(QueryVinaResultOnBioLipFixedPocket(
            self.lig_pdb).output().open('r').read())
        dset = read2Df(result, self.lig_pdb)
        dset = similarPocketsLigands(clean(dset), minimum_Tc=0.2)
        work_dir = os.path.join(self.workdir(), 'superpose')
        try:
            os.makedirs(work_dir)
        except Exception:
            pass

        mob_pdb = self.append_ligand()
        for template_pdb in dset.index:
            ref_pdb = Path(template_pdb).prtPdb
            lig_code = Path(template_pdb).lig_code
            ref_lig = Path(lig_code).ligPdb() + '.pdb'
            sup_pdb = os.path.join(work_dir, lig_code + '.sup.pdb')
            cmd = shlex.split("perl %s all %s %s %s" %
                              (self.superpose_perl, ref_pdb, mob_pdb, sup_pdb))
            subprocess32.call(cmd)

            shutil.copy(ref_pdb, work_dir)
            shutil.copy(ref_lig, work_dir)
开发者ID:EricTing,项目名称:extended-contact-mode-score,代码行数:25,代码来源:superpose.py


示例7: cli

def cli(force):
    """
    Update AerisCloud
    """
    if not force and config.get('github', 'enabled', default=False) == 'true':
        client = Github().gh
        repo = client.repository('aeriscloud', 'aeriscloud')
        latest_release = repo.iter_releases().next()
        latest_version = latest_release.tag_name[1:]

        if semver.compare(version, latest_version) != -1:
            click.secho('AerisCloud is already up to date!', fg='green')
            sys.exit(0)

        click.echo('A new version of AerisCloud is available: %s (%s)' % (
            click.style(latest_version, fg='green', bold=True),
            click.style(latest_release.name, bold=True)
        ))

    # retrieve install script in a tmpfile
    tmp = tempfile.NamedTemporaryFile()
    r = requests.get('https://raw.githubusercontent.com/' +
                     'AerisCloud/AerisCloud/develop/scripts/install.sh')
    if r.status_code != 200:
        fatal('error: update server returned %d (%s)' % (
            r.status_code, r.reason))

    tmp.write(r.content)
    tmp.flush()

    os.environ['INSTALL_DIR'] = aeriscloud_path
    call(['bash', tmp.name])

    tmp.close()
开发者ID:AerisCloud,项目名称:AerisCloud,代码行数:34,代码来源:update.py


示例8: timeout_func

 def timeout_func():
     self.logger.debug("%s: time limit exceeded; killing docker container" % (user,))
     ran_to_completion[0] = False
     try:
         subprocess.call(['docker', 'rm', '-f', docker_name])
     except:
         pass
开发者ID:chenclee,项目名称:utacm_icpc_autojudge,代码行数:7,代码来源:judge.py


示例9: run

    def run(self):
        nullFile = open('/dev/null','w')
        #logging.info("Starting FFMPEG")

        logging.info("Start up FFmpeg %s"%Config.FFMPEG_COMMAND)
        subprocess32.call(Config.FFMPEG_COMMAND,stdout=nullFile,stderr=nullFile)
        logging.info("FFMPEG ends!")
开发者ID:elliott-wen,项目名称:IWatch,代码行数:7,代码来源:ffmpeg.py


示例10: run

    def run(self, logdir):
        """
        Execute the command as a subprocess and log its output in logdir.

        :param logdir: Path to a log directory.
        """
        env = os.environ.copy()
        if "PATH" not in env:
            env["PATH"] = "/usr/bin:/bin"
        locale = settings.get_value("sysinfo.collect", "locale", str, None)
        if locale:
            env["LC_ALL"] = locale
        logf_path = os.path.join(logdir, self.logf)
        stdin = open(os.devnull, "r")
        stdout = open(logf_path, "w")
        try:
            subprocess.call(self.cmd, stdin=stdin, stdout=stdout,
                            stderr=subprocess.STDOUT, shell=True, env=env)
        finally:
            for f in (stdin, stdout):
                f.close()
            if self._compress_log and os.path.exists(logf_path):
                process.run('gzip -9 "%s"' % logf_path,
                            ignore_status=True,
                            verbose=False)
开发者ID:apahim,项目名称:avocado,代码行数:25,代码来源:sysinfo.py


示例11: timeout_func

 def timeout_func():
     self.logger.debug("%s: time limit exceeded; killing docker container" % (user,))
     ran_to_completion[0] = False
     try:
         subprocess.call('docker rm -f %s' % (docker_name,), shell=True)
     except:
         pass
开发者ID:projectstowork1,项目名称:utacm_icpc_autojudge,代码行数:7,代码来源:judge.py


示例12: runPkcombu

def runPkcombu(a_path, b_path, oam_path):
    FNULL = open(os.devnull, 'w')
    cmds = ["pkcombu",
            "-A", a_path,
            "-B", b_path,
            "-oam", oam_path]
    subprocess32.call(cmds, stdout=FNULL, stderr=subprocess32.STDOUT)
开发者ID:EricTing,项目名称:extended-contact-mode-score,代码行数:7,代码来源:astex_xcms.py


示例13: abacas_scaffold

def abacas_scaffold (contigs, reference, outdir, abacas_dir=None):
	if not abacas_dir: abacas_dir = '/home/anna/bioinformatics/bioprograms/Abacas/abacas.pl'
	abacas_out = outdir + 'abacas_out/'
	abacas = ['perl', abacas_dir + 'abacas.pl']
	abacas_options = ['-r', reference, '-q', contigs, '-b', '-c', '-m', '-p', nucmer]
	call(abacas + abacas_options)
	return abacas_out
开发者ID:AnnaNenarokova,项目名称:ngs,代码行数:7,代码来源:scaffold_abacas.py


示例14: trimc_trim

def trimc_trim (file_fw, file_rv, outdir, trimc_dir=None):
	if not trimc_dir: trimc_dir = '/home/anna/bioinformatics/bioprograms/Trimmomatic-0.32/'
	trim_out = outdir + 'trim_out/'
	if not os.path.exists(trim_out):
	    os.makedirs(trim_out)

	trimlog = trim_out +'trimlog'
	paired_out_fw = trim_out + 'paired_out_fw' + '.fastq'
	unpaired_out_fw = trim_out + 'unpaired_out_fw' + '.fastq'
	paired_out_rv = trim_out + 'paired_out_rv' + '.fastq'
	unpaired_out_rv = trim_out + 'unpaired_out_rv' + '.fastq'

	adapters_file = trimc_dir + 'adapters/'+ "illumina.fasta"

	trimmomatic = ['java', '-jar', trimc_dir + 'trimmomatic-0.32.jar']
	# trim_options = ['PE', '-threads', str(THREADS), '-phred33', '-trimlog', trimlog, file_fw, file_rv, 
	# 				paired_out_fw, unpaired_out_fw, paired_out_rv, unpaired_out_rv,
	# 				'ILLUMINACLIP:'+ adapters_file + ':2:15:15:8:true', 'LEADING:3', 'TRAILING:3', 'SLIDINGWINDOW:4:5',  
	# 				'MAXINFO:200:0.2', 'MINLEN:5' ] 
	trim_options = ['PE', '-threads', str(THREADS), '-phred33', '-trimlog', trimlog, file_fw, file_rv, 
				paired_out_fw, unpaired_out_fw, paired_out_rv, unpaired_out_rv, 'TRAILING:3', 'SLIDINGWINDOW:4:25', 'MINLEN:100' ] 

	trim = trimmomatic + trim_options
	print ' '.join(trim)
	call(trim)
	return trim_out
开发者ID:AnnaNenarokova,项目名称:ngs,代码行数:26,代码来源:trim.py


示例15: settings

 def settings(data):
   call(['touch',data['home_dir']+'/.ssh/config'])
   config_path = data['home_dir']+'/.ssh/config'
   if os.path.isfile(config_path):
     config_file = open(config_path,'wt')
     config_file.write('Host *\n\tStrictHostKeyChecking no\n')
     config_file.close()
开发者ID:abhijitmoha17,项目名称:slen-utils,代码行数:7,代码来源:identity.py


示例16: do_cmd

def do_cmd(cmd, tmp_file, cargs):

    out = []

    if cargs.verbose:
        print "    CMD: %s" % cmd

    fh = None
    if tmp_file:
        fh = open(tmp_file, 'w')
    else:
        fh = open(os.devnull, 'w')

    if cargs.verbose and not tmp_file:
        subprocess.call(cmd, stdin=None, shell=True)
    else:
        subprocess.call(cmd, stdin=None,
                stdout=fh, stderr=subprocess.STDOUT, shell=True)

    fh.close()

    if tmp_file:
        with open(tmp_file, 'r') as f:
            for line in f:
                out.append(line.rstrip('\n'))

    return out
开发者ID:ThePatrickStar,项目名称:fot-cov,代码行数:27,代码来源:run.py


示例17: spades_assemble

def spades_assemble(outdir, test=None, reads = None, file_fw=None, file_rv=None, spades_dir=None, bbduk_out = None, trimc_out=None, RAM=6):
	if not spades_dir: spades_dir = '/home/anna/bioinformatics/bioprograms/SPAdes-3.1.1-Linux/bin/'

	spades_out = outdir + 'spades_out/'
	spades = spades_dir + './spades.py'

	if test: spades_assemble= [spades, '--test'] # Test SPAdes

	else:

		if trimc_out:
			files = {'PEfw' : 'paired_out_fw.fastq', 'PErv' : 'paired_out_rv.fastq', 
					 'UPfw': 'unpaired_out_fw.fastq', 'UPrv': 'unpaired_out_rv.fastq'}
			for key in files:
				files[key] = trimc_out + files[key]
				spades_options = ['-1', files['PEfw'], '-2', files['PErv'], '-s', files['UPfw'], '-s', files['UPrv'], 
								  '-o', spades_out, '-m '+ str(RAM), '--careful']
				spades_assemble= [spades] + spades_options

		elif file_fw and file_rv:
			spades_options = ['-o', spades_out, '-m '+ str(RAM), '--careful', '--only-assembler']
			spades_assemble = [spades, '-1', file_fw, '-2', file_rv] + spades_options

		elif reads: 
			spades_options = ['-o', spades_out, '-m '+ str(RAM), '--only-assembler']
			spades_assemble = [spades, '-s', reads] + spades_options

		else: print "Error: spades_assemble haven't get needed values"

		if not os.path.exists(spades_out): os.makedirs(spades_out)
		call(spades_assemble)

	return spades_out
开发者ID:AnnaNenarokova,项目名称:ngs,代码行数:33,代码来源:spades_assemble.py


示例18: test_case

def test_case (testname, timeout, prog_name, checker):
  import subprocess32
  try:
    q=subprocess32.call(
                          ("./"+prog_name,),
                          stdin=open(testname+".in", "r"),
                          stdout=open(testname+".test", "w"),
                          timeout=timeout
                        )
  except:
    return (testname, 2)
  if q!=0:
    return (testname, "program returned code {}.".format(q))
  if checker=="diff":
    return (
            testname,
            subprocess32.call(
                                ("diff", "-qb", testname+".out", testname+".test"),
                                stdout=open("/dev/null", "w")
                              )
            )
  else:
    return (
            testname,
            subprocess32.call(
                                ("./"+checker, testname+".out", testname+".test", testname+".in"),
                                stdout=open("/dev/null", "w")
                              )
            )
开发者ID:quinor,项目名称:oi_tester,代码行数:29,代码来源:pp_workers.py


示例19: run_apoc

 def run_apoc(self):
     subprocess32.call(["mkdir", "-p", self._mydir()])
     paths = [_.output().path for _ in self.requires()]
     cmd = [APOC_BIN] + paths
     print " ".join(cmd)
     stdout = subprocess32.check_output(cmd)
     return stdout
开发者ID:EricTing,项目名称:extended-contact-mode-score,代码行数:7,代码来源:run_control_apoc.py


示例20: test_app_is_uninstalled

def test_app_is_uninstalled(appiumSetup, moduleSetup, testSetup):
    print 'in test app uninstalled'
    #setup.setup_appium_driver(app=config.app)
    # time.sleep(5)
    subprocess32.call(['adb', 'uninstall', config.app_package])
    app_package = subprocess32.check_output(['adb', '-s', config.udid, 'shell', 'pm list packages', '|', 'grep', config.app_package])
    assert not app_package, 'app is not uninstalled, %s not found' % config.app_package
开发者ID:skapil,项目名称:appmbtest,代码行数:7,代码来源:tests_sanity.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python subprocess32.check_call函数代码示例发布时间:2022-05-27
下一篇:
Python subprocess2.communicate函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap