zbjdonald / synology-drive-api

Synology drive api python wrapper.
MIT License
64 stars 16 forks source link

error 119 #6

Closed jlstanus closed 2 years ago

jlstanus commented 2 years ago

I tried to connect to drive. I get always a 119 error

synd.get_info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python39\lib\site-packages\synology_drive_api\drive.py", line 45, in get_info
    return self.session.http_get(endpoint, params=params)
  File "C:\Python39\lib\site-packages\synology_drive_api\base.py", line 203, in http_get
    return self._request('get', endpoint, **kwargs)
  File "C:\Python39\lib\site-packages\synology_drive_api\base.py", line 196, in _request
    raise_synology_exception(res, bio_exist=bio_flag)
  File "C:\Python39\lib\site-packages\synology_drive_api\base.py", line 118, in raise_synology_exception
    raise SynologyException(
synology_drive_api.base.SynologyException: {"error":{"code":119},"success":false}

No problem with https://github.com/N4S4/synology-api

zbjdonald commented 2 years ago

Hi, according to Web_API_Guide, 119 means invalid session. How do you initialize SynologyDrive?

jlstanus commented 2 years ago

Like this image

jlstanus commented 2 years ago

What's an invalid session?

zbjdonald commented 2 years ago

Sorry,I can't reproduce this error. Did you try some other api requests such as download somthing?

keoy7am commented 2 years ago

@jlstanus The program is not executed within the scope of the with statement

Problem Reproduces

with SynologyDrive(NAS_USER, NAS_PASS, NAS_IP) as synd:
    pass // __exit__ (logout) will be triggered when you leave this line

labels = synd.get_labels() // got invalid session error because it's logged out.
print(labels)

Try this

with SynologyDrive(NAS_USER, NAS_PASS, NAS_IP) as synd:
    labels= synd.get_labels()
    print(labels)
    // other logic...
    // __exit__ (logout) will be triggered when finished all logic