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

Python subprocess.check_call函数代码示例

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

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



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

示例1: MakeCoreSdist

 def MakeCoreSdist(self):
   os.chdir(args.grr_src)
   subprocess.check_call([self.PYTHON_BIN64, "setup.py", "sdist",
                          "--dist-dir=%s" % self.BUILDDIR, "--no-make-docs",
                          "--no-make-ui-files", "--no-sync-artifacts"])
   return glob.glob(os.path.join(self.BUILDDIR,
                                 "grr-response-core-*.zip")).pop()
开发者ID:4sp1r3,项目名称:grr,代码行数:7,代码来源:build_windows_templates.py


示例2: archive

def archive(conn, root, source, **kwargs):
  source = path.abspath(source)
  dir = path.dirname(source)
  base = path.basename(source)
  cursor = conn.cursor()
  cursor.execute("INSERT OR IGNORE INTO versions VALUES (:name, 0)", {"name": base})
  cursor.execute("UPDATE versions SET version = version + 1 WHERE name = :name", {"name": base})
  cursor.execute("SELECT version FROM versions WHERE name = :name", {"name": base})
  version = cursor.fetchone()["version"]
  conn.commit()
  archive = "{base}-{version}.tar.gz".format(**locals())
  fullPath = path.join(root, archive)
  commands = ["tar", "--checkpoint=.10000", "-C", dir, "-czf", fullPath, base]
  log(Level.Info, "Running command ", " ".join(commands))
  subprocess.check_call(commands)
  print
  cursor.execute(
      """INSERT INTO items VALUES (
             :name,
             :version,
             CURRENT_TIMESTAMP,
             'Archived',
             :source,
             :archive);
      """,
      {
        "name": base,
        "version": version,
        "source": source,
        "archive": archive,
      })
  conn.commit()
开发者ID:likan999,项目名称:archiver,代码行数:32,代码来源:archiver.py


示例3: initEnKFrun

def initEnKFrun(callback=None,basedir=None,site=None,siteparam=None):
    if not site:
        raise "site is a required parameter"
    if siteparam:
        param = ast.literal_eval(siteparam)
    else:
        raise "Parameters are required. Please submit Paramerers with task submission"
    if not basedir:
        raise "Basedir is required"
    #Create working directory
    newDir = basedir + "celery_data/" + str(initEnKFrun.request.id)
    check_call(["mkdir",newDir])
    os.chdir(newDir)
    #copy matlab code to working directory
    codeDir =basedir + 'enfk_matlab/'
    for file in glob.glob(codeDir + '*'): 
        shutil.copy(file, newDir) 
    #check_call(["cp","-r",codeDir + '*',newDir])
    #set inital Paramters files
    setup_param(newDir,param)
    if callback:
        result=subtask(callback).delay(task_id=str(initEnKFrun.request.id),wkdir=newDir)
        return {'task_id':result.task_id,'task_name':result.task_name}
    else:
        return newDir
开发者ID:ouinformatics,项目名称:cybercomq,代码行数:25,代码来源:enkf.py


示例4: create_profile_F

 def create_profile_F(self):
     """Function to create the SSHTunnel Firefox profile
     All firefox instances must be closed
     (or they can be left open, but the function will killall firefox)        
     """
    
     
     subprocess.call(["killall", "firefox"]) #all firefox instance must be killed
     subprocess.check_call(["firefox","-CreateProfile","SSHTunnel"]) #Create a new Profile named SSHTunnel
   
     
     #Navigate to the profile folder:
     os.chdir('/home/'+ str(LOGNAME) +'/.mozilla/firefox/')
     list_of_items = os.listdir(os.getcwd())
     for folder in list_of_items:
         if 'SSHTunnel' in folder:
             os.chdir(folder)
             break
     else:
         raise Exception("Create new profile for firefox failed")
                     
     
     write_prefs_js()       
     
     self.launch_firefox_instance()
开发者ID:1337micro,项目名称:SSHTunnel,代码行数:25,代码来源:SSHTunnel.py


示例5: build_dist

    def build_dist(self):
        for sdir in self.staging_dirs:
            if os.path.exists(sdir):
                shutil.rmtree(sdir)
        main_stage, ninja_stage = self.staging_dirs
        modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join('mesonbuild/modules/*'))]
        modules = ['mesonbuild.modules.' + x for x in modules if not x.startswith('_')]
        modules += ['distutils.version']
        modulestr = ','.join(modules)
        python = shutil.which('python')
        cxfreeze = os.path.join(os.path.dirname(python), "Scripts", "cxfreeze")
        if not os.path.isfile(cxfreeze):
            print("ERROR: This script requires cx_freeze module")
            sys.exit(1)

        subprocess.check_call([python,
                               cxfreeze,
                               '--target-dir',
                               main_stage,
                               '--include-modules',
                               modulestr,
                               'meson.py'])
        if not os.path.exists(os.path.join(main_stage, 'meson.exe')):
            sys.exit('Meson exe missing from staging dir.')
        os.mkdir(ninja_stage)
        shutil.copy(shutil.which('ninja'), ninja_stage)
        if not os.path.exists(os.path.join(ninja_stage, 'ninja.exe')):
            sys.exit('Ninja exe missing from staging dir.')
开发者ID:MathieuDuponchelle,项目名称:meson,代码行数:28,代码来源:createmsi.py


示例6: stop_dcvoip_process

def stop_dcvoip_process():
    try:
        logger.info("Stopping dcvoip process")
        with open(os.devnull, 'wb') as devnull:
            subprocess.check_call(["sudo", "service", "dcvoip", "stop"], stdout=devnull)
    except (subprocess.CalledProcessError, IOError):
        logging.warning("Unable to stop the dcvoip process")    
开发者ID:Kazade,项目名称:dreampi,代码行数:7,代码来源:dreampi.py


示例7: compare_review

def compare_review(review_spec, branch, remote, rebase=False):
    new_ps = None    # none means latest

    if '-' in review_spec:
        review_spec, new_ps = review_spec.split('-')
    review, old_ps = parse_review_number(review_spec)

    if old_ps is None or old_ps == new_ps:
        raise InvalidPatchsetsToCompare(old_ps, new_ps)

    old_review = build_review_number(review, old_ps)
    new_review = build_review_number(review, new_ps)

    old_branch = fetch_review(old_review, branch, remote)
    checkout_review(old_branch)

    if rebase:
        print('Rebasing %s' % old_branch)
        rebase = rebase_changes(branch, remote, False)
        if not rebase:
            print('Skipping rebase because of conflicts')
            run_command_exc(CommandFailed, 'git', 'rebase', '--abort')

    new_branch = fetch_review(new_review, branch, remote)
    checkout_review(new_branch)

    if rebase:
        print('Rebasing also %s' % new_branch)
        if not rebase_changes(branch, remote, False):
            print("Rebasing of the new branch failed, "
                  "diff can be messed up (use -R to not rebase at all)!")
            run_command_exc(CommandFailed, 'git', 'rebase', '--abort')

    subprocess.check_call(['git', 'diff', old_branch])
开发者ID:chmarr,项目名称:git-review,代码行数:34,代码来源:cmd.py


示例8: get_compressor

def get_compressor(ctools=COMPRESSING_TOOLS):
    global UPTO

    am_dir_pattern = "/usr/share/automake-*"
    am_files_pattern = am_dir_pattern + "/am/*.am"

    if len(glob.glob(am_dir_pattern)) == 0:  # automake is not installed.
        UPTO = STEP_PRECONFIGURE

        logging.warn("Automake not found. The process will go up to the step: " + UPTO)

        return ctools[-1]  # fallback to the default (gzip).

    for ct in ctools:
        # NOTE: bzip2 tries compressing input from stdin even it is invoked
        # with --version option. So give null input (/dev/null) to it.
        c_exists = 0 == subprocess.check_call(
            "%(command)s --version > /dev/null 2> /dev/null < /dev/null" % ct, shell=True
        )

        if c_exists:
            am_support_c = 0 == subprocess.check_call(
                "grep -q -e '^dist-%s:' %s 2> /dev/null" % (ct.command, am_files_pattern), shell=True
            )
            if am_support_c:
                return ct

    # gzip must exist at least and not reached here:
    raise RuntimeError("No compressor found! Aborting...")
开发者ID:masatake,项目名称:packagemaker,代码行数:29,代码来源:environ.py


示例9: sklearn2pmml

def sklearn2pmml(estimator, mapper, pmml, with_repr = False, verbose = False):
	if(not isinstance(estimator, BaseEstimator)):
		raise TypeError("The estimator object is not an instance of " + BaseEstimator.__name__)
	if((mapper is not None) and (not isinstance(mapper, DataFrameMapper))):
		raise TypeError("The mapper object is not an instance of " + DataFrameMapper.__name__)
	cmd = ["java", "-cp", os.pathsep.join(_classpath()), "org.jpmml.sklearn.Main"]
	dumps = []
	try:
		estimator_pkl = _dump(estimator)
		cmd.extend(["--pkl-estimator-input", estimator_pkl])
		dumps.append(estimator_pkl)
		if(with_repr):
			estimator_repr = repr(estimator)
			cmd.extend(["--repr-estimator", estimator_repr])
		if(mapper):
			mapper_pkl = _dump(mapper)
			cmd.extend(["--pkl-mapper-input", mapper_pkl])
			dumps.append(mapper_pkl)
			if(with_repr):
				mapper_repr = repr(mapper)
				cmd.extend(["--repr-mapper", mapper_repr])
		cmd.extend(["--pmml-output", pmml])
		if(verbose):
			print(cmd)
		subprocess.check_call(cmd)
	finally:
		for dump in dumps:
			os.remove(dump)
开发者ID:marsjoy,项目名称:sklearn2pmml,代码行数:28,代码来源:__init__.py


示例10: run_script

def run_script(prefix, dist, action='post-link', env_prefix=None):
    """
    call the post-link (or pre-unlink) script, and return True on success,
    False on failure
    """
    path = join(prefix, 'Scripts' if on_win else 'bin', '.%s-%s.%s' % (
            name_dist(dist),
            action,
            'bat' if on_win else 'sh'))
    if not isfile(path):
        return True
    if on_win:
        try:
            args = [os.environ['COMSPEC'], '/c', path]
        except KeyError:
            return False
    else:
        args = ['/bin/bash', path]
    env = os.environ
    env['PREFIX'] = env_prefix or prefix
    env['PKG_NAME'], env['PKG_VERSION'], env['PKG_BUILDNUM'] = str(dist).rsplit('-', 2)
    try:
        subprocess.check_call(args, env=env)
    except subprocess.CalledProcessError:
        return False
    return True
开发者ID:gitter-badger,项目名称:conda,代码行数:26,代码来源:install.py


示例11: pull_file

 def pull_file(self, device_path, destination_path, remove_original=False):
   """Copies or moves the specified file on the device to the host."""
   subprocess.check_call(self._adb_command([
       'pull', device_path, destination_path]))
   if remove_original:
     subprocess.check_call(self._adb_command([
         'shell', 'rm', device_path]))
开发者ID:pcmoritz,项目名称:mojo,代码行数:7,代码来源:android_shell.py


示例12: prepare_release

def prepare_release(build_number, image_source_path):
    release_dir = "release"
    try:
        os.makedirs(release_dir)
    except FileExistsError:
        pass

    tag = 'builds/%s/%s' % (base_version, build_number)
    subprocess.check_call(['git', 'tag', tag])

    import appcast
    appcast_text = appcast.generate_appcast(image_source_path, updates_template_file, build_number, updates_signing_key_file)
    with open(os.path.join(release_dir, updates_appcast_file), 'w') as appcast_file:
        appcast_file.write(appcast_text)

    import shutil
    copied_image = os.path.join(release_dir, os.path.basename(image_source_path))
    unversioned_image = os.path.join(release_dir, artifact_prefix + ".dmg")
    shutil.copyfile(image_source_path, copied_image)
    shutil.copyfile(image_source_path, unversioned_image)

    publish_release_notes_file = os.path.join(release_dir, os.path.basename(release_notes_file))
    shutil.copyfile(release_notes_file, publish_release_notes_file)
    publish_release_notes_filebase, publish_release_notes_ext = os.path.splitext(publish_release_notes_file)
    publish_release_notes_version_file = "%s-%s%s" % (publish_release_notes_filebase, build_number, publish_release_notes_ext)
    shutil.copyfile(release_notes_file, publish_release_notes_version_file)
开发者ID:BucOder,项目名称:gitx,代码行数:26,代码来源:build.py


示例13: set_versions

def set_versions(base_version, build_number, label):
    print("mvers: " + check_string_output(["agvtool", "mvers", "-terse1"]))
    print("vers:  " + check_string_output(["agvtool", "vers", "-terse"]))
    marketing_version = "%s.%s %s" % (base_version, build_number, label)
    build_version = "%s.%s" % (base_version, build_number)
    subprocess.check_call(["agvtool", "new-marketing-version", marketing_version])
    subprocess.check_call(["agvtool", "new-version", "-all", build_version])
开发者ID:BucOder,项目名称:gitx,代码行数:7,代码来源:build.py


示例14: _commit_and_push

    def _commit_and_push(self):
        """ Commit all the files and push. """

        deploy = self._deploy_branch
        source = self._source_branch
        remote = self._remote_name

        source_commit = uni_check_output(['git', 'rev-parse', source])
        commit_message = (
            'Nikola auto commit.\n\n'
            'Source commit: %s'
            'Nikola version: %s' % (source_commit, __version__)
        )

        commands = [
            ['git', 'add', '-A'],
            ['git', 'commit', '-m', commit_message],
            ['git', 'push', '-f', remote, '%s:%s' % (deploy, deploy)],
            ['git', 'checkout', source],
        ]

        for command in commands:
            self.logger.info("==> {0}".format(command))
            try:
                subprocess.check_call(command)
            except subprocess.CalledProcessError as e:
                self.logger.error(
                    'Failed GitHub deployment — command {0} '
                    'returned {1}'.format(e.cmd, e.returncode)
                )
                sys.exit(e.returncode)
开发者ID:asmeurer,项目名称:nikola,代码行数:31,代码来源:github_deploy.py


示例15: archive_logs

def archive_logs(log_dir):
    """Compress log files in given log_dir using gzip."""
    log_files = []
    for r, ds, fs in os.walk(log_dir):
        log_files.extend(os.path.join(r, f) for f in fs if is_log(f))
    if log_files:
        subprocess.check_call(['gzip', '--best', '-f'] + log_files)
开发者ID:mjs,项目名称:juju,代码行数:7,代码来源:deploy_stack.py


示例16: text_mof

def text_mof(pdf_part, pdf_year, pdf_number, pdf_name):

    s3_url = "https://mgax-mof.s3.amazonaws.com"

    pdf_url = s3_url + "/" + pdf_name

    with temp_dir() as tmp:
        pdf_local_path = tmp / pdf_name
        text_path = tmp / 'plain.txt'

        with pdf_local_path.open('wb') as f:
            resp = requests.get(pdf_url, stream=True)
            assert resp.status_code == 200
            for chunk in FileWrapper(resp.raw):
                f.write(chunk)

        subprocess.check_call(['pdftotext', pdf_local_path, text_path])

        with text_path.open('r') as f:
            raw_text = f.read()

        json = dict([('part', int(pdf_part)),
                     ('year', int(pdf_year)),
                     ('number', int(pdf_number)),
                     ('slug', pdf_name.split('.')[0]),
                     ('text', raw_text)])

        resp = requests.put(flask.current_app.config['ELASTIC_SEARCH_URL']
                            + pdf_name.split('.')[0],
                            data=flask.json.dumps(json))
        assert 200 <= resp.status_code < 300, repr(resp)
开发者ID:mgax,项目名称:hambar109,代码行数:31,代码来源:harvest.py


示例17: start_dcvoip_process

def start_dcvoip_process():
    try:
        logger.info("Starting dcvoip process - Thanks Jonas Karlsson!")
        with open(os.devnull, 'wb') as devnull:    
            subprocess.check_call(["sudo", "service", "dcvoip", "start"], stdout=devnull)    
    except (subprocess.CalledProcessError, IOError):
        logging.warning("Unable to start the dcvoip process")
开发者ID:Kazade,项目名称:dreampi,代码行数:7,代码来源:dreampi.py


示例18: sendpfast

def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, iface=None):
    """Send packets at layer 2 using tcpreplay for performance
    pps:  packets per second
    mpbs: MBits per second
    realtime: use packet's timestamp, bending time with realtime value
    loop: number of times to process the packet list
    iface: output interface """
    if iface is None:
        iface = conf.iface
    argv = [conf.prog.tcpreplay, "--intf1=%s" % iface ]
    if pps is not None:
        argv.append("--pps=%i" % pps)
    elif mbps is not None:
        argv.append("--mbps=%i" % mbps)
    elif realtime is not None:
        argv.append("--multiplier=%i" % realtime)
    else:
        argv.append("--topspeed")

    if loop:
        argv.append("--loop=%i" % loop)

    f = get_temp_file()
    argv.append(f)
    wrpcap(f, x)
    try:
        subprocess.check_call(argv)
    except KeyboardInterrupt:
        log_interactive.info("Interrupted by user")
    except Exception,e:
        log_interactive.error("while trying to exec [%s]: %s" % (argv[0],e))
开发者ID:AP2AMR,项目名称:TuxCut,代码行数:31,代码来源:sendrecv.py


示例19: sendCommand

    def sendCommand(self, jbossHome, controller, user, password, cluster):
        self.fillParameters(jbossHome, controller, user, password)
        startCommand =  self._clisg+cluster+":start-servers"

        print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand)

        subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,startCommand])
开发者ID:redhat-italy,项目名称:eap6-manager,代码行数:7,代码来源:StartClusterCommand.py


示例20: __exit__

 def __exit__(self, exc_type, _value, _traceback):
   for k in self._config_dict:
     if self._previous_values.get(k):
       subprocess.check_call(
           ['git', 'config', '--local', k, self._previous_values[k]])
     else:
       subprocess.check_call(['git', 'config', '--local', '--unset', k])
开发者ID:android,项目名称:platform_external_skia,代码行数:7,代码来源:git_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python subprocess.check_output函数代码示例发布时间:2022-05-27
下一篇:
Python subprocess.call函数代码示例发布时间: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