def connect(self): if self.qb is not None: self.qb.logout() url = clean_host(self.conf('host'), protocol=True, ssl=False) if self.conf('username') and self.conf('password'): self.qb = Client(url) self.qb.login(username=self.conf('username'), password=self.conf('password')) else: self.qb = Client(url) return self.qb._is_authenticated
def setup_platform( hass: HomeAssistant, config: ConfigType, add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the qBittorrent sensors.""" try: client = Client(config[CONF_URL]) client.login(config[CONF_USERNAME], config[CONF_PASSWORD]) except LoginRequired: _LOGGER.error("Invalid authentication") return except RequestException as err: _LOGGER.error("Connection failed") raise PlatformNotReady from err name = config.get(CONF_NAME) entities = [ QBittorrentSensor(description, client, name, LoginRequired) for description in SENSOR_TYPES ] add_entities(entities, True)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the qBittorrent sensors.""" from qbittorrent.client import Client, LoginRequired try: client = Client(config[CONF_URL]) client.login(config[CONF_USERNAME], config[CONF_PASSWORD]) except LoginRequired: _LOGGER.error("Invalid authentication") return except RequestException: _LOGGER.error("Connection failed") raise PlatformNotReady name = config.get(CONF_NAME) dev = [] for sensor_type in SENSOR_TYPES: sensor = QBittorrentSensor(sensor_type, client, name, LoginRequired) dev.append(sensor) async_add_entities(dev, True)
def __init__(self, hass, config): try: self.client = Client(config[CONF_URL]) self.client.login(config[CONF_USERNAME], config[CONF_PASSWORD]) except LoginRequired: _LOGGER.error("Invalid authentication") return except RequestException: _LOGGER.error("Connection failed") raise PlatformNotReady self.sensors = [] self.name = config.get(CONF_NAME) for sensor_type in SENSOR_TYPES: sensor = QBittorrentSensor(sensor_type, self.client, self.name, LoginRequired) self.sensors.append(sensor)
url = sys.argv[0] + "?mode=%s" % folder xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), cacheToDisc=False) username = __settings__.getSetting('username') password = __settings__.getSetting('password') url = __settings__.getSetting('url') qb = Client(url=url) qb.login(username, password) for arg in sys.argv: xbmc.log('arg: %s' % arg) params = get_params() for param in params: xbmc.log('param: %s' % param) mode = 0 try: mode = params['mode'] except: