tempname1024 / allium

Repository moved to https://git.jordan.im/allium/
https://relays.0x7c0.com
The Unlicense
18 stars 3 forks source link

Error, bug? - UndefinedError: 'dict object' has no attribute 'exit_count,1' #8

Closed scriptzteam closed 3 years ago

scriptzteam commented 3 years ago
python3 generate.py

Traceback (most recent call last):
  File "generate.py", line 44, in <module>
    RELAY_SET.write_misc(
  File "/home/allium/relays.py", line 217, in write_misc
    template_render = template.render(
  File "/usr/lib/python3/dist-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/home/allium/templates/misc-families.html", line 2, in <module>
    {% set sorted_by_label = sorted_by.split(',')[0].split('.')[1] -%}
  File "/home/allium/templates/skeleton.html", line 45, in <module>
    {% block body %}
  File "/home/allium/templates/misc-families.html", line 41, in <module>
    {% for k, v in relays.json['sorted']['family'].items()|sort(attribute=sorted_by,
  File "/usr/lib/python3/dist-packages/jinja2/filters.py", line 283, in do_sort
    return sorted(value, key=key_func, reverse=reverse)
  File "/usr/lib/python3/dist-packages/jinja2/filters.py", line 82, in attrgetter
    item = environment.getitem(item, part)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 411, in getitem
    return obj[argument]
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'exit_count,1'
scriptzteam commented 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
tempname1024 commented 3 years ago

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.

scriptzteam commented 3 years ago

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)
tempname1024 commented 3 years ago

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

scriptzteam commented 3 years ago

jinja2 upgrade helped, thx much!