本文整理汇总了Python中subprocess.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _reboot_buildout
def _reboot_buildout(self):
# rerun bootstrap to recreate bin/buildout with
# the virtualenf python as the interpreter
buildout_dir = self.buildout["buildout"]["directory"]
bootstrap_path = buildout_dir + "/bootstrap.py"
cmd_list = [self.python_cmd]
if os.path.exists(bootstrap_path):
cmd_list.append(bootstrap_path)
# cmd_list.extend(self.buildout_args)
else:
cmd_list.append(self.buildout_path)
cmd_list.extend(self.buildout_args)
cmd_list.append("bootstrap")
subprocess.call(cmd_list)
# rerun buildout if it isn't running under the
# virtualenv interpreter
self.logger.info(sys.executable)
if sys.executable != self.python_cmd:
cmd_list = [self.buildout_path]
cmd_list.extend(self.buildout_args)
self.logger.info("Rebooting buildout")
subprocess.call(cmd_list)
sys.exit()
pass
示例2: stress
def stress(self, stress_options):
stress = common.get_stress_bin(self.get_cassandra_dir())
args = [ stress ] + stress_options
try:
subprocess.call(args)
except KeyboardInterrupt:
pass
示例3: dispatch_to_slurm
def dispatch_to_slurm(commands):
scripts = {}
for job_name, command in commands.iteritems():
script = submit(command, job_name=job_name, time="0",
memory="{}G".format(maxmem), backend="slurm",
shell_script="#!/usr/bin/env bash")
script += " --partition={}".format(partition)
script += " --ntasks=1"
script += " --cpus-per-task={}".format(maxcpu)
script += " --mail-type=END,FAIL"
script += " --mail-user={}".format(email)
scripts[job_name] = script
scheduled_jobs = set(queued_or_running_jobs())
for job_name, script in scripts.iteritems():
if job_name not in scheduled_jobs:
if verbose:
print("{}".format(script), file=sys.stdout)
if not dry_run:
subprocess.call(script, shell=True)
else:
print("{} already running, skipping".format(job_name),
file=sys.stderr)
示例4: OnButton1Click
def OnButton1Click(self):
self.labelVariable.set( self.entryVariable.get()+" pocket" )
#execfile("pocket_V1.py")
#pocket_V1.main() # do whatever is in test1.py
subprocess.call("./pocket_V1.py", shell=True)
self.entry.focus_set()
self.entry.selection_range(0, Tkinter.END)
示例5: configure_linter
def configure_linter(self, language):
"""Fill out the template and move the linter into Packages."""
try:
if language is None:
return
if not self.fill_template(self.temp_dir, self.name, self.fullname, language):
return
git = util.which('git')
if git:
subprocess.call((git, 'init', self.temp_dest))
shutil.move(self.temp_dest, self.dest)
util.open_directory(self.dest)
self.wait_for_open(self.dest)
except Exception as ex:
sublime.error_message('An error occurred while configuring the plugin: {}'.format(str(ex)))
finally:
if self.temp_dir and os.path.exists(self.temp_dir):
shutil.rmtree(self.temp_dir)
示例6: setup
def setup():
import subprocess
line_break()
print("Installing python2.7...")
subprocess.call(['brew', 'install', 'python'])
line_break()
print("Installing pip...")
subprocess.call(['easy_install-2.7', 'pip'])
# if you got permissions issues and bad install, use this
# subprocess.call(['sudo', 'easy_install-2.7', 'pip'])
line_break()
print("Installing Fabric...")
subprocess.call(['pip', 'install', 'fabric'])
line_break()
print("Installing YAML...")
subprocess.call(['pip', 'install', 'PyYAML'])
line_break()
print("Installing terminal-notifier...")
subprocess.call(['gem', 'install', 'terminal-notifier'])
line_break()
print("DONE! You're good to go!")
示例7: share
def share(filename):
# TODO: Move this connection handling into a function in Kano Utils
import subprocess
if not is_internet():
subprocess.call(['sudo', 'kano-settings', '4'])
if not is_internet():
return 'You have no internet'
success, _ = login_using_token()
if not success:
os.system('kano-login 3')
success, _ = login_using_token()
if not success:
return 'Cannot login'
data = json.loads(request.data)
filename, filepath = _save(data)
success, msg = upload_share(filepath, filename, APP_NAME)
if not success:
return msg
increment_app_state_variable_with_dialog(APP_NAME, 'shared', 1)
return ''
示例8: push
def push(self, ssh_options, file):
master = self._get_master()
if not master:
sys.exit(1)
subprocess.call('scp %s -r %s [email protected]%s:' % (xstr(ssh_options),
file, master.public_ip),
shell=True)
示例9: generate_image
def generate_image(now):
"""
Generate the GEMPAK file!
"""
cmd = "csh mwplot.csh %s" % (
now.strftime("%Y %m %d %H %M"),)
subprocess.call(cmd, shell=True)
示例10: help_boot_avd
def help_boot_avd():
try:
emulator = get_identifier()
# Wait for the adb to answer
args = [settings.ADB_BINARY,
"-s",
emulator,
"wait-for-device"]
logger.info("help_boot_avd: wait-for-device")
subprocess.call(args)
# Make sure adb running as root
logger.info("help_boot_avd: root")
adb_command(['root'])
# Make sure adb running as root
logger.info("help_boot_avd: remount")
adb_command(['remount'])
# Make sure the system verity feature is disabled (Obviously, modified the system partition)
logger.info("help_boot_avd: disable-verity")
adb_command(['disable-verity'])
# Make SELinux permissive - in case SuperSu/Xposed didn't patch things right
logger.info("help_boot_avd: setenforce")
adb_command(['setenforce', '0'], shell=True)
logger.info("help_boot_avd: finished!")
return True
except:
PrintException("help_boot_avd")
return False
示例11: open_file
def open_file(fname):
if sys.platform.startswith('darwin'):
subprocess.call(('open', fname))
elif os.name == 'nt':
os.startfile(fname)
elif os.name == 'posix':
subprocess.call(('xdg-open', fname))
示例12: cloneFromGit
def cloneFromGit():
global clone_dir,git_path
try:
subprocess.call('/usr/bin/git clone '+git_path+' '+clone_dir,shell=True)
except Exception as e:
print e
sys.exit(1)
示例13: test_s_option
def test_s_option(self):
usersite = site.USER_SITE
self.assertIn(usersite, sys.path)
rc = subprocess.call([sys.executable, '-c',
'import sys; sys.exit(%r in sys.path)' % usersite])
self.assertEqual(rc, 1)
rc = subprocess.call([sys.executable, '-s', '-c',
'import sys; sys.exit(%r in sys.path)' % usersite])
self.assertEqual(rc, 0)
env = os.environ.copy()
env["PYTHONNOUSERSITE"] = "1"
rc = subprocess.call([sys.executable, '-c',
'import sys; sys.exit(%r in sys.path)' % usersite],
env=env)
self.assertEqual(rc, 0)
env = os.environ.copy()
env["PYTHONUSERBASE"] = "/tmp"
rc = subprocess.call([sys.executable, '-c',
'import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))'],
env=env)
self.assertEqual(rc, 1)
示例14: get_task
def get_task(task_id, src_id):
print task_id
print src_id
task = filter(lambda t: t['dst'][:5] == task_id[:5], tasks)
new_task = filter(lambda t: t['src'][:5] == src_id[:5], task)
if len(new_task) == 0:
print "cannot find the ip " + task_id + " from the database"
print "calling king service from server"
print subprocess.call(["../king/bin/king", src_id, task_id], stdout=open('log.txt','a'))
re_tasks = []
with open('out.txt') as ff:
lines = ff.readlines()
for line in lines:
words = line.split(' ')
re_task = {'src': words[1],
'dst': words[4],
'rtt': words[7],
'bandwidth': words[11]}
re_tasks.append(re_task)
print re_tasks
_task = filter(lambda t: t['dst'][:5] == task_id[:5], re_tasks)
inject_task = filter(lambda t: t['src'][:5] == src_id[:5], _task)
print inject_task
if len(inject_task) == 0:
abort(404)
print inject_task
new_task = inject_task
print new_task
return jsonify( { 'task': make_public_task(new_task[0]) } )
示例15: __init__
def __init__(self):
#try loading the config file
# if it doesn't exist, create one
try:
self.configFile = expanduser("~") + "/.puut/puut.conf"
#load configuration
self.config = {}
exec(open(self.configFile).read(),self.config)
except IOError:
self.setupPuut()
call(["notify-send", "Puut: Setup config", "Setup your user data at '~/.puut/puut.conf'"])
sys.exit(1)
#testing if server & credentials are correct
r = requests.get(self.config["serverAddress"] + "/info", auth=(self.config["user"],self.config["password"]))
if not (r.text=="PUUT"):
call(["notify-send", "Puut: Server error", "Contacting the server was unsuccessful, are credentials and server correct?\nResponse was: "+ r.text])
sys.exit(1)
#setting up keyhooks
for self.idx, self.val in enumerate(self.config["keys"]):
keybinder.bind(self.val, self.hotkeyFired, self.idx)
#setup GTK Status icon
self.statusicon = gtk.StatusIcon()
self.statusicon.set_from_file("icon.png")
self.statusicon.connect("popup-menu", self.right_click_event)
self.statusicon.set_tooltip("StatusIcon Example")