pycupra 0.0.7__tar.gz → 0.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycupra
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: A library to read and send vehicle data via Cupra/Seat portal using the same API calls as the MyCupra/MySeat mobile app.
5
5
  Home-page: https://github.com/WulfgarW/pycupra
6
6
  Author: WulfgarW
@@ -3,4 +3,4 @@ pycupra - A Python 3 library for interacting with the My Cupra/My Seat portal.
3
3
 
4
4
  For more details and documentation, visit the github page at https://github.com/WulfgarW/pycupra
5
5
  """
6
- __version__ = "0.0.7"
6
+ __version__ = "0.0.8"
@@ -136,6 +136,10 @@ class Connection:
136
136
  _LOGGER.info(f'Init PyCupra library, version {lib_version}')
137
137
  _LOGGER.debug(f'Using service {self._session_base}')
138
138
 
139
+ self._sessionRequestCounter = 0
140
+ self._sessionRequestTimestamp = datetime.now(tz= None)
141
+ self._sessionRequestCounterHistory = {}
142
+
139
143
 
140
144
  def _clear_cookies(self):
141
145
  self._session._cookie_jar._cookies.clear()
@@ -604,6 +608,19 @@ class Connection:
604
608
  """Perform a HTTP query"""
605
609
  if self._session_fulldebug:
606
610
  _LOGGER.debug(f'HTTP {method} "{url}"')
611
+ try:
612
+ if datetime.now(tz=None).date() != self._sessionRequestTimestamp.date():
613
+ # A new day has begun. Store _sessionRequestCounter in history and reset timestamp and counter
614
+ self._sessionRequestCounterHistory[self._sessionRequestTimestamp.strftime('%Y-%m-%d')]=self._sessionRequestCounter
615
+ _LOGGER.info(f'History of the number of API calls:')
616
+ for key, value in self._sessionRequestCounterHistory.items:
617
+ _LOGGER.info(f' Date: {key}: {value} API calls')
618
+
619
+ self._sessionRequestTimestamp= datetime.now(tz=None)
620
+ self._sessionRequestCounter = 0
621
+ except Exception as e:
622
+ _LOGGER.error(f'Error while preparing output of API call history. Error: {e}')
623
+ self._sessionRequestCounter = self._sessionRequestCounter + 1
607
624
  async with self._session.request(
608
625
  method,
609
626
  url,
@@ -74,6 +74,9 @@ class Vehicle:
74
74
  'transactionHistoryHonkFlash': {'active': False, 'reason': 'not supported'},
75
75
  }
76
76
 
77
+ self._last_full_update = datetime.now(tz=None) - timedelta(seconds=1200)
78
+
79
+
77
80
  #### API get and set functions ####
78
81
  # Init and update vehicle data
79
82
  async def discover(self):
@@ -132,7 +135,7 @@ class Vehicle:
132
135
  return_exceptions=True
133
136
  )
134
137
 
135
- fullUpdateExpired = datetime.now(timezone.utc) - timedelta(seconds= 1100)
138
+ fullUpdateExpired = datetime.now(tz=None) - timedelta(seconds= 1100)
136
139
  if hasattr(self, '_last_full_update'):
137
140
  _LOGGER.debug(f'last_full_update= {self._last_full_update}, fullUpdateExpired= {fullUpdateExpired}.')
138
141
  if updateType!=1 and (hasattr(self, '_last_full_update') and self._last_full_update>fullUpdateExpired):
@@ -153,8 +156,9 @@ class Vehicle:
153
156
  #self.get_modelimageurl(), #commented out, because getting the images discover() should be sufficient
154
157
  return_exceptions=True
155
158
  )
156
- self._last_full_update = datetime.now(timezone.utc)
159
+ self._last_full_update = datetime.now(tz=None)
157
160
  _LOGGER.debug(f'Performed full update for vehicle with VIN {self.vin}.')
161
+ _LOGGER.debug(f'So far about {self._connection._sessionRequestCounter} API calls since {self._connection._sessionRequestTimestamp}.')
158
162
  except:
159
163
  raise SeatException("Update failed")
160
164
  return True
@@ -1259,7 +1263,8 @@ class Vehicle:
1259
1263
  @property
1260
1264
  def is_last_full_update_supported(self):
1261
1265
  """Return when last full update for vehicle took place."""
1262
- return True
1266
+ if hasattr(self,'_last_full_update'):
1267
+ return True
1263
1268
 
1264
1269
  # Service information
1265
1270
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycupra
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: A library to read and send vehicle data via Cupra/Seat portal using the same API calls as the MyCupra/MySeat mobile app.
5
5
  Home-page: https://github.com/WulfgarW/pycupra
6
6
  Author: WulfgarW
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes