mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-09-24 06:15:52 +00:00
Attempt to save last data retrieved- WIP
This commit is contained in:
@@ -15,6 +15,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
class perform_site_check():
|
||||
screenshot = None
|
||||
xpath_data = None
|
||||
fetched_response = None
|
||||
|
||||
def __init__(self, *args, datastore, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -131,6 +132,7 @@ class perform_site_check():
|
||||
|
||||
self.screenshot = fetcher.screenshot
|
||||
self.xpath_data = fetcher.xpath_data
|
||||
self.fetched_response = fetcher.content
|
||||
|
||||
# Fetching complete, now filters
|
||||
# @todo move to class / maybe inside of fetcher abstract base?
|
||||
|
||||
@@ -375,6 +375,17 @@ class ChangeDetectionStore:
|
||||
f.write(json.dumps(data))
|
||||
f.close()
|
||||
|
||||
# Save whatever was returned from the fetcher
|
||||
def save_last_response(self, watch_uuid, data):
|
||||
if not self.data['watching'].get(watch_uuid):
|
||||
return
|
||||
|
||||
target_path = os.path.join(self.datastore_path, watch_uuid, "last-response.bin")
|
||||
# mimetype? binary? text? @todo
|
||||
# gzip if its non-binary? auto get encoding?
|
||||
with open(target_path, 'wb') as f:
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
def sync_to_json(self):
|
||||
logging.info("Saving JSON..")
|
||||
|
||||
@@ -286,6 +286,9 @@ class update_worker(threading.Thread):
|
||||
self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot)
|
||||
if update_handler.xpath_data:
|
||||
self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data)
|
||||
if update_handler.fetched_response:
|
||||
# @todo mimetype?
|
||||
self.datastore.save_last_response(watch_uuid=uuid, data=update_handler.fetched_response)
|
||||
|
||||
|
||||
self.current_uuid = None # Done
|
||||
|
||||
Reference in New Issue
Block a user