diff options
author | Josef Gustafsson <josef.gson@gmail.com> | 2015-09-28 14:35:02 +0200 |
---|---|---|
committer | Josef Gustafsson <josef.gson@gmail.com> | 2015-09-28 14:35:02 +0200 |
commit | 3ce97b21e8efe2432f3b4fcbd494c4b9560341fb (patch) | |
tree | 21fa544aaa1d015bfb1c04308d3cc5e886353e44 /monitor/josef_monitor.py | |
parent | bff0a1bfc41e8cae9d96ec587e15956fab0b9cfa (diff) |
changing log timestamps to UTC
Diffstat (limited to 'monitor/josef_monitor.py')
-rwxr-xr-x | monitor/josef_monitor.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py index 6c189ca..a32cf7d 100755 --- a/monitor/josef_monitor.py +++ b/monitor/josef_monitor.py @@ -122,6 +122,7 @@ class ctlog: def log(self, string): s = time.strftime('%Y-%m-%d %H:%M:%S') + " " + string + s = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') + " " + string with open(self.logfile, 'a') as f: f.write(s + "\n") f.close() @@ -133,12 +134,11 @@ class ctlog: self.log("Failed to fetch STH. " +str(e)) return - # try: - check_sth_signature(self.url, new_sth, base64.b64decode(self.key)) - # check_sth_signature(self.url, new_sth, None) - # except: - # self.log("ERROR: Could not verify STH signature") - # print "ERROR: Could not verify STH signature from " + self.url + try: + check_sth_signature(self.url, new_sth, base64.b64decode(self.key)) + except: + self.log("ERROR: Could not verify STH signature") + print "ERROR: Could not verify STH signature from " + self.url sth_time = datetime.datetime.fromtimestamp(new_sth['timestamp'] / 1000, UTC()).strftime("%Y-%m-%d %H:%M:%S") if new_sth["timestamp"] != self.sth["timestamp"]: @@ -444,17 +444,17 @@ def main(args): open(CONFIG.DOMAINS_FILE, 'w').write(json.dumps(domain_dict)) # Something went horribly wrong! - # except Exception, err: - # print Exception, err - # for log in logs: - # log.save() - - # # Save info about monitored domains - # domain_dict = [] - # if len(monitored_domains) > 0: - # for md in monitored_domains: - # domain_dict.append(md.to_dict()) - # open(CONFIG.DOMAINS_FILE, 'w').write(json.dumps(domain_dict)) + except Exception, err: + print Exception, err + for log in logs: + log.save() + + # Save info about monitored domains + domain_dict = [] + if len(monitored_domains) > 0: + for md in monitored_domains: + domain_dict.append(md.to_dict()) + open(CONFIG.DOMAINS_FILE, 'w').write(json.dumps(domain_dict)) |