Add HardwareSerial parameter
This commit is contained in:
parent
599cf4375e
commit
2ee2a97d40
1 changed files with 16 additions and 6 deletions
|
|
@ -10,6 +10,17 @@ SQLITE_LOCATION = Config.get("Storage", "sqlite_location")
|
||||||
|
|
||||||
|
|
||||||
class Series(Resource):
|
class Series(Resource):
|
||||||
|
def __init__(self):
|
||||||
|
self._cpuserial = "0000000000000000"
|
||||||
|
try:
|
||||||
|
f = open('/proc/cpuinfo','r')
|
||||||
|
for line in f:
|
||||||
|
if line[0:6]=='Serial':
|
||||||
|
self._cpuserial = line[10:26]
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
self._cpuserial = "ERROR000000000"
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
format = request.args['format']
|
format = request.args['format']
|
||||||
limit = int(request.args.get('limit', 20))
|
limit = int(request.args.get('limit', 20))
|
||||||
|
|
@ -32,22 +43,21 @@ class Series(Resource):
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
if format == 'json':
|
if format == 'json':
|
||||||
return Series._get_json(col_names, data)
|
return self._get_json(col_names, data)
|
||||||
elif format == 'csv':
|
elif format == 'csv':
|
||||||
return Series._get_csv(col_names, data)
|
return self._get_csv(col_names, data)
|
||||||
|
|
||||||
@staticmethod
|
def _get_json(self, col_names, data):
|
||||||
def _get_json(col_names, data):
|
|
||||||
items = []
|
items = []
|
||||||
for row in data:
|
for row in data:
|
||||||
item = {}
|
item = {}
|
||||||
|
item['HardwareSerial'] = self._cpuserial
|
||||||
for i in range(len(col_names)):
|
for i in range(len(col_names)):
|
||||||
item[col_names[i]] = row[i]
|
item[col_names[i]] = row[i]
|
||||||
items.append(item)
|
items.append(item)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@staticmethod
|
def _get_csv(self, col_names, data):
|
||||||
def _get_csv(col_names, data):
|
|
||||||
"""
|
"""
|
||||||
Write CSV export to memory
|
Write CSV export to memory
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue