diff --git a/core/controllers/ApplicationVersionController.py b/core/controllers/ApplicationVersionController.py index 7e4873b..1664722 100644 --- a/core/controllers/ApplicationVersionController.py +++ b/core/controllers/ApplicationVersionController.py @@ -29,7 +29,7 @@ class ApplicationVersionController: if not application_version.is_supported(): raise UnsupportedApplicationVersionError('The application version in question is not supported.') - if reinstall is True: + if reinstall: ApplicationVersionController.uninstall(application_version) if application_version.is_installed(): diff --git a/core/controllers/ClientController.py b/core/controllers/ClientController.py index 202f31a..97e216a 100644 --- a/core/controllers/ClientController.py +++ b/core/controllers/ClientController.py @@ -6,7 +6,7 @@ from core.controllers.ClientVersionController import ClientVersionController from core.controllers.ConfigurationController import ConfigurationController from core.controllers.LocationController import LocationController from core.controllers.SubscriptionPlanController import SubscriptionPlanController -from core.observers import ClientObserver +from core.observers.ClientObserver import ClientObserver from core.observers.ConnectionObserver import ConnectionObserver from typing import Optional import os diff --git a/core/controllers/ConnectionController.py b/core/controllers/ConnectionController.py index cb73391..92bda63 100644 --- a/core/controllers/ConnectionController.py +++ b/core/controllers/ConnectionController.py @@ -1,3 +1,4 @@ +from collections.abc import Callable from core.Constants import Constants from core.Errors import InvalidSubscriptionError, MissingSubscriptionError, ConnectionUnprotectedError, ConnectionTerminationError, CommandNotFoundError from core.controllers.ConfigurationController import ConfigurationController @@ -10,7 +11,7 @@ from core.models.system.SystemState import SystemState from core.observers import ConnectionObserver from core.services.WebServiceApiService import WebServiceApiService from pathlib import Path -from typing import Union, Optional +from typing import Union, Optional, Any import os import re import requests @@ -24,7 +25,7 @@ import time class ConnectionController: @staticmethod - def with_preferred_connection(*args, task: callable, connection_observer: Optional[ConnectionObserver] = None, **kwargs): + def with_preferred_connection(*args, task: Callable[..., Any], connection_observer: Optional[ConnectionObserver] = None, **kwargs): connection = ConfigurationController.get_connection() @@ -34,6 +35,9 @@ class ConnectionController: elif connection == 'tor': return ConnectionController.__with_tor_connection(*args, task=task, connection_observer=connection_observer, **kwargs) + else: + return None + @staticmethod def establish_connection(profile: Union[SessionProfile, SystemProfile], force: bool = False, connection_observer: Optional[ConnectionObserver] = None): @@ -110,6 +114,8 @@ class ConnectionController: else: raise ConnectionError('The connection could not be established.') + return None + @staticmethod def establish_session_connection(profile: SessionProfile, force: Optional[bool] = False, connection_observer: Optional[ConnectionObserver] = None): @@ -360,7 +366,7 @@ class ConnectionController: network_interface_is_activated = ConnectionController.system_uses_wireguard_interface() attempt += 1 - if network_interface_is_activated is False: + if not network_interface_is_activated: raise ConnectionError('The network interface could not be activated.') @staticmethod @@ -375,7 +381,7 @@ class ConnectionController: return bool(re.search('dev wg', str(process_output))) @staticmethod - def __with_tor_connection(*args, task: callable, connection_observer: Optional[ConnectionObserver] = None, **kwargs): + def __with_tor_connection(*args, task: Callable[..., Any], connection_observer: Optional[ConnectionObserver] = None, **kwargs): session_directory = tempfile.mkdtemp(prefix='hv-') port_number = ConnectionController.get_random_available_port_number() diff --git a/core/models/invoice/Invoice.py b/core/models/invoice/Invoice.py index 111a729..d15cf21 100644 --- a/core/models/invoice/Invoice.py +++ b/core/models/invoice/Invoice.py @@ -1,4 +1,4 @@ -from core.models.invoice import PaymentMethod +from core.models.invoice.PaymentMethod import PaymentMethod from dataclasses import dataclass from datetime import datetime diff --git a/core/services/WebServiceApiService.py b/core/services/WebServiceApiService.py index 92d0349..a0903c4 100644 --- a/core/services/WebServiceApiService.py +++ b/core/services/WebServiceApiService.py @@ -86,6 +86,9 @@ class WebServiceApiService: if response.status_code == requests.codes.created: return Subscription(response.headers['X-Billing-Code']) + else: + return None + @staticmethod def get_subscription(billing_code: str, proxies: Optional[dict] = None): @@ -100,6 +103,9 @@ class WebServiceApiService: subscription = response.json()['data'] return Subscription(billing_code, Subscription.from_iso_format(subscription['expires_at'])) + else: + return None + @staticmethod def get_invoice(billing_code: str, proxies: Optional[dict] = None): @@ -121,6 +127,9 @@ class WebServiceApiService: return Invoice(billing_code, invoice['status'], invoice['expires_at'], tuple[PaymentMethod](payment_methods)) + else: + return None + @staticmethod def get_proxy_configuration(billing_code: str, proxies: Optional[dict] = None):