本文整理汇总了Python中utils.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: mode_pre
def mode_pre(session_dir, args):
global gtmpfilename
"""
Read from Session file and write to session.pre file
"""
endtime_to_update = int(time.time()) - get_changelog_rollover_time(
args.volume)
status_file = os.path.join(session_dir, args.volume, "status")
status_file_pre = status_file + ".pre"
mkdirp(os.path.dirname(args.outfile), exit_on_err=True, logger=logger)
# If Pre status file exists and running pre command again
if os.path.exists(status_file_pre) and not args.regenerate_outfile:
fail("Post command is not run after last pre, "
"use --regenerate-outfile")
start = 0
try:
with open(status_file) as f:
start = int(f.read().strip())
except ValueError:
pass
except (OSError, IOError) as e:
fail("Error Opening Session file %s: %s"
% (status_file, e), logger=logger)
logger.debug("Pre is called - Session: %s, Volume: %s, "
"Start time: %s, End time: %s"
% (args.session, args.volume, start, endtime_to_update))
prefix = datetime.now().strftime("%Y%m%d-%H%M%S-%f-")
gtmpfilename = prefix + next(tempfile._get_candidate_names())
run_cmd_nodes("pre", args, start=start, end=-1, tmpfilename=gtmpfilename)
# Merger
if args.full:
cmd = ["sort", "-u"] + node_outfiles + ["-o", args.outfile]
execute(cmd,
exit_msg="Failed to merge output files "
"collected from nodes", logger=logger)
else:
# Read each Changelogs db and generate finaldb
create_file(args.outfile, exit_on_err=True, logger=logger)
outfilemerger = OutputMerger(args.outfile + ".db", node_outfiles)
write_output(args.outfile, outfilemerger, args.field_separator)
try:
os.remove(args.outfile + ".db")
except (IOError, OSError):
pass
run_cmd_nodes("cleanup", args, tmpfilename=gtmpfilename)
with open(status_file_pre, "w", buffering=0) as f:
f.write(str(endtime_to_update))
sys.stdout.write("Generated output file %s\n" % args.outfile)
开发者ID:raghavendrabhat,项目名称:glusterfs,代码行数:60,代码来源:main.py
示例2: check_postgresql_server
def check_postgresql_server():
if System.system_name in ('ubuntu', 'debian',):
command = [
'sudo',
'su',
'postgres',
'-c',
'psql -tAc "select version();"'
]
exit_code, output = utils.execute(command,capture_output=True)
if exit_code:
System.postgresql_version = None # Not installed
else:
System.postgresql_version = output.split(' ')[1]
elif System.system_name == 'darwin':
command = [
'psql',
'-tAc',
'select version();'
]
exit_code, output = utils.execute(command,capture_output=True)
if exit_code:
System.postgresql_version = None # Not installed
else:
System.postgresql_version = output.split(' ')[1] # No need to remove \n
else:
raise NotImplementedError()
开发者ID:cmorisse,项目名称:ikez,代码行数:28,代码来源:system_info.py
示例3: update
def update(req, edits, newrows):
edits = json.loads(edits)
newrows = json.loads(newrows)
insert_ids = {}
cursor = utils.get_cursor()
for rowid, fields_and_vals in edits.items():
setlist = ','.join('%s = %s'%(f, sql_representation(v)) for f, v in fields_and_vals.items() if f != 'estimated_units_remaining')
sql = "update sku set " + setlist + " where id = " + rowid + "\n"
utils.execute(sql, cursor)
for rowid, fields_and_vals in newrows.items():
for bad_field in ('uid', 'undefined', 'estimated_units_remaining', 'boundindex', 'visibleindex', 'uniqueid'):
if fields_and_vals.has_key(bad_field): fields_and_vals.pop(bad_field)
fields = fields_and_vals.keys()
values = fields_and_vals.values()
field_list = ','.join(fields)
value_list = ','.join(sql_representation(v) for v in values)
sql = "insert into sku ("+field_list+") VALUES ("+value_list+")"
utils.execute(sql, cursor)
insert_ids[rowid] = utils.select("select LAST_INSERT_ID()", cursor, False)[0][0]
cursor.close ()
wineprint.gen_fodt_and_pdf()
return json.dumps(insert_ids)
开发者ID:jkobrin,项目名称:pos1,代码行数:27,代码来源:inventory.py
示例4: delete_net
def delete_net(self,Id):
if Id:
utils.execute("rm -f /var/run/netns/%s" % ("nets-"+Id))
if os.path.isdir("/sys/class/net/%s" % ("t-"+Id)):
utils.execute("ip link del %s" % ("t-"+Id))
else:
pass
开发者ID:zwqzhangweiqiang,项目名称:dnet,代码行数:7,代码来源:network.py
示例5: executeHandlers
def executeHandlers(type, list=()):
"""
Executes all handlers by type with list as list of args
"""
handlers = Handlers[type]
for handler in handlers:
utils.execute(handler, list)
开发者ID:eg-astrouka,项目名称:vk4xmpp,代码行数:7,代码来源:gateway.py
示例6: populate_pay_stub
def populate_pay_stub():
results = utils.select('''
select
DATE(intime) - interval (DAYOFWEEK(intime) -1) DAY as week_of,
employee_tax_info.person_id,
last_name, first_name,
sum(hours_worked) as hours_worked,
pay_rate,
allowances,
nominal_scale,
round(sum(hours_worked)*pay_rate) as weekly_pay,
round(sum(hours_worked)*pay_rate*nominal_scale) as gross_wages,
married,
sum(tip_pay) tips,
round(sum(hours_worked)*pay_rate - weekly_tax) + sum(tip_pay) as total_weekly,
sum(tip_pay) / sum(hours_worked) + pay_rate as total_hourly_pay
from hours_worked JOIN employee_tax_info ON hours_worked.person_id = employee_tax_info.person_id
where yearweek(intime) = yearweek(now() - interval '1' week)
and intime != 0
group by employee_tax_info.person_id
''',
incursor = None,
label = True
)
for row in results:
add_witholding_fields(employee_tax_info = row)
columns = ','.join(row.keys())
values = ','.join(map(str,row.values()))
utils.execute('''INSERT into pay_stub (%s) VALUES (%s)'''%(columns, values))
开发者ID:jkobrin,项目名称:pos1,代码行数:31,代码来源:tax.py
示例7: node_cmd
def node_cmd(host, host_uuid, task, cmd, args, opts):
"""
Runs command via ssh if host is not local
"""
localdir = is_host_local(host_uuid)
# this is so to avoid deleting the ssh keys on local node which otherwise
# cause ssh password prompts on the console (race conditions)
# mode_delete() should be cleaning up the session tree
if localdir and task == "delete":
return
pem_key_path = get_pem_key_path(args.session, args.volume)
if not localdir:
# prefix with ssh command if not local node
cmd = ["ssh",
"-i", pem_key_path,
"[email protected]%s" % host] + cmd
execute(cmd, exit_msg="%s - %s failed" % (host, task), logger=logger)
if opts.get("copy_outfile", False):
cmd_copy = ["scp",
"-i", pem_key_path,
"[email protected]%s:/%s" % (host, opts.get("node_outfile")),
os.path.dirname(opts.get("node_outfile"))]
execute(cmd_copy, exit_msg="%s - Copy command failed" % host,
logger=logger)
开发者ID:newpant,项目名称:glusterfs,代码行数:29,代码来源:main.py
示例8: moveToNextStep
def moveToNextStep(self):
if self.currentStep == len(self.lesson.steps):
dlg = LessonFinishedDialog(self.lesson)
dlg.exec_()
if dlg.nextLesson is not None:
self.init(dlg.nextLesson)
else:
self.finishLesson()
else:
step = self.lesson.steps[self.currentStep]
if step.endsignal is not None:
step.endsignal.connect(self.endSignalEmitted)
item = self.listSteps.item(self.currentStep)
item.setBackground(Qt.green)
if os.path.exists(step.description):
with open(step.description) as f:
html = "".join(f.readlines())
self.webView.document().setMetaInformation(QTextDocument.DocumentUrl,
QUrl.fromUserInput(step.description).toString())
self.webView.setHtml(html)
else:
self.webView.setHtml(step.description)
QCoreApplication.processEvents()
if step.prestep is not None:
execute(step.prestep)
if step.function is not None:
self.btnRunStep.setEnabled(step.steptype != Step.AUTOMATEDSTEP)
self.btnMove.setEnabled(step.steptype != Step.AUTOMATEDSTEP and step.endsignal is None)
if step.steptype == Step.AUTOMATEDSTEP:
self.runCurrentStepFunction()
else:
self.btnRunStep.setEnabled(False)
self.btnMove.setEnabled(step.endsignal is None)
开发者ID:boundlessgeo,项目名称:qgis-lessons-plugin,代码行数:33,代码来源:lessonwidget.py
示例9: _ensure_project_folder
def _ensure_project_folder(project_id):
if not os.path.exists(ca_path(project_id)):
start = os.getcwd()
os.chdir(ca_folder())
utils.execute('sh', 'geninter.sh', project_id,
_project_cert_subject(project_id))
os.chdir(start)
开发者ID:pombredanne,项目名称:nova,代码行数:7,代码来源:crypto.py
示例10: runCurrentStepFunction
def runCurrentStepFunction(self):
QtCore.QCoreApplication.processEvents()
step = self.lesson.steps[self.currentStep]
self.webView.setEnabled(False)
execute(step.function)
self.webView.setEnabled(True)
self.stepFinished()
开发者ID:SrNetoChan,项目名称:qgis-lessons-plugin,代码行数:7,代码来源:lessonwidget.py
示例11: uninstall
def uninstall(self, hostname):
"""
Portal uninstall process
"""
utils.execute("apt-get -y --purge remove openjdk-7-jdk tomcat7", check_exit_code=False)
utils.execute("apt-get -y clean", check_exit_code=False)
return
开发者ID:StackOps,项目名称:stackops-agent,代码行数:7,代码来源:portal.py
示例12: moveToNextStep
def moveToNextStep(self):
if self.currentStep == len(self.lesson.steps):
QtGui.QMessageBox.information(self, "Lesson", "You have reached the end of this lesson")
self.finishLesson()
else:
step = self.lesson.steps[self.currentStep]
if step.endsignal is not None:
step.endsignal.connect(self.endSignalEmitted)
item = self.listSteps.item(self.currentStep)
item.setBackground(QtCore.Qt.green)
if os.path.exists(step.description):
with open(step.description) as f:
html = "".join(f.readlines())
self.webView.setHtml(html, QtCore.QUrl.fromUserInput(step.description))
else:
self.webView.setHtml(step.description)
QtCore.QCoreApplication.processEvents()
if step.prestep is not None:
execute(step.prestep)
if step.function is not None:
self.btnRunStep.setEnabled(step.steptype != Step.AUTOMATEDSTEP)
self.btnMove.setEnabled(step.steptype != Step.AUTOMATEDSTEP)
if step.steptype == Step.AUTOMATEDSTEP:
self.runCurrentStepFunction()
else:
self.btnRunStep.setEnabled(False)
self.btnMove.setEnabled(True)
开发者ID:SrNetoChan,项目名称:qgis-lessons-plugin,代码行数:27,代码来源:lessonwidget.py
示例13: index
def index(req, receipts_id, field_name, new_value):
utils.execute(
'''update receipts_by_server set %(field_name)s = '%(new_value)s' where id = %(receipts_id)s;'''%locals()
)
return json.dumps(None)
开发者ID:jkobrin,项目名称:pos1,代码行数:7,代码来源:update_receipts.py
示例14: cleanup
def cleanup():
print("\n***** Cleaning up *****")
if volume_mounted:
utils.execute("umount " + mount_point)
if volume_created:
vmcreate.detach_and_delete_volume(volume)
if mount_point_created:
utils.execute("rm -rf " + mount_point)
开发者ID:canarie,项目名称:vm-toolkit,代码行数:8,代码来源:vmbundle.py
示例15: uninstall
def uninstall(self, hostname):
"""
RabbitMQ uninstall process
"""
utils.execute("apt-get -y --purge remove rabbitmq-server memcached python-memcache", check_exit_code=False)
utils.execute("apt-get -y clean", check_exit_code=False)
shutil.rmtree('/var/lib/rabbitmq', ignore_errors=True)
return
开发者ID:StackOps,项目名称:stackops-agent,代码行数:8,代码来源:rabbitmq.py
示例16: abyss_bloom
def abyss_bloom(input_fqs, outputs):
fq1, fq2 = input_fqs
for k_mer_size, bf, bf_flag in zip(K_MER_SIZES, BFS, BF_FLAGS):
cmd = CONFIG['abyss_bloom']['cmd'].format(**locals())
# cmd = ('abyss-bloom build -v -k {k_mer_size} -j 8 -b 3G -l 2 -q 15 - '
# '{fq1} {fq2} '
# '| gzip -c > {bf}'.format(**locals()))
execute(cmd, flag=bf_flag)
开发者ID:zyxue,项目名称:kvarscan,代码行数:8,代码来源:konnector.py
示例17: revoke_cert
def revoke_cert(project_id, file_name):
"""Revoke a cert by file name"""
start = os.getcwd()
os.chdir(ca_folder(project_id))
# NOTE(vish): potential race condition here
utils.execute("openssl ca -config ./openssl.cnf -revoke '%s'" % file_name)
utils.execute("openssl ca -gencrl -config ./openssl.cnf -out '%s'" %
FLAGS.crl_file)
os.chdir(start)
开发者ID:anotherjesse,项目名称:nova,代码行数:9,代码来源:crypto.py
示例18: uninstall
def uninstall(self, hostname):
"""
Keystone uninstall process
"""
utils.execute("apt-get -y --purge remove keystone python-keystone python-keystoneclient python-mysqldb",
check_exit_code=False)
utils.execute("apt-get -y clean", check_exit_code=False)
shutil.rmtree('/var/lib/keystone', ignore_errors=True)
return
开发者ID:StackOps,项目名称:stackops-agent,代码行数:9,代码来源:keystone.py
示例19: __init__
def __init__(self,url):
self.connection=docker.Client(base_url=url)
if os.path.isdir("/etc/config"):
pass
else:
utils.execute("mkdir /etc/config")
self.path="/etc/config/"
self.netpath="/etc/network/"
self.net=network.network()
开发者ID:zwqzhangweiqiang,项目名称:dnet,代码行数:9,代码来源:container.py
示例20: _ensure_project_folder
def _ensure_project_folder(project_id):
if not os.path.exists(ca_path(project_id)):
geninter_sh_path = os.path.join(FLAGS.ca_path,
'geninter.sh')
start = os.getcwd()
os.chdir(ca_folder())
utils.execute('sh', geninter_sh_path, project_id,
_project_cert_subject(project_id))
os.chdir(start)
开发者ID:BillTheBest,项目名称:nova,代码行数:9,代码来源:crypto.py
注:本文中的utils.execute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论