Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff pythonwifi/iwlibs.py git/pythonwifi/pythonwifi/iwlibs.py
- 1c1
- < # -*- coding: latin1 -*-
- ---
- > # -*- coding: utf-8 -*-
- 168a169,170
- >
- > FIXME: This needs to check address type before acting.
- 177c179,181
- < if ":" not in addr: return (errno.ENOSYS, os.strerror(errno.ENOSYS))
- ---
- > if ":" not in addr:
- > # not a hardware address
- > raise IOError(errno.ENOSYS, os.strerror(errno.ENOSYS))
- 389c393
- < def setKey(self, key, index=0):
- ---
- > def setKey(self, key, index=1):
- 473a478
- > format = "lhBB"
- 476c481
- < iwreq = iwstruct.pack("ihBB", -1, 0, 0, pythonwifi.flags.IW_FREQ_AUTO)
- ---
- > iwreq = iwstruct.pack(format, -1, 0, 0, pythonwifi.flags.IW_FREQ_AUTO)
- 480c485
- < freq_pattern = re.compile("([\d\.]+)(\w)", re.I|re.M|re.S)
- ---
- > freq_pattern = re.compile("([\d\.]+)\s?([GMk])\w?", re.I|re.M|re.S)
- 482,486c487,498
- < freq_num, unit = freq_match.groups()
- < if unit == "G": freq_num = float(freq_num) * GIGA
- < if unit == "M": freq_num = float(freq_num) * MEGA
- < if unit == "k": freq_num = float(freq_num) * KILO
- < e = math.floor(math.log10(freq_num))
- ---
- > if freq_match is None:
- > # match failed, try to just find a number (no units)
- > freq_pattern = re.compile("([\d\.]+)", re.I|re.M|re.S)
- > freq_match = freq_pattern.search(freq)
- > freq_num, unit = (freq_match.groups()[0], "")
- > else:
- > freq_num, unit = freq_match.groups()
- > freq_num = float(freq_num)
- > if unit == "G": freq_num = freq_num * GIGA
- > if unit == "M": freq_num = freq_num * MEGA
- > if unit == "k": freq_num = freq_num * KILO
- > e = int(math.floor(math.log10(freq_num)))
- 491c503
- < m = int(math.floor(freq_num))
- ---
- > m = int(freq_num)
- 493c505
- < iwreq = iwstruct.pack("ihBB", m, e, 0, pythonwifi.flags.IW_FREQ_FIXED)
- ---
- > iwreq = iwstruct.pack(format, m, e, 0, pythonwifi.flags.IW_FREQ_FIXED)
- 512a525,526
- > this_modes = [x.lower() for x in pythonwifi.flags.modes]
- > mode = mode.lower()
- 514,515d527
- < this_modes = [x.lower() for x in pythonwifi.flags.modes]
- < mode = mode.lower()
- 517,519c529,530
- < except ValueError:
- < raise ValueError("Invalid operation mode!")
- <
- ---
- > except ValueError, detail:
- > raise ValueError("Invalid mode")
- 699d709
- < self.essid_on = 0
- 1020,1021c1030,1031
- < buff = 32 # - pythonwifi.flags.IFNAMSIZE
- < ifreq.extend('\0'*buff)
- ---
- > # extend to 32 bytes for ioctl payload
- > ifreq.extend('\0'*16)
- 1519c1529
- < raw_mode = struct.unpack('I', data)[0]
- ---
- > raw_mode = struct.unpack('I', data[:4])[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement