rmartin16 / qbittorrent-api

Python client implementation for qBittorrent's Web API
https://qbittorrent-api.readthedocs.io/
MIT License
413 stars 67 forks source link

Missing AttributeError: __enter__ #470

Closed MarcusJohnRose closed 4 months ago

MarcusJohnRose commented 4 months ago

Describe the bug

when trying to use Client as a context manager getting the following error AttributeError: __enter__

Steps to reproduce

Trying to use the with context manager

conn_info = dict(host="192.168.0.6",
                     port=30024,
                     username="admin",
                     password="adminadmin")

 with qbittorrentapi.Client(**conn_info) as qbt_client:
        print(f"qBittorrent: {qbt_client.app.version}")
        try:
            qbt_client.auth_log_in()
            print("successfully logged in ")
        except qbittorrentapi.LoginFailed as e:
            print(e) 

when connecting without the context manager

qbt_client = qbittorrentapi.Client(**conn_info)
    try:
        qbt_client.auth_log_in()
        print("successfully logged in ")
    except qbittorrentapi.LoginFailed as e:
        print(e)

No error present

Expected behavior

connects to api and prints print("successfully logged in ")

Screenshots

No response

Environment

Additional context

No response

rmartin16 commented 4 months ago

This functionality has existed since v2023.4.47. When I run your code above using v2024.3.60, it works for me.

My best guess is an older version of qbittorrent-api is actually being used.

What version of qbittorrent-api does python -m pip show qbittorrent-api show is installed?

MarcusJohnRose commented 4 months ago

strange, Pip was showing I was update to date, however appears I wasn't

Version: 2023.2.43 Summary: Python client for qBittorrent v4.1+ Web API. Home-page: https://github.com/rmartin16/qbittorrent-api Author: Russell Martin Author-email: rmartin16@gmail.com License: MIT Location: c:\users\marcus\appdata\local\programs\python\python310\lib\site-packages Requires: requests, setuptools, six, urllib3 Required-by:

I've reinstalled the package via pip and its working again. (should have done that before raising this 🙈) not sure how I manged to downgrade 2 separate machines but appears I broke it my end. Thank you for your time :)