Closed scriptzteam closed 3 years ago
Traceback (most recent call last):
File "generate.py", line 21, in <module>
RELAY_SET = Relays()
File "/home/allium/relays.py", line 55, in __init__
self.json = self._fetch_onionoo_details()
File "/home/allium/relays.py", line 77, in _fetch_onionoo_details
api_response = urllib.request.urlopen(conn).read()
File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 304: Not Modified
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'exit_count,1'
This is most likely due to an out-of-date Jinja2 install, update to 2.11.2. Should probably add a requirements.txt to ensure libraries are up to date.
urllib.error.HTTPError: HTTP Error 304: Not Modified
An HTTP 304 response indicates there has been no change (Not Modified) in the relay set since last execution, the date of which is derived from the timestamp file generated at runtime.
gonna try update jinja2
pip3 install --upgrade jinja2
Collecting jinja2
Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 4.3 MB/s
Requirement already satisfied, skipping upgrade: MarkupSafe>=0.23 in /usr/lib/python3/dist-packages (from jinja2) (1.1.0)
Installing collected packages: jinja2
Attempting uninstall: jinja2
Found existing installation: Jinja2 2.10.1
Not uninstalling jinja2 at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'Jinja2'. No files were found to uninstall.
Successfully installed jinja2-2.11.2
also yeah, i tried this and problem gone
with open(self.ts_file, 'r') as ts_file:
prev_timestamp = ts_file.read()
#headers = {"If-Modified-Since": prev_timestamp}
#conn = urllib.request.Request(self.url, headers=headers)
conn = urllib.request.Request(self.url)
else:
conn = urllib.request.Request(self.url)
Cool. I'd probably leave that code in though, it prevents regeneration of files when there hasn't been a change to the relay set.
Upgrade jinja with pip install --upgrade jinja2
jinja2 upgrade helped, thx much!