Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.97 KB | None | 0 0
  1.  
  2. diff pythonwifi/iwlibs.py git/pythonwifi/pythonwifi/iwlibs.py
  3. 1c1
  4. < # -*- coding: latin1 -*-
  5. ---
  6. > # -*- coding: utf-8 -*-
  7. 168a169,170
  8. >
  9. >             FIXME: This needs to check address type before acting.
  10. 177c179,181
  11. <             if ":" not in addr: return (errno.ENOSYS, os.strerror(errno.ENOSYS))
  12. ---
  13. >             if ":" not in addr:
  14. >                 # not a hardware address
  15. >                 raise IOError(errno.ENOSYS, os.strerror(errno.ENOSYS))
  16. 389c393
  17. <     def setKey(self, key, index=0):
  18. ---
  19. >     def setKey(self, key, index=1):
  20. 473a478
  21. >         format = "lhBB"
  22. 476c481
  23. <             iwreq = iwstruct.pack("ihBB", -1, 0, 0, pythonwifi.flags.IW_FREQ_AUTO)
  24. ---
  25. >             iwreq = iwstruct.pack(format, -1, 0, 0, pythonwifi.flags.IW_FREQ_AUTO)
  26. 480c485
  27. <             freq_pattern = re.compile("([\d\.]+)(\w)", re.I|re.M|re.S)
  28. ---
  29. >             freq_pattern = re.compile("([\d\.]+)\s?([GMk])\w?", re.I|re.M|re.S)
  30. 482,486c487,498
  31. <             freq_num, unit = freq_match.groups()
  32. <             if unit == "G": freq_num = float(freq_num) * GIGA
  33. <             if unit == "M": freq_num = float(freq_num) * MEGA
  34. <             if unit == "k": freq_num = float(freq_num) * KILO
  35. <             e = math.floor(math.log10(freq_num))
  36. ---
  37. >             if freq_match is None:
  38. >                 # match failed, try to just find a number (no units)
  39. >                 freq_pattern = re.compile("([\d\.]+)", re.I|re.M|re.S)
  40. >                 freq_match = freq_pattern.search(freq)
  41. >                 freq_num, unit = (freq_match.groups()[0], "")
  42. >             else:
  43. >                 freq_num, unit = freq_match.groups()
  44. >             freq_num = float(freq_num)
  45. >             if unit == "G": freq_num = freq_num * GIGA
  46. >             if unit == "M": freq_num = freq_num * MEGA
  47. >             if unit == "k": freq_num = freq_num * KILO
  48. >             e = int(math.floor(math.log10(freq_num)))
  49. 491c503
  50. <                 m = int(math.floor(freq_num))
  51. ---
  52. >                 m = int(freq_num)
  53. 493c505
  54. <             iwreq = iwstruct.pack("ihBB", m, e, 0, pythonwifi.flags.IW_FREQ_FIXED)
  55. ---
  56. >             iwreq = iwstruct.pack(format, m, e, 0, pythonwifi.flags.IW_FREQ_FIXED)
  57. 512a525,526
  58. >         this_modes = [x.lower() for x in pythonwifi.flags.modes]
  59. >         mode = mode.lower()
  60. 514,515d527
  61. <             this_modes = [x.lower() for x in pythonwifi.flags.modes]
  62. <             mode = mode.lower()
  63. 517,519c529,530
  64. <         except ValueError:
  65. <             raise ValueError("Invalid operation mode!")
  66. <
  67. ---
  68. >         except ValueError, detail:
  69. >             raise ValueError("Invalid mode")
  70. 699d709
  71. <         self.essid_on = 0
  72. 1020,1021c1030,1031
  73. <             buff = 32 # - pythonwifi.flags.IFNAMSIZE
  74. <             ifreq.extend('\0'*buff)
  75. ---
  76. >             # extend to 32 bytes for ioctl payload
  77. >             ifreq.extend('\0'*16)
  78. 1519c1529
  79. <                 raw_mode = struct.unpack('I', data)[0]
  80. ---
  81. >                 raw_mode = struct.unpack('I', data[:4])[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement