|
|
|
@ -6,6 +6,7 @@ import sys |
|
|
|
|
|
|
|
|
|
html_file = '/users/n3parikh/www/office-status.html' |
|
|
|
|
json_file = '/users/n3parikh/www/office-status.json' |
|
|
|
|
csv_file = '/users/n3parikh/www/office-status.csv' |
|
|
|
|
|
|
|
|
|
def writeOpenHTML(lux): |
|
|
|
|
hmtl = \ |
|
|
|
@ -41,6 +42,11 @@ def writeJSON(status): |
|
|
|
|
with open(json_file, 'w') as f: |
|
|
|
|
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', |
|
|
|
|
filemode='a', |
|
|
|
|
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', |
|
|
|
@ -55,6 +61,7 @@ except Exception as e: |
|
|
|
|
logger.error(e) |
|
|
|
|
writeUnknownHTML() |
|
|
|
|
writeJSON(-1) |
|
|
|
|
writeCSV(-1) |
|
|
|
|
sys.exit() |
|
|
|
|
|
|
|
|
|
if r.status_code == 200 and r.text != "error": |
|
|
|
@ -74,3 +81,4 @@ else: |
|
|
|
|
logger.error(r.text) |
|
|
|
|
writeUnknownHTML() |
|
|
|
|
writeJSON(status) |
|
|
|
|
writeCSV(status) |
|
|
|
|