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

Python execute.execute函数代码示例

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

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



在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: wpa_run

    def wpa_run(self):
        dump_cmd = ['airodump-ng', '-c', self.channel, '--bssid', self.bssid, '-w', './log/' + self.bssid, self.iface]
        airodump_proc = Popen(dump_cmd, stdout=DN, stderr=DN)
        self.proc_list.append(airodump_proc)

        self.send_deauths()
        while self.key == '':
            output = Popen('tshark -r ./log/' + self.bssid + '-01.cap 2>/dev/null| grep "Message 4 of 4"',shell=True, stdout=PIPE).communicate()[0]
            if output.find('Message 4 of 4') != -1:
                execute('rm ./log/'+self.bssid+'.key')
                airodump_proc.kill()
                airodump_proc.communicate()
                crack_cmd = ['aircrack-ng', '-w', self.password_list, '-b', self.bssid, './log/' + self.bssid + '-01.cap','-l', './log/' + self.bssid + '.key']
                crack_proc = Popen(crack_cmd, stdout=DN)
                self.proc_list.append(crack_proc)
                crack_proc.wait()
                try:
                    f = open('./log/' + self.bssid + '.key')
                    key = f.read()
                    f.close()
                    self.key = key
                    self.crack_success = True
                    self.stop()
                except:
                    pass
            else:
                self.send_deauths()
                time.sleep(5)
        return self.key
开发者ID:kn9,项目名称:AtEar,代码行数:29,代码来源:aircrack.py


示例2: purge

 def purge(self, cr, uid, vals, context={}):
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     ssh, sftp = execute.connect(vals['backup_fullname'], context=context)
     execute.execute(ssh, ['rm', '-rf', '/opt/backup/simple/' + vals['saverepo_name'] + '/'+ vals['save_name']], context)
     ssh.close()
     sftp.close()
     return
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:7,代码来源:save.py


示例3: stop_monitor

def stop_monitor():
    '''
        @brief Delete wlan device.
    '''
    for dev in _dev_name_list:
        execute('iw dev '+ dev +' del > /dev/null 2>&1')
    w_interface_up()
开发者ID:onexuan,项目名称:AtEar,代码行数:7,代码来源:network.py


示例4: deploy_post

 def deploy_post(self, cr, uid, vals, context):
     super(saas_container, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'docker':
         ssh, sftp = execute.connect(vals['container_fullname'], context=context)
         execute.execute(ssh, ['echo "host all  all    ' + vals['container_options']['network']['value'] + ' md5" >> /etc/postgresql/' + vals['app_current_version'] + '/main/pg_hba.conf'], context)
         execute.execute(ssh, ['echo "listen_addresses=\'' + vals['container_options']['listen']['value'] + '\'" >> /etc/postgresql/' + vals['app_current_version'] + '/main/postgresql.conf'], context)
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:7,代码来源:docker.py


示例5: purge

 def purge(self, cr, uid, vals, context={}):
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if 'shinken_server_domain' in vals:
         ssh, sftp = execute.connect(vals['shinken_fullname'], context=context)
         execute.execute(ssh, ['rm', vals['server_shinken_configfile']], context)
         execute.execute(ssh, ['/etc/init.d/shinken', 'reload'], context)
         ssh.close()
         sftp.close()
开发者ID:ajite,项目名称:odoo-hosting-orchestrator,代码行数:8,代码来源:container.py


示例6: start

 def start(self, cr, uid, vals, context={}):
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     self.stop(cr, uid, vals, context=context)
     ssh, sftp = execute.connect(vals['server_domain'], vals['server_ssh_port'], 'root', context)
     execute.execute(ssh, ['docker', 'start', vals['container_name']], context)
     ssh.close()
     sftp.close()
     time.sleep(3)
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:8,代码来源:container.py


示例7: purge_files

    def purge_files(self, cr, uid, vals, context={}):
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
        execute.execute(ssh, ['rm', '-rf', vals['service_full_localpath_files']], context)
        ssh.close()
        sftp.close()

        self.check_files(cr, uid, vals, context=context)
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:8,代码来源:service.py


示例8: purge

    def purge(self, cr, uid, vals, context={}):
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})

        #TODO we need to launch a direct command, without ssh
        ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
        execute.execute(ssh, ['sed', '-i', "'/Host " + vals['server_domain'] + "/,/END " + vals['server_domain'] + "/d'", vals['config_home_directory'] + '/.ssh/config'], context)
        ssh.close()
        sftp.close()
        execute.execute_local(['rm', '-rf', vals['config_home_directory'] + '/.ssh/keys/' + vals['server_domain']], context)
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:9,代码来源:container.py


示例9: run

 def run(self):
     ''' Start airodump-ng and dump '''
     # Clean first
     self.stop()
     remove_command = 'rm -rf ' + self.air_scan_result + '*'
     execute(remove_command)
     dump_command = ['airodump-ng', self.iface, '-w', self.air_scan_result, '--output-format', 'csv']
     self.dump_proc, unused_ret, unused_out, unused_err = execute(dump_command, wait=False)
     self.isRunning = True
开发者ID:kn9,项目名称:AtEar,代码行数:9,代码来源:airodump.py


示例10: w_interface_up

def w_interface_up():
    p, retval, out, err = execute('iw dev |grep Interface')
    intf_list = out.replace('\tInterface','').split()
    for interface in intf_list:
        execute('ifconfig ' + interface + ' up')



#print get_interfaces()
开发者ID:NORMA-Inc,项目名称:AtEar,代码行数:9,代码来源:network.py


示例11: main

def main ():
    logging.basicConfig(stream=sys.stdout, level=logging.INFO)

    for locale in CONFIGURATION.locales:
        merge(locale)
    # Dummy text is not required. Don't raise exception if files are missing.
    merge(CONFIGURATION.dummy_locale, fail_if_missing=False)
    compile_cmd = 'django-admin.py compilemessages'
    execute(compile_cmd, working_directory=BASE_DIR)
开发者ID:fbagirov,项目名称:edx-platform,代码行数:9,代码来源:generate.py


示例12: check_files

    def check_files(self, cr, uid, vals, context={}):
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        service_ids = self.search(cr, uid, [('application_version_id', '=', vals['app_version_id']),('container_id.server_id','=',vals['server_id'])], context=context)
	if vals['service_id'] in service_ids:
	    service_ids.remove(vals['service_id'])
        if not service_ids:
            ssh, sftp = execute.connect(vals['server_domain'], vals['server_ssh_port'], 'root', context)
            execute.execute(ssh, ['rm', '-rf', vals['app_version_full_hostpath']], context)
            ssh.close()
            sftp.close()
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:10,代码来源:service.py


示例13: deploy

 def deploy(self, cr, uid, vals, context={}):
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     _logger.info('test %s', vals['shinken_server_domain'])
     if 'shinken_server_domain' in vals:
         ssh, sftp = execute.connect(vals['shinken_fullname'], context=context)
         sftp.put(vals['config_conductor_path'] + '/saas/saas_shinken/res/server-shinken.config', vals['server_shinken_configfile'])
         execute.execute(ssh, ['sed', '-i', '"s/NAME/' + vals['server_domain'] + '/g"', vals['server_shinken_configfile']], context)
         execute.execute(ssh, ['/etc/init.d/shinken', 'reload'], context)
         ssh.close()
         sftp.close()
开发者ID:ajite,项目名称:odoo-hosting-orchestrator,代码行数:10,代码来源:container.py


示例14: set_monitor_mode

def set_monitor_mode():
    '''
        @brief Set wlan device to monitor mode.
        @return:
            * success - True
            * fail - False
    '''
    for dev in _mon_dev_list:
        execute('iwconfig '+ dev +' mode monitor')
        time.sleep(1)
        p, retval, out, err = execute('iwconfig '+ dev)

        retry = 0
        while out.find('Mode:Monitor') == -1: # If the mode is not changed properly, enter the loop and retry 60.
            execute('ifconfig '+dev+' down')
            execute('iwconfig '+ dev +' mode monitor')
            time.sleep(0.5)
            p, retval, out, err = execute('iwconfig '+ dev)
            retry = retry + 1
            if retry == 150:
                break

    time.sleep(2)
    for dev in _mon_dev_list: # Reaffirm
        p, retval, out, err = execute('iwconfig '+ dev)
        if out.find('Mode:Monitor') == -1:
            return False

    return True
开发者ID:onexuan,项目名称:AtEar,代码行数:29,代码来源:network.py


示例15: purge_key

 def purge_key(self, cr, uid, vals, context={}):
     ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
     execute.execute(ssh, ['sed', '-i', "'/Host " + vals['container_fullname'] + "/,/END " + vals['container_fullname'] + "/d'", vals['config_home_directory'] + '/.ssh/config'], context)
     ssh.close()
     sftp.close()
     execute.execute_local(['rm', '-rf', vals['config_home_directory'] + '/.ssh/keys/' + vals['container_fullname']], context)
     execute.execute_local(['rm', '-rf', vals['config_home_directory'] + '/.ssh/keys/' + vals['container_fullname'] + '.pub'], context)
     ssh, sftp = execute.connect(vals['server_domain'], vals['server_ssh_port'], 'root', context)
     execute.execute(ssh, ['rm', '-rf', '/opt/keys/' + vals['container_fullname'] + '/authorized_keys'], context)
     ssh.close()
     sftp.close()
开发者ID:ajite,项目名称:odoo-hosting-orchestrator,代码行数:11,代码来源:container.py


示例16: deploy

    def deploy(self, cr, uid, vals, context=None):
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        self.purge(cr, uid, vals, context=context)

        if 'base_restoration' in context:
            return

        res = self.deploy_create_database(cr, uid, vals, context)
        if not res:
            for key, database in vals['base_databases'].iteritems():
                if vals['database_type'] != 'mysql':
                    ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
                    execute.execute(ssh, ['createdb', '-h', vals['database_server'], '-U', vals['service_db_user'], database], context)
                    ssh.close()
                    sftp.close()
                else:
                    ssh, sftp = execute.connect(vals['database_fullname'], context=context)
                    execute.execute(ssh, ["mysql -u root -p'" + vals['database_root_password'] + "' -se \"create database " + database + ";\""], context)
                    execute.execute(ssh, ["mysql -u root -p'" + vals['database_root_password'] + "' -se \"grant all on " + database + ".* to '" + vals['service_db_user'] + "';\""], context)
                    ssh.close()
                    sftp.close()

        execute.log('Database created', context)
        if vals['base_build'] == 'build':
            self.deploy_build(cr, uid, vals, context)

        elif vals['base_build'] == 'restore':
            if vals['database_type'] != 'mysql':
                ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
                execute.execute(ssh, ['pg_restore', '-h', vals['bdd_server_domain'], '-U', vals['service_db_user'], '--no-owner', '-Fc', '-d', vals['base_unique_name_'], vals['app_version_full_localpath'] + '/' + vals['app_bdd'] + '/build.sql'], context)
                ssh.close()
                sftp.close()
            else:
                ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
                execute.execute(ssh, ['mysql', '-h', vals['bdd_server_domain'], '-u', vals['service_db_user'], '-p' + vals['bdd_server_mysql_passwd'], vals['base_unique_name_'], '<', vals['app_version_full_localpath'] + '/' + vals['app_bdd'] + '/build.sql'], context)
                ssh.close()
                sftp.close()

            self.deploy_post_restore(cr, uid, vals, context)

        if vals['base_build'] != 'none':
            if vals['base_poweruser_name'] and vals['base_poweruser_email'] and vals['apptype_admin_name'] != vals['base_poweruser_name']:
                self.deploy_create_poweruser(cr, uid, vals, context)
            if vals['base_test']:
                self.deploy_test(cr, uid, vals, context)


        self.deploy_post(cr, uid, vals, context)

        #For shinken
        self.save(cr, uid, [vals['base_id']], context=context)
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:51,代码来源:base.py


示例17: purge

    def purge(self, cr, uid, vals, context={}):
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        self.purge_files(cr, uid, vals, context=context)
        self.purge_pre_service(cr, uid, vals, context)

        ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
        execute.execute(ssh, ['rm', '-rf', vals['service_full_localpath']], context)
        ssh.close()
        sftp.close()

        if vals['database_type'] != 'mysql':
            ssh, sftp = execute.connect(vals['database_fullname'], username='postgres', context=context)
            execute.execute(ssh, ['psql', '-c', '"DROP USER ' + vals['service_db_user'] + ';"'], context)
            ssh.close()
            sftp.close()

            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['sed', '-i', '"/:*:' + vals['service_db_user'] + ':/d" ~/.pgpass'], context)
            ssh.close()
            sftp.close()

        else:
            ssh, sftp = execute.connect(vals['database_fullname'], context=context)
            execute.execute(ssh, ["mysql -u root -p'" + vals['database_root_password'] + "' -se \"drop user " + vals['service_db_user'] + ";\""], context)
            ssh.close()
            sftp.close()

        return
开发者ID:YannickB,项目名称:saas-deprecated,代码行数:28,代码来源:service.py


示例18: auto_monitor

def auto_monitor():
    '''
        @brief Check monitor mode support. and set.
    '''
    print "Check Monitor mode...."
    p, r, out, err = execute('iw dev| grep phy')
    interface_list = out.split('\n')
    interface_list.pop()
    ap_support = []
    monitor_support = []
    for interface in interface_list:
        interface = interface.replace('#', '')

        p, r, out, err = execute('iw phy '+interface+' info')

        sup = out[out.find('Supported interface modes:')+28:]
        support_list = sup[:sup.find(':')].replace('\t', '').replace(' ', '').replace('*', '').split('\n')[:-1]
        for support in support_list:
            if support == 'AP':
                ap_support.append(interface)
            elif support == 'monitor':
                monitor_support.append(interface)

    if len(ap_support) == 0 or len(monitor_support) == 0:
        print '\n'
        print '[!!] I did not find the device to support the required mode.'
        print '[!!] Please check that the WLAN device that supports monitor mode on your system.'
        return False

    print "Set Monitor mode...."
    if ap_support:
        w_interface_down()
        for dev in _dev_name_list:
            execute('iw phy ' + ap_support[0] + ' interface add '+ dev +' type monitor')

        w_interface_down()
        ret = set_monitor_mode()
        if ret == False:
            print '[!!] It failed to change the mode of the wireless LAN device.'
            print '[!!] Please try again later.'
            return False
        w_interface_down()

    elif monitor_support:
        w_interface_down()
        for dev in _dev_name_list:
            if dev == "atear_ap": continue
            execute('iw phy ' + ap_support[0] + ' interface add '+ dev +' type monitor')

        w_interface_down()
        ret = set_monitor_mode()
        if ret == False:
            print '[!!] It failed to change the mode of the wireless LAN device.'
            print '[!!] Please try again later.'
            return False
        w_interface_down()

    execute('rfkill unblock wlan')
    return True
开发者ID:onexuan,项目名称:AtEar,代码行数:59,代码来源:network.py


示例19: run

 def run(self):
     dns_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
     dns_sock.settimeout(3)  # Set timeout on socket-operations.
     execute('fuser -k -n udp 53')
     time.sleep(0.5)
     dns_sock.bind(('', 53))
     while self.START_SIGNAL:
         try:
             data, addr = dns_sock.recvfrom(1024)
         except:
             continue
         packet = DNSQuery(data)
         # Return own IP adress.
         dns_sock.sendto(packet.respuesta(self.address), addr)
     dns_sock.close()
开发者ID:onexuan,项目名称:AtEar,代码行数:15,代码来源:fake_ap.py


示例20: create_pool

def create_pool(cluster, pool_name, compression_type, tier=True, pg_num=32, pgp_num=32):
    """ Create erasure pool pool_name with compression compression_type """
    if cluster.pool_exists(pool_name):
        cluster.delete_pool(pool_name)
    if tier and cluster.pool_exists(pool_name+"_tier"):
        cluster.delete_pool(pool_name+"_tier")

    try:
        cmds = ["./ceph osd pool create {0} {1} {2} erasure".format(pool_name,
                                                                    pg_num,
                                                                    pgp_num),
                "./ceph osd pool set {0} compression_type {1}".format(pool_name,
                                                                      compression_type)
               ]
        if tier:
            cmds.extend(["./ceph osd pool create {0}_tier {1} {2}".format(pool_name,
                                                                          pg_num,
                                                                          pgp_num),
                         "./ceph osd tier add {0} {0}_tier".format(pool_name),
                         "./ceph osd tier cache-mode {0}_tier writeback".format(pool_name),
                         "./ceph osd tier set-overlay {0} {0}_tier".format(pool_name)
                        ])

        for cmd in cmds:
            res = execute(cmd)
            logger.debug(res)
    except Exception as ex:
        logger.error("%s failed: %s", cmd, ex.message())
        return False
    return True
开发者ID:Ved-vampir,项目名称:compression_tests,代码行数:30,代码来源:cluster.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python executil.getoutput函数代码示例发布时间:2022-05-24
下一篇:
Python execute.capture_execution函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap