Skip to content

Commit

Permalink
still fighting with inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Dec 31, 2024
1 parent 5ef0a85 commit aa0cd44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
19 changes: 12 additions & 7 deletions src/carconnectivity_connectors/skoda/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,19 @@ def __init__(self, car_connectivity: CarConnectivity, config: Dict) -> None:
raise AuthenticationError(f'Authentication using {netrc_filename} failed: {err}') from err
except TypeError as err:
if 'username' not in self.config:
raise AuthenticationError(f'skoda entry was not found in {netrc_filename} netrc-file.'
raise AuthenticationError(f'"skoda" entry was not found in {netrc_filename} netrc-file.'
' Create it or provide username and password in config') from err
except FileNotFoundError as err:
raise AuthenticationError(f'{netrc_filename} netrc-file was not found. Create it or provide username and password in config') from err

self.max_age: int = 300
if 'max_age' in self.config:
self.max_age = self.config['max_age']

self.intervall: int = 300
if 'interval' in self.config:
self.intervall = self.config['interval']
if self.intervall < 180:
raise ValueError('Intervall must be at least 180 seconds')
if self.intervall < 300:
raise ValueError('Intervall must be at least 300 seconds')
self.max_age: int = self.intervall - 1
if 'max_age' in self.config:
self.max_age = self.config['max_age']

if username is None or password is None:
raise AuthenticationError('Username or password not provided')
Expand Down Expand Up @@ -170,6 +169,11 @@ def fetch_vehicles(self) -> None:
vehicle.license_plate._set_value(vehicle_dict['licensePlate']) # pylint: disable=protected-access
else:
vehicle.license_plate._set_value(None) # pylint: disable=protected-access

if 'softwareVersion' in vehicle_dict and vehicle_dict['softwareVersion'] is not None:
vehicle.software.version._set_value(vehicle_dict['softwareVersion']) # pylint: disable=protected-access
else:
vehicle.software.version._set_value(None) # pylint: disable=protected-access

if 'capabilities' in vehicle_dict and vehicle_dict['capabilities'] is not None:
if 'capabilities' in vehicle_dict['capabilities'] and vehicle_dict['capabilities']['capabilities'] is not None:
Expand Down Expand Up @@ -222,6 +226,7 @@ def fetch_vehicle_status(self, vehicle: GenericVehicle) -> None:
vin = vehicle.vin.value
url = f'https://api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}'
data: Dict[str, Any] | None = self._fetch_data(url, self._session2)
print(data)
if data is not None and 'remote' in data and data['remote'] is not None:
remote = data['remote']
if 'capturedAt' in remote and remote['capturedAt'] is not None:
Expand Down
18 changes: 6 additions & 12 deletions src/carconnectivity_connectors/skoda/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ class SkodaElectricVehicle(ElectricVehicle, SkodaVehicle):
def __init__(self, vin: Optional[str] = None, garage: Optional[Garage] = None, managing_connector: Optional[BaseConnector] = None,
origin: Optional[SkodaVehicle] = None) -> None:
if origin is not None:
ElectricVehicle.__init__(self, origin=origin)
SkodaVehicle.__init__(self, origin=origin)
super().__init__(origin=origin)
else:
ElectricVehicle.__init__(self, vin=vin, garage=garage, managing_connector=managing_connector)
SkodaVehicle.__init__(self, vin=vin, garage=garage, managing_connector=managing_connector)
super().__init__(vin=vin, garage=garage, managing_connector=managing_connector)


class SkodaCombustionVehicle(CombustionVehicle, SkodaVehicle):
Expand All @@ -52,11 +50,9 @@ class SkodaCombustionVehicle(CombustionVehicle, SkodaVehicle):
def __init__(self, vin: Optional[str] = None, garage: Optional[Garage] = None, managing_connector: Optional[BaseConnector] = None,
origin: Optional[SkodaVehicle] = None) -> None:
if origin is not None:
CombustionVehicle.__init__(self, origin=origin)
SkodaVehicle.__init__(self, origin=origin)
super().__init__(origin=origin)
else:
CombustionVehicle.__init__(self, vin=vin, garage=garage, managing_connector=managing_connector)
SkodaVehicle.__init__(self, vin=vin, garage=garage, managing_connector=managing_connector)
super().__init__(vin=vin, garage=garage, managing_connector=managing_connector)


class SkodaHybridVehicle(HybridVehicle, SkodaVehicle):
Expand All @@ -66,8 +62,6 @@ class SkodaHybridVehicle(HybridVehicle, SkodaVehicle):
def __init__(self, vin: Optional[str] = None, garage: Optional[Garage] = None, managing_connector: Optional[BaseConnector] = None,
origin: Optional[SkodaVehicle] = None) -> None:
if origin is not None:
HybridVehicle.__init__(self, origin=origin)
SkodaVehicle.__init__(self, origin=origin)
super().__init__(origin=origin)
else:
HybridVehicle.__init__(self, vin=vin, garage=garage, managing_connector=managing_connector)
SkodaVehicle.__init__(self, vin=vin, garage=garage, managing_connector=managing_connector)
super().__init__(vin=vin, garage=garage, managing_connector=managing_connector)

0 comments on commit aa0cd44

Please sign in to comment.