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

Python subprocess.call函数代码示例

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

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



在下文中一共展示了call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:orgsea,项目名称:Project-Manager,代码行数:27,代码来源:virtenv.py


示例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
开发者ID:umermansoor,项目名称:ccm,代码行数:7,代码来源:node.py


示例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)
开发者ID:cacampbell,项目名称:pythonmisc,代码行数:26,代码来源:Psme_map.py


示例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)
开发者ID:atmelino,项目名称:CNCMaker,代码行数:7,代码来源:cncmaker.py


示例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)
开发者ID:1901,项目名称:sublime_sync,代码行数:26,代码来源:commands.py


示例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!")
开发者ID:scalp42,项目名称:fabulous,代码行数:27,代码来源:setup.py


示例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 ''
开发者ID:litoteslover,项目名称:kano-draw,代码行数:27,代码来源:server.py


示例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)
开发者ID:scouredimage,项目名称:clouderaec2,代码行数:7,代码来源:service.py


示例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)
开发者ID:muthulatha,项目名称:iem,代码行数:7,代码来源:proctor.py


示例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
开发者ID:security-geeks,项目名称:Mobile-Security-Framework-MobSF,代码行数:33,代码来源:start_avd.py


示例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))
开发者ID:boscoh,项目名称:proteomicstools,代码行数:7,代码来源:best_seqid.py


示例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)
开发者ID:KowloonZh,项目名称:fish,代码行数:7,代码来源:update.py


示例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)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:25,代码来源:test_site.py


示例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]) } )
开发者ID:yhx189,项目名称:api-server,代码行数:29,代码来源:app.py


示例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")
开发者ID:Puut,项目名称:Puut-Linux,代码行数:28,代码来源:puut.py


示例16: do_lrun

    def do_lrun(self, argv):
        """Execute client-side shell command

        SYNOPSIS:
            lrun command [arg1 [arg2 [...] ] ]

        DESCRIPTION:
                Execute a shell command in your own operating system.
                This command works like the `exec` command in unix
                shells.
             
                NOTE: This core command shouldn't be confused with the
                `run` plugin, which does the same thing in the
                remotely exploited system.
             
        EXAMPLES:
            > lrun ls -la /
            > lrun htop
        """
        if len(argv) == 1:
            return self.interpret("help lrun")

        cmd = " ".join(argv[1:])

        if argv[1] != "exit":
            tmpfile = Path()
            postcmd = " ; pwd >'%s' 2>&1" % tmpfile
            subprocess.call(cmd + postcmd, shell=True)
            try:
                os.chdir(tmpfile.read())
            finally:
                del tmpfile
开发者ID:terncgod,项目名称:phpsploit,代码行数:32,代码来源:interface.py


示例17: login

 def login(self, ssh_options):
   master = self._get_master()
   if not master:
     sys.exit(1)
   subprocess.call('ssh %s [email protected]%s' % \
                   (xstr(ssh_options), master.public_ip),
                   shell=True)
开发者ID:scouredimage,项目名称:clouderaec2,代码行数:7,代码来源:service.py


示例18: dump_a_session

def dump_a_session(dbobj, str_session_id):
    """
    Using mongodump to export images in a session from hardcoded database 
    on slideatlas
    """
    sessionid = ObjectId("4ed62213114d971078000000")

    # Create a meta collection connecting to temp db

    conn = dbobj.connection
    db = conn["bev1"]
    sessionobj = db["sessions"].find_one({"_id" : ObjectId(str_session_id)})

#    for aviewid in sessionobj["views"]:
#        viewobj = db["views"].find_one({"_id" : aviewid["ref"]})
#        imgobj = db["images"].find_one({"_id" : viewobj["img"]})
#        print "Processing ", imgobj["filename"]
#        db["claw"].insert(imgobj)
#        params = [ "mongodump", "-h", "slide-atlas.org", "-u", "claw", "-p", "claw123", "-d", "bev1", "-c", str(imgobj["_id"]) ]
#        print params
#        call(params)
    params = [ "mongodump", "-h", "slide-atlas.org", "-u", "claw", "-p", "claw123", "-d", "bev1", "-c", "claw"]
    call(params)

    print "done"
开发者ID:charles-marion,项目名称:SlideAtlas-Server,代码行数:25,代码来源:dbschema.py


示例19: execute

 def execute(self, ssh_options, args):
   master = self._get_master()
   if not master:
     sys.exit(1)
   subprocess.call("ssh %s [email protected]%s '%s'" % (xstr(ssh_options),
                                            master.public_ip,
                                            " ".join(args)), shell=True)
开发者ID:scouredimage,项目名称:clouderaec2,代码行数:7,代码来源:service.py


示例20: render

def render(filtered, args):
    print("> Regenerating haproxy configuration...")
    with file_or_stdout(args['--output']) as outf:
        outf.write(_generate_conf(filtered, args['<jinja2_template>']))

    if args['--run-cmd']:
        subprocess.call(args['--run-cmd'], shell=True)
开发者ID:CyrilPeponnet,项目名称:Unify,代码行数:7,代码来源:switchboard.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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