當前位置: 首頁>>代碼示例>>Python>>正文


Python Wireless.setFrequency方法代碼示例

本文整理匯總了Python中pythonwifi.iwlibs.Wireless.setFrequency方法的典型用法代碼示例。如果您正苦於以下問題:Python Wireless.setFrequency方法的具體用法?Python Wireless.setFrequency怎麽用?Python Wireless.setFrequency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pythonwifi.iwlibs.Wireless的用法示例。


在下文中一共展示了Wireless.setFrequency方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestWireless

# 需要導入模塊: from pythonwifi.iwlibs import Wireless [as 別名]
# 或者: from pythonwifi.iwlibs.Wireless import setFrequency [as 別名]
class TestWireless(unittest.TestCase):

    def setUp(self):
        ifnames = getNICnames()
        self.wifi = Wireless(ifnames[0])

    def test_wirelessMethods(self):
        # test all wireless methods that they don't return an error
        methods = ['getAPaddr',
                   'getBitrate',
                   'getBitrates',
                   'getChannelInfo',
                   'getEssid',
                   'getFragmentation',
                   'getFrequency',
                   'getMode',
                   'getNwids',
                   'getWirelessName',
                   'getPowermanagement',
                   'getQualityMax',
                   'getQualityAvg',
                   'getRetrylimit',
                   'getRTS',
                   'getSensitivity',
                   'getTXPower',
                   'getStatistics',
                   'commit']

        for m in methods:
            result = getattr(self.wifi, m)()

        old_mode = self.wifi.getMode()
        self.wifi.setMode('Monitor')
        self.assert_(self.wifi.getMode() == 'Monitor')
        self.wifi.setMode(old_mode)

        old_essid = self.wifi.getEssid()
        self.wifi.setEssid('Joost')
        self.assert_(self.wifi.getEssid() == 'Joost')
        self.wifi.setEssid(old_essid)

        old_freq = self.wifi.getFrequency()
        self.wifi.setFrequency('2.462GHz')
        self.assert_(self.wifi.getFrequency() == '2.462GHz')
        self.wifi.setFrequency(old_freq)

        # test setAPaddr - does not work unless AP is real and available
        #old_mac = self.wifi.getAPaddr()
        #self.wifi.setAPaddr('61:62:63:64:65:66')
        #time.sleep(3)                                     # 3 second delay between set and get required
        #self.assert_(self.wifi.getAPaddr() == '61:62:63:64:65:66')
        #self.wifi.setAPaddr(old_mac)

        old_enc = self.wifi.getEncryption()
        self.wifi.setEncryption('restricted')
        self.assert_(self.wifi.getEncryption() == 'restricted')
        self.assert_(self.wifi.getEncryption(symbolic=False) \
                        == IW_ENCODE_RESTRICTED+1)
        self.wifi.setEncryption(old_enc)

        try:
            old_key = self.wifi.getKey()
        except ValueError, msg:
            old_key = None
        self.wifi.setKey('ABCDEF1234', 1)
        self.assert_(self.wifi.getKey() == 'ABCD-EF12-34')
        self.assert_(map(hex, self.wifi.getKey(formatted=False)) \
                        == ['0xab', '0xcd', '0xef', '0x12', '0x34'])
        if old_key:
            self.wifi.setKey(old_key, 1)
        else:
            self.wifi.setEncryption('off')
開發者ID:FomkaV,項目名稱:wifi-arsenal,代碼行數:74,代碼來源:test_wireless.py


注:本文中的pythonwifi.iwlibs.Wireless.setFrequency方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。