zoukankan      html  css  js  c++  java
  • python自动循环开关WiFi

    提前条件能通过adb命令控制WiFi开关

    import os
    import time
    class Wifi():
    
        def __init__(self,count):
            self.count = count
    
    #  开启wifi的方法
        def openWifi(self):
            cmd = 'adb shell svc wifi enable'
            os.popen(cmd)
            time.sleep(10)
    
    # 关闭wifi的方法
        def closeWifi(self):
            cmd = 'adb shell svc wifi disable'
            os.popen(cmd)
            time.sleep(10)
    
    #获取wifi当前开关状态
        def getWifiStatue(self):
            cmd='adb shell settings get global wifi_on'
            f = os.popen(cmd)
            str = f.readlines()
            if( str == ['1
    ']):
                print("wifi成功开启")
            elif(str == ['0
    ']):
                print("wifi成功关闭")
            else:
                print('wifi出错了')
    #控制wifi循环的方法
        def controlWifi(self):
    
            i = 1
            while (self.count >0):
                print("第 %d 次执行关闭Wi-Fi操作:" % i)
                self.closeWifi()
                self.getWifiStatue()
                print("第 %d 次执行开启Wi-Fi操作:" % i)
                self.openWifi()
                self.getWifiStatue()
    
                i = i +1
                self.count = self.count - 1
    
            else:
                print("总共执行wifi开关次数 %d" % count)
    
                time.sleep(18000)
    
    if __name__ == '__main__':
    
       #控制Wi-Fi开关执行次数
       count=int(input("请输入执行wifi开关次数:"))
       app = Wifi(count)
       app.controlWifi()
    

      

  • 相关阅读:
    pwndbg + gdb8.2 + kali (2018-10-09)爬坑
    关于EOF
    ARM的PC和LR寄存器
    存档,IE漏洞,一直不会分析
    QQProtect.sys漏洞真有意思
    问题
    gapz注入代码
    Spring JdbcTemplate批量操作数据库
    消息中间件MQ基础理论知识
    Spring4.3.1 JDBCTemplate操作数据库
  • 原文地址:https://www.cnblogs.com/laochun/p/14665503.html
Copyright © 2011-2022 走看看