mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-11-07 10:07:00 +00:00
Compare commits
1 Commits
restock-mu
...
save-last-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08c9b55e0f |
@@ -15,6 +15,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|||||||
class perform_site_check():
|
class perform_site_check():
|
||||||
screenshot = None
|
screenshot = None
|
||||||
xpath_data = None
|
xpath_data = None
|
||||||
|
fetched_response = None
|
||||||
|
|
||||||
def __init__(self, *args, datastore, **kwargs):
|
def __init__(self, *args, datastore, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@@ -131,6 +132,7 @@ class perform_site_check():
|
|||||||
|
|
||||||
self.screenshot = fetcher.screenshot
|
self.screenshot = fetcher.screenshot
|
||||||
self.xpath_data = fetcher.xpath_data
|
self.xpath_data = fetcher.xpath_data
|
||||||
|
self.fetched_response = fetcher.content
|
||||||
|
|
||||||
# Fetching complete, now filters
|
# Fetching complete, now filters
|
||||||
# @todo move to class / maybe inside of fetcher abstract base?
|
# @todo move to class / maybe inside of fetcher abstract base?
|
||||||
|
|||||||
@@ -375,6 +375,17 @@ class ChangeDetectionStore:
|
|||||||
f.write(json.dumps(data))
|
f.write(json.dumps(data))
|
||||||
f.close()
|
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):
|
def sync_to_json(self):
|
||||||
logging.info("Saving JSON..")
|
logging.info("Saving JSON..")
|
||||||
|
|||||||
@@ -286,6 +286,9 @@ class update_worker(threading.Thread):
|
|||||||
self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot)
|
self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot)
|
||||||
if update_handler.xpath_data:
|
if update_handler.xpath_data:
|
||||||
self.datastore.save_xpath_data(watch_uuid=uuid, data=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
|
self.current_uuid = None # Done
|
||||||
|
|||||||
Reference in New Issue
Block a user