diff --git a/backend/fetch_site_status.py b/backend/fetch_site_status.py index 561d34ae..92922254 100644 --- a/backend/fetch_site_status.py +++ b/backend/fetch_site_status.py @@ -34,10 +34,13 @@ class perform_site_check(Thread): def save_response_stripped_output(self, output): - with open("{}/{}.stripped.txt".format(self.output_path, self.timestamp), 'w') as f: + fname = "{}/{}.stripped.txt".format(self.output_path, self.timestamp) + with open(fname, 'w') as f: f.write(output) f.close() + return fname + def run(self): headers = { @@ -90,7 +93,14 @@ class perform_site_check(Thread): self.datastore.update_watch(self.uuid, 'previous_md5', fetched_md5) self.save_response_html_output(r.text) - self.save_response_stripped_output(stripped_text_from_html) + output_filepath = self.save_response_stripped_output(stripped_text_from_html) + + # Update history with the stripped text for future reference + # need to learn more about attr/setters/getters + history = self.datastore.get_val(self.uuid, 'history') + history.update(dict([(self.timestamp, output_filepath)])) + + self.datastore.update_watch(self.uuid, 'history', history) self.datastore.update_watch(self.uuid, 'last_checked', int(time.time())) diff --git a/backend/store.py b/backend/store.py index e3b5f637..54879472 100644 --- a/backend/store.py +++ b/backend/store.py @@ -18,7 +18,8 @@ class ChangeDetectionStore: 'last_changed': 0, 'title': None, 'uuid': str(uuid.uuid4()), - 'headers' : {} + 'headers' : {}, # Extra headers to send + 'history' : {} # Dict of timestamp and output stripped filename } try: