Began rewrite with more modular design
This commit is contained in:
parent
54402ce089
commit
f5e3705eec
15 changed files with 354 additions and 708 deletions
18
inputs/alfred/__init__.py
Normal file
18
inputs/alfred/__init__.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import subprocess
|
||||
import json
|
||||
|
||||
class Input:
|
||||
def __init__(self,request_data_type = 158):
|
||||
self.request_data_type = request_data_type
|
||||
|
||||
def get_data(self, nodedb):
|
||||
"""Add data from alfred to the supplied nodedb"""
|
||||
output = subprocess.check_output([
|
||||
"alfred-json",
|
||||
"-r", str(self.request_data_type),
|
||||
"-f", "json",
|
||||
])
|
||||
alfred_data = json.loads(output.decode("utf-8"))
|
||||
|
||||
for mac, node in alfred_data.items():
|
||||
nodedb.add_or_update([mac], node)
|
Loading…
Add table
Add a link
Reference in a new issue