本文整理汇总了Python中node.Node.gps方法的典型用法代码示例。如果您正苦于以下问题:Python Node.gps方法的具体用法?Python Node.gps怎么用?Python Node.gps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node.Node
的用法示例。
在下文中一共展示了Node.gps方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_aliases
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import gps [as 别名]
def import_aliases(self, aliases):
for mac, alias in aliases.items():
try:
node = self.maybe_node_by_mac([mac])
except:
try:
node = self.maybe_node_by_fuzzy_mac(mac)
except:
# create an offline node
node = Node()
node.add_mac(mac)
self._nodes.append(node)
if 'name' in alias:
node.name = alias['name']
if 'vpn' in alias and alias['vpn'] and mac and node.interfaces and mac in node.interfaces:
node.interfaces[mac].vpn = True
if 'gps' in alias:
node.gps = alias['gps']
if 'firmware' in alias:
node.firmware = alias['firmware']
if 'id' in alias:
node.id = alias['id']
示例2: load_state
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import gps [as 别名]
def load_state(self, filename):
try:
with open(filename, "r") as f:
obj = json.load(f)
for n in obj:
try:
node = self.maybe_node_by_id(n['id'])
except:
node = Node()
node.id = n['id']
node.name = n['name']
node.lastseen = n['lastseen']
node.gps = n['geo']
node.firmware = n['firmware']
node.firmware_release = n['firmware_release']
node.hardware = n['hardware']
node.autoupdate = n['autoupdate']
node.branch = n['branch']
self._nodes.append(node)
if 'firstseen' in n:
node.firstseen = n['firstseen']
except:
pass
示例3: import_aliases
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import gps [as 别名]
def import_aliases(self, aliases):
for mac, alias in aliases.items():
try:
node = self.maybe_node_by_mac([mac])
except:
try:
node = self.maybe_node_by_fuzzy_mac(mac)
except:
# create an offline node
node = Node()
node.add_mac(mac)
self._nodes.append(node)
if 'name' in alias:
node.name = alias['name']
if 'vpn' in alias and alias['vpn'] and mac and node.interfaces and mac in node.interfaces:
try:
node.interfaces[mac].vpn = True
except:
print("error with ", mac)
if 'gps' in alias:
node.gps = alias['gps']
if 'firmware' in alias:
node.firmware = alias['firmware']
if 'model' in alias:
node.model = alias['model']
if 'uptime' in alias:
node.uptime = alias['uptime']
if 'id' in alias:
node.id = alias['id']
if 'addresses' in alias:
node.addresses = alias['addresses']
if 'autoupdater_enabled' in alias:
node.autoupdater['enabled'] = alias['autoupdater_enabled']
if 'autoupdater_branch' in alias:
node.autoupdater['branch'] = alias['autoupdater_branch']
if 'contact' in alias:
node.contact = alias['contact']
示例4: import_aliases
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import gps [as 别名]
def import_aliases(self, aliases):
for mac, alias in aliases.items():
try:
node = self.maybe_node_by_mac([mac])
except:
try:
node = self.maybe_node_by_fuzzy_mac(mac)
except:
# create an offline node
node = Node()
node.add_mac(mac)
self._nodes.append(node)
if 'name' in alias:
node.name = alias['name']
if 'vpn' in alias and alias['vpn'] and mac and node.interfaces and mac in node.interfaces:
node.interfaces[mac].vpn = True
if 'gps' in alias:
node.gps = alias['gps']
if 'firmware' in alias:
node.firmware = alias['firmware']
if 'id' in alias:
node.id = alias['id']
if 'uptime' in alias:
node.uptime = alias['uptime']
if 'tx_bytes' in alias:
node.tx_bytes = alias['tx_bytes']
if 'rx_bytes' in alias:
node.rx_bytes = alias['rx_bytes']
if 'loadavg' in alias:
node.loadavg = alias['loadavg']
if 'autoupdater' in alias:
node.autoupdater = alias['autoupdater']
if 'branch' in alias:
node.branch = alias['branch']
if 'hardware' in alias:
node.hardware = alias['hardware']
示例5: load_state
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import gps [as 别名]
def load_state(self, filename):
try:
with open(filename, "r") as f:
obj = json.load(f)
for n in obj:
try:
node = self.maybe_node_by_id(n['id'])
except:
node = Node()
node.id = n['id']
node.name = n['name']
node.lastseen = n['lastseen']
node.gps = n['geo']
self._nodes.append(node)
except:
pass
示例6: import_wikigps
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import gps [as 别名]
def import_wikigps(self, url):
def fetch_wikitable(url):
f = urlopen(url)
soup = BeautifulSoup(f)
table = soup.find_all("table")[0]
rows = table.find_all("tr")
headers = []
data = []
def maybe_strip(x):
if isinstance(x.string, str):
return x.string.strip()
else:
return ""
for row in rows:
tds = list([maybe_strip(x) for x in row.find_all("td")])
ths = list([maybe_strip(x) for x in row.find_all("th")])
if any(tds):
data.append(tds)
if any(ths):
headers = ths
nodes = []
for d in data:
nodes.append(dict(zip(headers, d)))
return nodes
nodes = fetch_wikitable(url)
for node in nodes:
try:
node['MAC'] = node['MAC'].split(',')
except KeyError:
pass
try:
node['GPS'] = node['GPS'].split(',')
except KeyError:
pass
try:
node['Nick'] = node['Nick'].split(',')
except KeyError:
pass
nodes = zip_longest(node['MAC'], node['GPS'], node['Nick'])
for data in nodes:
if not data[0]:
continue
try:
node = self.maybe_node_by_mac((data[0], ))
except:
node = Node()
node.add_mac(data[0])
self._nodes.append(node)
if data[1]:
node.gps = data[1]
if data[2]:
node.name = data[2]