Skip to content

Commit 227ac40

Browse files
author
Stéphane Senart
committed
[#65] PermissionError happens when loading data from Excel file
1 parent baab6d5 commit 227ac40

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.2.2](https://github.com/ssenart/PyGazpar/compare/1.2.1...1.2.2) - 2024-05-08
8+
9+
### Fixed
10+
- [#65](https://github.com/ssenart/PyGazpar/issues/65): [Bug] PermissionError happens when loading data from Excel file.
711

812
## [1.2.1](https://github.com/ssenart/PyGazpar/compare/1.2.0...1.2.1) - 2024-05-04
913

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# PyGazpar
22

3-
## $\text{\color{red}{!!! This library is broken since CAPTCHA is mandatory on GrDF site !!!}}$
3+
## <span style="color:green">!!! This library is working again. CAPTCHA has been removed !!!</span>
4+
5+
## <span style="color:red">~~!!! This library is broken since CAPTCHA is mandatory on GrDF site !!!~~</span>
46

57
PyGazpar is a Python library for getting natural gas consumption from GrDF French provider.
68

pygazpar/datasource.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date,
144144
file_list = glob.glob(data_file_path_pattern)
145145
for filename in file_list:
146146
if os.path.isfile(filename):
147-
os.remove(filename)
147+
try:
148+
os.remove(filename)
149+
except PermissionError:
150+
pass
148151

149152
if frequencies is None:
150153
# Transform Enum in List.
@@ -194,7 +197,7 @@ def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date,
194197
try:
195198
# openpyxl does not close the file properly.
196199
os.remove(filename)
197-
except Exception:
200+
except PermissionError:
198201
pass
199202

200203
# We compute yearly from daily data.

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_monthly_jsonweb(self):
7272

7373
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.MONTHLY])
7474

75-
assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13)
75+
assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13)
7676

7777
def test_yearly_jsonweb(self):
7878
client = Client(JsonWebDataSource(self.__username, self.__password))

tests/test_datasource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_jsonweb(self):
143143

144144
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
145145

146-
assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13)
146+
assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13)
147147

148148
assert (len(data[Frequency.YEARLY.value]) == 1)
149149

0 commit comments

Comments
 (0)