Skip to content

Commit d632c76

Browse files
committed
Merge branch 'devel'
2 parents 7c1983f + 880a451 commit d632c76

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
NOTE: potentially breaking changes are flagged with a 🧨 symbol.
66

7+
## 3.2.1
8+
9+
### Fixed
10+
11+
- `pyppms.booking.PpmsBooking.endtime_fromstr()` contained a bug where the
12+
end time of a booking finishing at midnight got wrongly assigning it to the
13+
*start* of the given day instead of the end. This is now fixed by setting the
14+
end time to the start of the following day.
15+
716
## 3.2.0
817

918
### Added

src/pyppms/booking.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Module representing bookings / reservations in PPMS."""
22

3-
from datetime import datetime
3+
from datetime import datetime, timedelta
44

55
from loguru import logger as log
66

@@ -100,6 +100,7 @@ def from_runningsheet(cls, entry, system_id, username, date):
100100
)
101101
raise
102102

103+
log.trace(f"Created booking from runningsheet: {booking}")
103104
return booking
104105

105106
def starttime_fromstr(self, time_str, date=None):
@@ -143,6 +144,9 @@ def endtime_fromstr(self, time_str, date=None):
143144
second=0,
144145
microsecond=0,
145146
)
147+
if end.hour == 0 and end.minute == 0:
148+
end = end + timedelta(days=1)
149+
log.debug(f"Booking end is midnight, adjust date to {end}")
146150
self.endtime = end
147151
log.trace("New endtime: {}", self)
148152

src/pyppms/ppms.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class PpmsConnection:
4040
cache_users_only : bool
4141
Flag indicating that only PPMS user details will be stored in the
4242
on-disk cache, nothing else.
43-
last_served_from_cache
43+
last_served_from_cache : bool
4444
Indicates if the last request was served from the cache or on-line.
4545
users : dict
4646
A dict with usernames as keys, mapping to the related
@@ -171,7 +171,7 @@ def __authenticate(self):
171171
log.error(msg)
172172
raise requests.exceptions.ConnectionError(msg)
173173

174-
log.debug(
174+
log.trace(
175175
"Authentication succeeded, response=[{}], http_status=[{}]",
176176
response.text,
177177
response.status_code,
@@ -614,18 +614,18 @@ def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False
614614
full = entry["User"]
615615
if full not in self.fullname_mapping:
616616
if ignore_uncached_users:
617-
log.debug("Ignoring booking for uncached user [{}]", full)
617+
log.debug(f"Ignoring booking for uncached / unknown user [{full}]")
618618
continue
619619

620-
log.debug("Booking for an uncached user ({}) found!", full)
620+
log.debug(f"Booking refers an uncached user ({full}), updating users!")
621621
self.update_users()
622622

623623
if full not in self.fullname_mapping:
624624
log.error("PPMS doesn't seem to know user [{}], skipping", full)
625625
continue
626626

627627
log.trace(
628-
"Booking for user '{}' ({}) found", self.fullname_mapping[full], full
628+
f"Booking for user '{self.fullname_mapping[full]}' ({full}) found"
629629
)
630630
system_name = entry["Object"]
631631
system_ids = self.get_systems_matching("", [system_name])

0 commit comments

Comments
 (0)