Compare commits

..

No commits in common. "8c8892bbd41526a462a3ff1a80855a2714a8d76b" and "41988fc491741bb7254d0ec92062d1acc1686c37" have entirely different histories.

6 changed files with 10 additions and 30 deletions

View file

@ -29,7 +29,7 @@ class ApplicationVersionController:
if not application_version.is_supported():
raise UnsupportedApplicationVersionError('The application version in question is not supported.')
if reinstall:
if reinstall is True:
ApplicationVersionController.uninstall(application_version)
if application_version.is_installed():

View file

@ -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.ClientObserver import ClientObserver
from core.observers import ClientObserver
from core.observers.ConnectionObserver import ConnectionObserver
from typing import Optional
import os

View file

@ -1,4 +1,3 @@
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
@ -11,7 +10,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, Any
from typing import Union, Optional
import os
import re
import requests
@ -25,7 +24,7 @@ import time
class ConnectionController:
@staticmethod
def with_preferred_connection(*args, task: Callable[..., Any], connection_observer: Optional[ConnectionObserver] = None, **kwargs):
def with_preferred_connection(*args, task: callable, connection_observer: Optional[ConnectionObserver] = None, **kwargs):
connection = ConfigurationController.get_connection()
@ -35,9 +34,6 @@ 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):
@ -114,8 +110,6 @@ 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):
@ -366,7 +360,7 @@ class ConnectionController:
network_interface_is_activated = ConnectionController.system_uses_wireguard_interface()
attempt += 1
if not network_interface_is_activated:
if network_interface_is_activated is False:
raise ConnectionError('The network interface could not be activated.')
@staticmethod
@ -381,7 +375,7 @@ class ConnectionController:
return bool(re.search('dev wg', str(process_output)))
@staticmethod
def __with_tor_connection(*args, task: Callable[..., Any], connection_observer: Optional[ConnectionObserver] = None, **kwargs):
def __with_tor_connection(*args, task: callable, connection_observer: Optional[ConnectionObserver] = None, **kwargs):
session_directory = tempfile.mkdtemp(prefix='hv-')
port_number = ConnectionController.get_random_available_port_number()

View file

@ -12,7 +12,6 @@ _table_definition: str = """
'code' varchar,
'name' varchar,
'time_zone' varchar,
'provider_name' varchar,
UNIQUE(code, country_code)
"""
@ -34,10 +33,6 @@ class Location(Model):
metadata=config(exclude=Exclude.ALWAYS)
)
time_zone: Optional[str] = None
provider_name: Optional[str] = field(
default=None,
metadata=config(exclude=Exclude.ALWAYS)
)
available: Optional[bool] = field(
default=False,
metadata=config(exclude=Exclude.ALWAYS)
@ -76,7 +71,7 @@ class Location(Model):
@staticmethod
def save_many(locations):
Model._create_table_if_not_exists(table_name=_table_name, table_definition=_table_definition)
Model._insert_many('INSERT INTO locations VALUES(?, ?, ?, ?, ?, ?, ?)', Location.tuple_factory, locations)
Model._insert_many('INSERT INTO locations VALUES(?, ?, ?, ?, ?, ?)', Location.tuple_factory, locations)
@staticmethod
def factory(cursor, row):
@ -85,4 +80,4 @@ class Location(Model):
@staticmethod
def tuple_factory(location):
return location.id, location.country_code, location.country_name, location.code, location.name, location.time_zone, location.provider_name
return location.id, location.country_code, location.country_name, location.code, location.name, location.time_zone

View file

@ -1,4 +1,4 @@
from core.models.invoice.PaymentMethod import PaymentMethod
from core.models.invoice import PaymentMethod
from dataclasses import dataclass
from datetime import datetime

View file

@ -59,7 +59,7 @@ class WebServiceApiService:
if response.status_code == requests.codes.ok:
for location in response.json()['data']:
locations.append(Location(location['country']['code'], location['code'], location['id'], location['country']['name'], location['name'], location['time_zone']['code'], location['provider']['name']))
locations.append(Location(location['country']['code'], location['code'], location['id'], location['country']['name'], location['name'], location['time_zone']['code']))
return locations
@ -86,9 +86,6 @@ 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):
@ -103,9 +100,6 @@ 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):
@ -127,9 +121,6 @@ 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):