Mercurial > code > home > repos > homeauto
comparison service/wifi/scrape.py @ 1225:b8c0daabe5a5
factor out some URI generation
Ignore-this: 3c982a1fdbadcc3154278fbae3d2ce0
darcs-hash:22be14eeb34ca3e87842f4619af6277851033561
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 30 Mar 2019 18:59:19 -0700 |
parents | e1202af42d4d |
children | 7de8f0cd3392 |
comparison
equal
deleted
inserted
replaced
1224:e1202af42d4d | 1225:b8c0daabe5a5 |
---|---|
3 from cyclone.httpclient import fetch | 3 from cyclone.httpclient import fetch |
4 from rdflib import Literal, Graph, RDFS, URIRef | 4 from rdflib import Literal, Graph, RDFS, URIRef |
5 | 5 |
6 log = logging.getLogger() | 6 log = logging.getLogger() |
7 | 7 |
8 class Router(object): | 8 def macUri(macAddress: str) -> URIRef: |
9 def __repr__(self): | 9 return URIRef("http://bigasterisk.com/mac/%s" % dev['mac'].lower()) |
10 return repr(self.__dict__) | |
11 | 10 |
12 class Wifi(object): | 11 class Wifi(object): |
13 """ | 12 """ |
14 gather the users of wifi from the tomato routers | 13 gather the users of wifi from the tomato routers |
15 """ | 14 """ |
61 self.rereadConfig() | 60 self.rereadConfig() |
62 rows = yield loadOrbiData() | 61 rows = yield loadOrbiData() |
63 for row in rows: | 62 for row in rows: |
64 if 'clientHostname' in row: | 63 if 'clientHostname' in row: |
65 row['name'] = row['clientHostname'] | 64 row['name'] = row['clientHostname'] |
66 mac = URIRef('http://bigasterisk.com/mac/%s' % row['mac'].lower()) | 65 mac = macUri(row['mac'].lower()) |
67 label = self.graph.value(mac, RDFS.label) | 66 label = self.graph.value(mac, RDFS.label) |
68 if label: | 67 if label: |
69 row['name'] = label | 68 row['name'] = label |
70 returnValue(rows) | 69 returnValue(rows) |
71 | 70 |