本文整理汇总了Python中subprocess.check_call函数的典型用法代码示例。如果您正苦于以下问题:Python check_call函数的具体用法?Python check_call怎么用?Python check_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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()
示例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
示例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()
示例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.')
示例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")
示例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])
示例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...")
示例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)
示例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
示例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]))
示例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)
示例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])
示例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)
示例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)