本文整理汇总了Python中wifi.scan.Cell.frequency方法的典型用法代码示例。如果您正苦于以下问题:Python Cell.frequency方法的具体用法?Python Cell.frequency怎么用?Python Cell.frequency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wifi.scan.Cell
的用法示例。
在下文中一共展示了Cell.frequency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: normalize
# 需要导入模块: from wifi.scan import Cell [as 别名]
# 或者: from wifi.scan.Cell import frequency [as 别名]
def normalize(cell_block):
# The cell blocks come in with every line except the first indented at
# least 20 spaces. This removes the first 20 spaces off of those lines.
lines = textwrap.dedent(' ' * 20 + cell_block).splitlines()
cell = Cell()
while lines:
line = lines.pop(0)
if line.startswith('Quality'):
for re_name, quality_re in quality_re_dict.items():
match_result = quality_re.search(line)
if match_result is not None:
cell.quality, signal = match_result.groups()
if re_name == 'relative':
actual, total = map(int, signal.split('/'))
cell.signal = db2dbm(int((actual / total) * 100))
else:
cell.signal = int(signal)
break
elif line.startswith('Bit Rates'):
values = split_on_colon(line)[1].split('; ')
# consume next line of bit rates, because they are split on
# different lines, sometimes...
while lines[0].startswith(' ' * 10):
values += lines.pop(0).strip().split('; ')
cell.bitrates.extend(values)
elif ':' in line:
key, value = split_on_colon(line)
key = normalize_key(key)
if key == 'ie':
if 'Unknown' in value:
continue
# consume remaining block
values = [value]
while lines and lines[0].startswith(' ' * 4):
values.append(lines.pop(0).strip())
if 'WPA2' in value:
cell.encryption_type = 'wpa2'
elif 'WPA' in value:
cell.encryption_type = 'wpa'
if key == 'frequency':
frequency, channel = frequency_re.search(value).groups()
cell.frequency = frequency
cell.channel = int(channel)
elif key in normalize_value:
setattr(cell, key, normalize_value[key](value))
# It seems that encryption types other than WEP need to specify their
# existence.
if cell.encrypted and not hasattr(cell, 'encryption_type'):
cell.encryption_type = 'wep'
return cell