JohnDoee / deluge-client

A very lightweight pure-python Deluge RPC Client
MIT License
87 stars 14 forks source link

ModuleNotFoundError: No module named 'deluge_client' #46

Open Sonic3R opened 9 months ago

Sonic3R commented 9 months ago

Hi,

I have created a class like

import logging

from torrent_clients.torrent_client import TorrentClient
from torrent_clients.torrent_data import TorrentData
from deluge_client import DelugeRPCClient

class DelugedClient(TorrentClient):
    def __init__(self, logger: logging.Logger, address: str, port: int, user: str, password: str) -> None:
        super().__init__(logger, address, port, user, password)

    def __get_torrent_client(self):
        if (
            len(self._address) == 0
            or len(self._pass) == 0
            or len(self._user) == 0
        ):
            raise  ValueError("Torrent client details are missing")

        client = DelugeRPCClient(self._address, self._port, self._user, self._pass, True)
        try:
            if not client.connected:
                client.connect()
            return client
        except Exception as e:
            self._logger.error(e)

        raise TypeError("Cannot initialise deluge client")

    def _get_torrent_list(self)->list[TorrentData]:
        client = self.__get_torrent_client()
        items:list[TorrentData] = []

        deluge_data = client.call("core.get_torrents_status", [], [])
        for key in deluge_data:
            obj = deluge_data[key]
            items.append(TorrentData(obj["name"], obj["hash"], obj["state"], obj["tracker"]))

        return items

    def _delete_torrent(self,torrent_id:str, delete_local_files: bool):
        client = self.__get_torrent_client()
        client.call("core.remove_torrent", [torrent_id], [delete_local_files])

    def _resume_torrent(self,torrent_ids:list[str]):
        client = self.__get_torrent_client()
        client.call("core.resume_torrents", torrent_ids, [])

and TorrentClient

class TorrentClient(abc.ABC):
   ...

When compile application, I get:

ModuleNotFoundError: No module named 'deluge_client'

Of course I ran:

pip install deluge-client

Seems to fail at

from deluge_client import DelugeRPCClient

But cannot figure out why.