本文整理汇总了Python中shell.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __rebaseFile
def __rebaseFile( self , file , base ):
"""__rebaseFile(f,b)
Execute the command to rebase file f to base address b.
"""
cmd = '%s -v -b 0x%x %s' % ( self.__rebaseTool , base , file )
shell.run( cmd )
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:7,代码来源:rebase_exe.py
示例2: addDirectories
def addDirectories(self, dirNames):
for dirName in dirNames:
parent = os.path.dirname(dirName)
if parent and parent != "/" and not os.path.exists(parent + "/CVS"):
self.addDirectories((parent,))
if not os.path.exists(dirName + "/CVS"):
shell.run(self.log, "cvs", "add", dirName)
开发者ID:mikjo,项目名称:bigitr,代码行数:7,代码来源:cvs.py
示例3: apply
def apply(doc):
output_dir = config.output_dir()
if not os.path.exists(output_dir): os.makedirs(output_dir)
log = planet.getLogger(config.log_level(),config.log_format())
# Go-go-gadget-template
for template_file in config.template_files():
shell.run(template_file, doc)
# Process bill of materials
for copy_file in config.bill_of_materials():
dest = os.path.join(output_dir, copy_file)
for template_dir in config.template_directories():
source = os.path.join(template_dir, copy_file)
if os.path.exists(source): break
else:
log.error('Unable to locate %s', copy_file)
continue
mtime = os.stat(source).st_mtime
if not os.path.exists(dest) or os.stat(dest).st_mtime < mtime:
dest_dir = os.path.split(dest)[0]
if not os.path.exists(dest_dir): os.makedirs(dest_dir)
log.info("Copying %s to %s", source, dest)
shutil.copyfile(source, dest)
shutil.copystat(source, dest)
开发者ID:3rdandUrban-dev,项目名称:Nuxleus,代码行数:27,代码来源:splice.py
示例4: apply
def apply(doc):
output_dir = config.output_dir()
if not os.path.exists(output_dir): os.makedirs(output_dir)
log = planet.logger
planet_filters = config.filters('Planet')
# Go-go-gadget-template
for template_file in config.template_files():
output_file = shell.run(template_file, doc)
# run any template specific filters
if config.filters(template_file) != planet_filters:
output = open(output_file).read()
for filter in config.filters(template_file):
if filter in planet_filters: continue
if filter.find('>')>0:
# tee'd output
filter,dest = filter.split('>',1)
tee = shell.run(filter.strip(), output, mode="filter")
if tee:
output_dir = planet.config.output_dir()
dest_file = os.path.join(output_dir, dest.strip())
dest_file = open(dest_file,'w')
dest_file.write(tee)
dest_file.close()
else:
# pipe'd output
output = shell.run(filter, output, mode="filter")
if not output:
os.unlink(output_file)
break
else:
handle = open(output_file,'w')
handle.write(output)
handle.close()
# Process bill of materials
for copy_file in config.bill_of_materials():
dest = os.path.join(output_dir, copy_file)
for template_dir in config.template_directories():
source = os.path.join(template_dir, copy_file)
if os.path.exists(source): break
else:
log.error('Unable to locate %s', copy_file)
log.info("Template search path:")
for template_dir in config.template_directories():
log.info(" %s", os.path.realpath(template_dir))
continue
mtime = os.stat(source).st_mtime
if not os.path.exists(dest) or os.stat(dest).st_mtime < mtime:
dest_dir = os.path.split(dest)[0]
if not os.path.exists(dest_dir): os.makedirs(dest_dir)
log.info("Copying %s to %s", source, dest)
if os.path.exists(dest): os.chmod(dest, 0644)
shutil.copyfile(source, dest)
shutil.copystat(source, dest)
开发者ID:AlexBaranosky,项目名称:planet.clojure,代码行数:59,代码来源:splice.py
示例5: add_script
def add_script(cluster_id, schema_file, script_file):
schema_path = 's3://shareablee-hive/tmp/scripts/%s' % uuid.uuid4()
script_path = 's3://shareablee-hive/tmp/scripts/%s' % uuid.uuid4()
shell.run('aws s3 cp', schema_file, schema_path)
shell.run('aws s3 cp', script_file, script_path)
add_step(cluster_id, 'copy schema', 'aws', 's3', 'cp', schema_path, '/tmp/schema.hql')
add_step(cluster_id, 'copy script', 'aws', 's3', 'cp', script_path, '/tmp/script.hql')
add_step(cluster_id, 'run script', 'hive', '-i', '/tmp/schema.hql', '-f', '/tmp/script.hql')
开发者ID:shareablee,项目名称:py-aws,代码行数:8,代码来源:emr.py
示例6: setenforce
def setenforce(mode):
""" Sets enforcing mode of SElinux
:param mode: Enforcing mode from [Permissive, Enforcing]
:param type: ``str``
:raises: AssertionError
"""
assert mode in ["Permissive", "Enforcing"]
shell.run("/usr/sbin/setenforce %s" % mode)
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:9,代码来源:selinux.py
示例7: infoDiff
def infoDiff(self, since=None, until='HEAD'):
if since:
shell.run(self.log, 'git', 'diff',
'--stat=200',
'--patch', '--minimal', '--irreversible-delete',
'%s..%s' %(since, until))
else:
shell.run(self.log, 'git', 'diff',
'--stat=200',
'--patch', '--minimal', '--irreversible-delete')
开发者ID:pombreda,项目名称:bigitr,代码行数:10,代码来源:git.py
示例8: is_elf
def is_elf(filename):
""" Checks whether file is ELF executable
:param filename: file name to check
:type filename: ``str``
:returns: Whether file is ELF executable
"""
try:
shell.run("readelf -h %s" % filename)
return True
except AssertionError:
return False
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:13,代码来源:elf.py
示例9: install
def install(package_name):
""" Does the 'yum install <package>' command.
:param package_name: Name of the package to install (eg. katello-all)
:type package_name: str
:raises: AssertionError
"""
# Install it
text = shell.run("yum -y install %s" % (package_name))
# Verify it
shell.run("rpm -q %s" % (package_name))
return rpm.check_for_errors(text)
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:13,代码来源:yum.py
示例10: package_installed
def package_installed(package):
""" Returns whether is package installed or not
:param package: Package name
:type package: ``str``
:returns: ``True`` when package is installed, otherwise ``False``
:rtype: ``bool``
"""
try:
shell.run("rpm -q %s" % package)
return True
except AssertionError:
return False
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:14,代码来源:rpm.py
示例11: remove
def remove(package_name):
""" Does the 'yum remove <package>' command.
:param package_name: Name of the package to be removed (eg. katello-all)
:type package_name: str
:raises: AssertionError
"""
# Remove it
text = shell.run("yum -y remove %s" % (package_name))
# Verify it
shell.run("rpm -q %s" % (package_name), errorcode=1)
return text
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:14,代码来源:yum.py
示例12: commit
def commit(self, message):
fd, name = tempfile.mkstemp(".bigitr")
os.write(fd, message)
# flat list: ['-s', 'A=a', '-s', 'B=b']
cvsvars = sum([["-s", x] for x in self.ctx.getCVSVariables(self.repo)], [])
if self.mapped_branch is not None:
commitargs = ["commit", "-r", self.branch, "-R", "-F", name]
else:
commitargs = ["commit", "-R", "-F", name]
try:
shell.run(self.log, "cvs", *(cvsvars + commitargs))
finally:
os.remove(name)
os.close(fd)
开发者ID:mikjo,项目名称:bigitr,代码行数:14,代码来源:cvs.py
示例13: process_module
def process_module(self, imodule):
if imodule.type in ["cvs", "distribution"]:
tmpdir="branch_tmp_"+str(distributions.my_get_thread_ident())
shell.rm(tmpdir)
try:
if imodule.type == "cvs":
imodule.checkout(
date = self.source_date,
tag = self.source_tag,
as = tmpdir)
else:
cvs.Checkout(self.source_tag or imodule.cvs_tag,
"distribution",
imodule.cvs_root,
tmpdir,
self.source_date or imodule.cvs_date)
cmd='cvs tag %s %s "%s"' %( self.cvs_flags,self.dash_b, self.tag )
print "Running: %s (in %s + %s)" % (cmd, os.getcwd(), tmpdir)
status, output = shell.run(cmd, dir = tmpdir)
print output
if status:
print "Tagging module %s failed\n" % imodule.id
except cvs.cvs_error:
print "Tagging module %s failed\n" % imodule.id
shell.rm(tmpdir)
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:31,代码来源:branch.py
示例14: update
def update():
""" Does the 'yum update' command.
:raises: AssertionError
"""
# Update
return rpm.check_for_errors(shell.run("yum -y update"))
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:7,代码来源:yum.py
示例15: ql
def ql(package):
""" Performs a 'rpm -ql' command
:param package: Package to be listed
:type package: ``str``
"""
return shell.run("rpm -ql %s" % package)
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:7,代码来源:rpm.py
示例16: e
def e(package):
""" Performs a 'rpm -e' command
:param package: Package to be removed
:type package: ``str``
"""
return shell.run("rpm -e %s" % package)
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:7,代码来源:rpm.py
示例17: status
def status(launch,
bucket: 's3 bucket to upload logs to' = shell.conf.get_or_prompt_pref('launch_logs_bucket', __file__, message='bucket for launch_logs')):
"""
show all instances, and their state, ie running|done|failed|missing.
"""
launch = launch.replace('launch=', '')
data = json.loads(params(launch))
results = shell.run("aws s3 ls %(bucket)s/launch_logs/launch=%(launch)s/ --recursive|awk '{print $NF}'| grep exited=" % locals()).splitlines()
results = [(x.split('/')[-2], x.split('exited=')[-1]) for x in results]
fail_labels = [label.split('label=', 1)[-1] for label, exit in results if exit != '0']
done_labels = [label.split('label=', 1)[-1] for label, exit in results if exit == '0']
running_labels = [aws.ec2._tags(i)['label'] for i in aws.ec2._ls(['launch=%s' % launch], state='running')]
vals = []
for label in sorted(data['labels']):
if label in fail_labels:
vals.append('failed label=%s' % label)
elif label in done_labels:
vals.append('done label=%s' % label)
elif label in running_labels:
vals.append('running label=%s' % label)
else:
vals.append('missing label=%s' % label)
for k, v in util.iter.groupby(vals, key=lambda x: x.split()[0]):
logging.info('num %s: %s', k, len(v))
return sorted(vals, key=lambda x: x.split()[0], reverse=True)
开发者ID:nathants,项目名称:py-aws,代码行数:25,代码来源:launch.py
示例18: grouplist
def grouplist():
""" Does the 'yum grouplist' command.
:raises: AssertionError
"""
# Check for update
return shell.run("yum grouplist")
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:7,代码来源:yum.py
示例19: getenforce
def getenforce():
""" Returns enforcing mode of SElinux
:returns: Enforcing mode of SELinux
:rtype: ``str``
"""
return shell.run("/usr/sbin/getenforce")
开发者ID:aweiteka,项目名称:cloud-app-sanity,代码行数:7,代码来源:selinux.py
示例20: run
def run(self, cmd, nowarn=0):
print "Running '%s' in %s" % (cmd, tmpdir())
status, output=shell.run(cmd, self.lcb, 1800, tmpdir())
if status and not nowarn:
print "WARNING WARNING WARNING"
print "Command failed: %s" % cmd
return output
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:8,代码来源:distributions.py
注:本文中的shell.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论