Chouffy / home_assistant_tgtg

TooGoodToGo items stock as sensor in Home Assistant
MIT License
65 stars 18 forks source link

getting tokens by docker not working #72

Closed bartek75 closed 1 year ago

bartek75 commented 1 year ago

System Health details

not relevant to HA

Checklist

Describe the issue

when running docker build https://github.com/Chouffy/home_assistant_tgtg.git#main --tag "homeassistant_tgtg_tokens:latest" on ubuntu 20 it fails with

_Collecting ruamel.yaml==0.15.72
  Downloading ruamel.yaml-0.15.72.tar.gz (309 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 309.9/309.9 KB 5.0 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 211, in <module>
          pkg_data = _package_data(__file__.replace('setup.py', '__init__.py'))
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 184, in _package_data
          data = literal_eval("".join(lines))
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 156, in literal_eval
          return _convert(node_or_string)
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 95, in _convert
          if isinstance(node, Str):
      NameError: name 'Str' is not defined
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
The command '/bin/sh -c python -m pip install -r requirements.txt' returned a non-zero code: 1_

Reproduction steps

  1. docker build https://github.com/Chouffy/home_assistant_tgtg.git#main --tag "homeassistant_tgtg_tokens:latest"

Debug logs

Collecting ruamel.yaml==0.15.72
  Downloading ruamel.yaml-0.15.72.tar.gz (309 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 309.9/309.9 KB 5.0 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 211, in <module>
          pkg_data = _package_data(__file__.replace('setup.py', '__init__.py'))
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 184, in _package_data
          data = literal_eval("".join(lines))
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 156, in literal_eval
          return _convert(node_or_string)
        File "/tmp/pip-install-jw9mfj8a/ruamel-yaml_1fa05d8779c546a68d69b4b677d28004/setup.py", line 95, in _convert
          if isinstance(node, Str):
      NameError: name 'Str' is not defined
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
The command '/bin/sh -c python -m pip install -r requirements.txt' returned a non-zero code: 1

Diagnostics dump

No response

DasPflanze commented 1 year ago

Hi, for me it took way to long to even build the container so I cancelled it and ran it that way:

docker run -it python:3.9 /bin/bash

Inside that container: python -m pip install --upgrade pip

then get the skript with: wget https://raw.githubusercontent.com/Chouffy/home_assistant_tgtg/main/tgtg_get_tokens.py

and now run it: python tgtg_get_tokens.py

maxxer commented 1 year ago

Thanks @DasPflanze, but I think your steps are missing the script requirements. I got it working with:


python -m pip install --upgrade pip
wget https://raw.githubusercontent.com/Chouffy/home_assistant_tgtg/main/requirements.txt
pip install -r requirements.txt
wget https://raw.githubusercontent.com/Chouffy/home_assistant_tgtg/main/tgtg_get_tokens.py
python tgtg_get_tokens.py
DasPflanze commented 1 year ago

@maxxer you are right, I missed that. Now I wondered why my way was that much quicker and realized, that while I used python:3.9 the Dockerfile used in the manual is running 3.8. Running the Dockerfile with 3.8 took so long, that I canceled it. Changing the Dockerfile to FROM python:3.9-slim solved that problem and is now as fast as one would expect.