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


Python subprocess32.call函数代码示例

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


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


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