dynasticorpheus / gigasetelements-cli

Gigaset Elements - python based command line interface
GNU General Public License v2.0
35 stars 11 forks source link

Traceback after auth = success #28

Closed fbartels closed 6 years ago

fbartels commented 6 years ago

Hi,

it seems like something has changed in the responses from the Gigaset API, as I recently started getting the following traceback from gigasetelements-cli:

$ /usr/local/bin/gigasetelements-cli
/usr/local/lib/python2.7/dist-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)

Gigaset Elements - Command-line Interface v1.5.0b5

[-] Identity          | VERIFIED | User logged in successfully.
[-] Authentication    | SUCCESS  |
Traceback (most recent call last):
  File "/usr/local/bin/gigasetelements-cli", line 9, in <module>
    load_entry_point('gigasetelements-cli==1.5.0b5', 'console_scripts', 'gigasetelements-cli')()
  File "/usr/local/lib/python2.7/dist-packages/gigasetelements/gigasetelements.py", line 740, in main
    base()
  File "/usr/local/lib/python2.7/dist-packages/gigasetelements/gigasetelements.py", line 663, in base
    auth_time = authenticate()
  File "/usr/local/lib/python2.7/dist-packages/gigasetelements/gigasetelements.py", line 233, in authenticate
    rest(HEAD, URL_USAGE, None, False, 2, 0, True)
  File "/usr/local/lib/python2.7/dist-packages/gigasetelements/gigasetelements.py", line 216, in rest
    return data
UnboundLocalError: local variable 'data' referenced before assignment
dynasticorpheus commented 6 years ago

@fbartels Just did a quick test against both python 2.x and 3.x but have no issues? Perhaps a good first step would be to upgrade the dependencies?

(sudo) pip install --upgrade --requirement https://raw.githubusercontent.com/dynasticorpheus/gigasetelements-cli/develop/requirements.txt

fbartels commented 6 years ago

Hi @dynasticorpheus ,

thanks for the response. In my first tries to resolve I already did a reinstall of the script via sudo pip install --upgrade --force-reinstall git+https://github.com/dynasticorpheus/gigasetelements-cli@develop, but now also issued your command just for the dependencies. Unfortunately this did not change it.

I know such scenarios where the local admin says "i did not change anything" and this is of course never true, but this time it really is :-D (this is why I assumed this must have been a change in the Gigaset API).

I will try to dockerise the script this evening to see if this has something to do with my local machine. Good to know that python3 is supported as well, will see to use that in the Container.

Thanks for your help so far.

fbartels commented 6 years ago

Hi, I've added a minimal Makefile and a Dockerfile to https://github.com/fbartels/gigasetelements-cli/tree/docker. So now I can do make docker-run and it will do a local build of the develop branch and then run (while mounting .gigasetelements-cli from my $HOME. Unfortunately the error is still the same:

$ make docker-run
Building Docker image
docker build -t gigasetelements-cli .
Sending build context to Docker daemon  335.9kB
Step 1/4 : FROM python:3.7-alpine3.8
 ---> d30308ec4dc1
Step 2/4 : RUN apk update && apk upgrade &&     apk add --no-cache git
 ---> Using cache
 ---> 331d14efbc90
Step 3/4 : RUN pip install git+https://github.com/dynasticorpheus/gigasetelements-cli@develop
 ---> Using cache
 ---> e4a72b75d2ff
Step 4/4 : ENTRYPOINT [ "/usr/local/bin/gigasetelements-cli" ]
 ---> Using cache
 ---> 4211bc0cd473
Successfully built 4211bc0cd473
Successfully tagged gigasetelements-cli:latest
docker run -it --rm \
        -v /home/fbartels/.gigasetelements-cli:/root/.gigasetelements-cli \
        gigasetelements-cli

Gigaset Elements - Command-line Interface v1.5.0b5

[-] Identity          | VERIFIED | User logged in successfully.
[-] Authentication    | SUCCESS  |
Traceback (most recent call last):
  File "/usr/local/bin/gigasetelements-cli", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/gigasetelements/gigasetelements.py", line 740, in main
    base()
  File "/usr/local/lib/python3.7/site-packages/gigasetelements/gigasetelements.py", line 663, in base
    auth_time = authenticate()
  File "/usr/local/lib/python3.7/site-packages/gigasetelements/gigasetelements.py", line 233, in authenticate
    rest(HEAD, URL_USAGE, None, False, 2, 0, True)
  File "/usr/local/lib/python3.7/site-packages/gigasetelements/gigasetelements.py", line 216, in rest
    return data
UnboundLocalError: local variable 'data' referenced before assignment
Makefile:13: die Regel für Ziel „docker-run“ scheiterte
make: *** [docker-run] Fehler 1
dynasticorpheus commented 6 years ago

@fbartels Could you try again after installing the latest DEV version to see if my last commit prevents the UnboundLocalError you are facing?

fbartels commented 6 years ago

Hi @dynasticorpheus,

yes that does fix the issue for me. Thanks!

dynasticorpheus commented 6 years ago

@fbartels Cool, thanks for reporting!