From b162949c04b4037200bcc93cafffee353d5ec253 Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Mon, 24 Dec 2018 15:21:45 -0800 Subject: [PATCH] improved log messages --- tcc-exporter | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tcc-exporter b/tcc-exporter index 5993d0e..e7190bc 100755 --- a/tcc-exporter +++ b/tcc-exporter @@ -12,7 +12,7 @@ import urllib.request from http.server import HTTPServer, BaseHTTPRequestHandler from urllib.error import HTTPError -VERSION = '0.8.8' +VERSION = '0.8.9' PREFIX = 'https://mytotalconnectcomfort.com/' devices = list() @@ -48,9 +48,9 @@ class Client(object): data = urllib.parse.urlencode(form).encode('utf-8') request = urllib.request.Request(PREFIX + 'portal', data, headers) try: - log('DEBUG', 'HTTP GET {0}'.format(PREFIX + 'portal')) + log('DEBUG', 'Remote HTTP GET {0}'.format(PREFIX + 'portal')) self.urlopener.open(PREFIX + 'portal') # get signin cookie - log('DEBUG', 'HTTP POST {0}'.format(PREFIX + 'portal')) + log('DEBUG', 'Remote HTTP POST {0}'.format(PREFIX + 'portal')) data = self.urlopener.open(request) # actually sign in decoded = data.read().decode() if '/portal/Account/LogOff' in decoded: @@ -90,7 +90,7 @@ class Client(object): headers['Content-Type'] = 'application/json; charset=utf-8' request = urllib.request.Request(PREFIX + path, data, headers) try: - log('DEBUG', 'HTTP GET {0}'.format(PREFIX + path)) + log('DEBUG', 'Remote HTTP GET {0}'.format(PREFIX + path)) return self.urlopener.open(request) # actually fetch except HTTPError as e: log('INFO', 'TCC portal status: {0} - {1}'.format(e.code, e.reason)) @@ -138,9 +138,10 @@ class Client(object): class Server(BaseHTTPRequestHandler): # Simplified logging def log_message(self, format, *args): - log('DEBUG', format % args) + log('DEBUG', 'Finished GET request: {0}'.format(args[1])) def do_GET(self): + log('DEBUG', 'Received GET request.') results = bytes() for device in devices: data = client.device_status(device['DeviceID'])