fixed import errors

This commit is contained in:
bwees
2022-10-19 18:55:05 -04:00
parent 0d5820932f
commit 495e322c9e
+6 -6
View File
@@ -2,10 +2,9 @@ import hashlib
import logging
import os
import re
import time
import urllib3
import requests
import simplejson
import json
from changedetectionio import content_fetcher, html_tools
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@@ -57,17 +56,18 @@ class perform_site_check():
# Tweak the base config with the per-watch ones
request_headers = self.datastore.data['settings']['headers'].copy()
if self.datastore.get_val(uuid, 'external_header_server') is not None:
if self.datastore.data['watching'][uuid].get('external_header_server') is not None:
try:
resp = requests.get(self.datastore.get_val(uuid, 'external_header_server'))
resp = requests.get(self.datastore.data['watching'][uuid].get('external_header_server'))
if resp.status_code != 200:
raise Exception("External header server returned non-200 response. Please check the URL for the server")
data = json.loads(resp.text.strip())
request_headers.update(resp.json())
except simplejson.errors.JSONDecodeError:
except json.decoder.JSONDecodeError:
raise Exception("Failed to decode JSON response from external header server")
request_headers.update(extra_headers)
# https://github.com/psf/requests/issues/4525