pygazpar 1.2.5__tar.gz → 1.2.6__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. {pygazpar-1.2.5/pygazpar.egg-info → pygazpar-1.2.6}/PKG-INFO +6 -1
  2. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/datasource.py +13 -29
  3. pygazpar-1.2.6/pygazpar/version.py +1 -0
  4. {pygazpar-1.2.5 → pygazpar-1.2.6/pygazpar.egg-info}/PKG-INFO +6 -1
  5. pygazpar-1.2.5/pygazpar/version.py +0 -1
  6. {pygazpar-1.2.5 → pygazpar-1.2.6}/LICENSE.md +0 -0
  7. {pygazpar-1.2.5 → pygazpar-1.2.6}/MANIFEST.in +0 -0
  8. {pygazpar-1.2.5 → pygazpar-1.2.6}/README.md +0 -0
  9. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/__init__.py +0 -0
  10. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/__main__.py +0 -0
  11. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/client.py +0 -0
  12. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/enum.py +0 -0
  13. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/excelparser.py +0 -0
  14. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/jsonparser.py +0 -0
  15. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/resources/daily_data_sample.json +0 -0
  16. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/resources/hourly_data_sample.json +0 -0
  17. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/resources/monthly_data_sample.json +0 -0
  18. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/resources/weekly_data_sample.json +0 -0
  19. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar/resources/yearly_data_sample.json +0 -0
  20. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar.egg-info/SOURCES.txt +0 -0
  21. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar.egg-info/dependency_links.txt +0 -0
  22. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar.egg-info/entry_points.txt +0 -0
  23. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar.egg-info/not-zip-safe +0 -0
  24. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar.egg-info/requires.txt +0 -0
  25. {pygazpar-1.2.5 → pygazpar-1.2.6}/pygazpar.egg-info/top_level.txt +0 -0
  26. {pygazpar-1.2.5 → pygazpar-1.2.6}/samples/__init__.py +0 -0
  27. {pygazpar-1.2.5 → pygazpar-1.2.6}/samples/excelSample.py +0 -0
  28. {pygazpar-1.2.5 → pygazpar-1.2.6}/samples/jsonSample.py +0 -0
  29. {pygazpar-1.2.5 → pygazpar-1.2.6}/samples/testSample.py +0 -0
  30. {pygazpar-1.2.5 → pygazpar-1.2.6}/setup.cfg +0 -0
  31. {pygazpar-1.2.5 → pygazpar-1.2.6}/setup.py +0 -0
  32. {pygazpar-1.2.5 → pygazpar-1.2.6}/tests/__init__.py +0 -0
  33. {pygazpar-1.2.5 → pygazpar-1.2.6}/tests/test_client.py +0 -0
  34. {pygazpar-1.2.5 → pygazpar-1.2.6}/tests/test_datafileparser.py +0 -0
  35. {pygazpar-1.2.5 → pygazpar-1.2.6}/tests/test_datasource.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pygazpar
3
- Version: 1.2.5
3
+ Version: 1.2.6
4
4
  Summary: Retrieve gas consumption from GrDF web site (French Gas Company)
5
5
  Home-page: https://github.com/ssenart/pygazpar
6
6
  Author: Stephane Senart
@@ -215,6 +215,11 @@ All notable changes to this project will be documented in this file.
215
215
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
216
216
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
217
217
 
218
+ ## [1.2.6](https://github.com/ssenart/PyGazpar/compare/1.2.6...1.2.5) - 2025-01-03
219
+
220
+ ### Fixed
221
+ - [#77](https://github.com/ssenart/PyGazpar/issues/77): Some error may occur while requesting data from GrDF API.
222
+
218
223
  ## [1.2.5](https://github.com/ssenart/PyGazpar/compare/1.2.5...1.2.4) - 2024-12-21
219
224
 
220
225
  ### Fixed
@@ -59,9 +59,9 @@ class WebDataSource(IDataSource):
59
59
  # ------------------------------------------------------
60
60
  def load(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
61
61
 
62
- auth_token = self._login(self.__username, self.__password)
62
+ self._login(self.__username, self.__password) # We ignore the return value.
63
63
 
64
- res = self._loadFromSession(auth_token, pceIdentifier, startDate, endDate, frequencies)
64
+ res = self._loadFromSession(pceIdentifier, startDate, endDate, frequencies)
65
65
 
66
66
  Logger.debug("The data update terminates normally")
67
67
 
@@ -88,23 +88,23 @@ class WebDataSource(IDataSource):
88
88
 
89
89
  jar = http.cookiejar.CookieJar()
90
90
 
91
- session = Session()
92
- session.headers.update({"Content-Type": "application/json"})
93
- session.headers.update({"X-Requested-With": "XMLHttpRequest"})
91
+ self._session = Session()
92
+ self._session.headers.update({"Content-Type": "application/json"})
93
+ self._session.headers.update({"X-Requested-With": "XMLHttpRequest"})
94
94
 
95
95
  params = json.loads(AUTH_TOKEN_PARAMS.format(session_token))
96
96
 
97
- response = session.get(AUTH_TOKEN_URL, params=params, allow_redirects=True, cookies=jar) # type: ignore
97
+ response = self._session.get(AUTH_TOKEN_URL, params=params, allow_redirects=True, cookies=jar) # type: ignore
98
98
 
99
99
  if response.status_code != 200:
100
100
  raise Exception(f"An error occurred while getting the auth token. Status code: {response.status_code} - {response.text}")
101
101
 
102
- auth_token = session.cookies.get("auth_token", domain="monespace.grdf.fr")
102
+ auth_token = self._session.cookies.get("auth_token", domain="monespace.grdf.fr")
103
103
 
104
104
  return auth_token # type: ignore
105
105
 
106
106
  @abstractmethod
107
- def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
107
+ def _loadFromSession(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
108
108
  pass
109
109
 
110
110
 
@@ -133,7 +133,7 @@ class ExcelWebDataSource(WebDataSource):
133
133
  self.__tmpDirectory = tmpDirectory
134
134
 
135
135
  # ------------------------------------------------------
136
- def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
136
+ def _loadFromSession(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
137
137
 
138
138
  res = {}
139
139
 
@@ -166,16 +166,8 @@ class ExcelWebDataSource(WebDataSource):
166
166
  retry = 10
167
167
  while retry > 0:
168
168
 
169
- # Create a session.
170
- session = Session()
171
- session.headers.update({"Host": "monespace.grdf.fr"})
172
- session.headers.update({"Domain": "grdf.fr"})
173
- session.headers.update({"X-Requested-With": "XMLHttpRequest"})
174
- session.headers.update({"Accept": "application/json"})
175
- session.cookies.set("auth_token", auth_token, domain="monespace.grdf.fr")
176
-
177
169
  try:
178
- self.__downloadFile(session, downloadUrl, self.__tmpDirectory)
170
+ self.__downloadFile(self._session, downloadUrl, self.__tmpDirectory)
179
171
  break
180
172
  except Exception as e:
181
173
 
@@ -267,7 +259,7 @@ class JsonWebDataSource(WebDataSource):
267
259
 
268
260
  super().__init__(username, password)
269
261
 
270
- def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
262
+ def _loadFromSession(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
271
263
 
272
264
  res = {}
273
265
 
@@ -286,16 +278,8 @@ class JsonWebDataSource(WebDataSource):
286
278
  retry = 10
287
279
  while retry > 0:
288
280
 
289
- # Create a session.
290
- session = Session()
291
- session.headers.update({"Host": "monespace.grdf.fr"})
292
- session.headers.update({"Domain": "grdf.fr"})
293
- session.headers.update({"X-Requested-With": "XMLHttpRequest"})
294
- session.headers.update({"Accept": "application/json"})
295
- session.cookies.set("auth_token", auth_token, domain="monespace.grdf.fr")
296
-
297
281
  try:
298
- response = session.get(downloadUrl)
282
+ response = self._session.get(downloadUrl)
299
283
 
300
284
  if "text/html" in response.headers.get("Content-Type"): # type: ignore
301
285
  raise Exception("An error occurred while loading data. Please check your credentials.")
@@ -321,7 +305,7 @@ class JsonWebDataSource(WebDataSource):
321
305
  temperaturesUrl = JsonWebDataSource.TEMPERATURES_URL.format(pceIdentifier, endDate.strftime(JsonWebDataSource.INPUT_DATE_FORMAT), days)
322
306
 
323
307
  # Get weather data.
324
- temperatures = session.get(temperaturesUrl).text
308
+ temperatures = self._session.get(temperaturesUrl).text
325
309
 
326
310
  # Transform all the data into the target structure.
327
311
  daily = JsonParser.parse(data, temperatures, pceIdentifier)
@@ -0,0 +1 @@
1
+ __version__ = "1.2.6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pygazpar
3
- Version: 1.2.5
3
+ Version: 1.2.6
4
4
  Summary: Retrieve gas consumption from GrDF web site (French Gas Company)
5
5
  Home-page: https://github.com/ssenart/pygazpar
6
6
  Author: Stephane Senart
@@ -215,6 +215,11 @@ All notable changes to this project will be documented in this file.
215
215
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
216
216
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
217
217
 
218
+ ## [1.2.6](https://github.com/ssenart/PyGazpar/compare/1.2.6...1.2.5) - 2025-01-03
219
+
220
+ ### Fixed
221
+ - [#77](https://github.com/ssenart/PyGazpar/issues/77): Some error may occur while requesting data from GrDF API.
222
+
218
223
  ## [1.2.5](https://github.com/ssenart/PyGazpar/compare/1.2.5...1.2.4) - 2024-12-21
219
224
 
220
225
  ### Fixed
@@ -1 +0,0 @@
1
- __version__ = "1.2.5"
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
File without changes
File without changes