csv file for historical data
This commit is contained in:
parent
5ebf89bc27
commit
3a09b08990
|
@ -6,6 +6,7 @@ import sys
|
||||||
|
|
||||||
html_file = '/users/n3parikh/www/office-status.html'
|
html_file = '/users/n3parikh/www/office-status.html'
|
||||||
json_file = '/users/n3parikh/www/office-status.json'
|
json_file = '/users/n3parikh/www/office-status.json'
|
||||||
|
csv_file = '/users/n3parikh/www/office-status.csv'
|
||||||
|
|
||||||
def writeOpenHTML(lux):
|
def writeOpenHTML(lux):
|
||||||
hmtl = \
|
hmtl = \
|
||||||
|
@ -41,6 +42,11 @@ def writeJSON(status):
|
||||||
with open(json_file, 'w') as f:
|
with open(json_file, 'w') as f:
|
||||||
f.write(json.dumps(out_json))
|
f.write(json.dumps(out_json))
|
||||||
|
|
||||||
|
def writeCSV(status):
|
||||||
|
out = "%f,%d\n" % (time.time(), status)
|
||||||
|
with open(csv_file, 'a') as f:
|
||||||
|
f.write(out)
|
||||||
|
|
||||||
logging.basicConfig(filename='/users/n3parikh/office/log',
|
logging.basicConfig(filename='/users/n3parikh/office/log',
|
||||||
filemode='a',
|
filemode='a',
|
||||||
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
|
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
|
||||||
|
@ -55,6 +61,7 @@ except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
writeUnknownHTML()
|
writeUnknownHTML()
|
||||||
writeJSON(-1)
|
writeJSON(-1)
|
||||||
|
writeCSV(-1)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if r.status_code == 200 and r.text != "error":
|
if r.status_code == 200 and r.text != "error":
|
||||||
|
@ -74,3 +81,4 @@ else:
|
||||||
logger.error(r.text)
|
logger.error(r.text)
|
||||||
writeUnknownHTML()
|
writeUnknownHTML()
|
||||||
writeJSON(status)
|
writeJSON(status)
|
||||||
|
writeCSV(status)
|
||||||
|
|
Loading…
Reference in New Issue