Skip to content

Commit c9b4a1b

Browse files
authored
Merge pull request #1136 from BCDA-APS/UnboundLocalError--cannot-access-local-variable-'dt_cycle_ends'
MNT Only use when available
2 parents 8bc4dc6 + 7578528 commit c9b4a1b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGES.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ describe future plans.
2424
1.7.10
2525
******
2626
27-
Release expected by 2026-01.
27+
Release expected by 2025-12-05.
28+
29+
Fixes
30+
-------------
31+
32+
* BUG 'dt_cycle_ends' in apstools.devices.aps_cycle.ApsCycleDM
2833

2934
1.7.9
3035
*****

apstools/devices/aps_cycle.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,20 @@ def get(self):
161161
if now.month < 5:
162162
cycle = f"{now.year}-1"
163163
dt_cycle_ends = f"{now.year}-05-01 00:00:00-05:00"
164-
if now.month < 9:
164+
elif now.month < 9:
165165
cycle = f"{now.year}-2"
166166
dt_cycle_ends = f"{now.year}-10-01 00:00:00-05:00"
167167
else:
168168
cycle = f"{now.year}-3"
169169
dt_cycle_ends = f"{now.year+1}-01-01 00:00:00-06:00"
170+
self._cycle_ends = dt_cycle_ends
171+
170172
else: # official table from APS (via DM)
171173
if now.isoformat(sep=" ") >= self._cycle_ends:
172174
ts_cycle_end = cycle_db.db[cycle]["end"]
173175
dt_cycle_ends = datetime.datetime.fromtimestamp(ts_cycle_end).isoformat(sep=" ")
176+
self._cycle_ends = dt_cycle_ends
174177

175-
self._cycle_ends = dt_cycle_ends
176178
self._cycle_name = cycle
177179
return self._cycle_name
178180

0 commit comments

Comments
 (0)