Skip to content

Commit d6eee5e

Browse files
committed
Backup - update
build bat update
1 parent ed80465 commit d6eee5e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cd dls_barcode
66
REM use to debug the exe file
77
REM pyinstaller --onefile --icon=..\resources\icons\qr_code.ico --debug --clean main.py
88

9-
pyinstaller --onefile --windowed --icon="C:\Users\rqq82173\PycharmProjects\PuckBarcodeReader\resources\icons\qr_code.ico" --add-data "C:\Users\rqq82173\PycharmProjects\PuckBarcodeReader\resources; C:\Users\rqq82173\PycharmProjects\PuckBarcodeReader\bin" --clean "C:\Users\rqq82173\PycharmProjects\PuckBarcodeReader\dls_barcode\main.py"
9+
pyinstaller --onefile --windowed --icon="C:\Users\rqq82173\PycharmProjects\PuckBarcodeReader\resources\icons\qr_code.ico" --clean "C:\Users\rqq82173\PycharmProjects\PuckBarcodeReader\dls_barcode\main.py"
1010

1111
move dist\main.exe ..\bin\barcode.exe
1212
rd /S /Q build

dls_barcode/data_store/backup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ class Backup:
99
Backup class maintains the short time backaup of records which is kept in the same folder as the store files.
1010
"""
1111

12+
WEEK_IN_SECONDS = 604800
13+
1214
def __init__(self, comms_man, backup_time):
1315
self._comms = comms_man
1416
self._backup_time = backup_time.value()
1517
self._records = self._comms.load_records_from_file()
16-
self._truncate_record_list()
1718

1819
def _truncate_record_list(self):
19-
for record in self._records:
20-
if self._is_old(record):
21-
self._records.remove(record)
20+
self._records = list(filter(lambda x: not self._is_old(x), self._records))
2221

2322
def backup_records(self, to_back):
2423
self._records.extend(to_back)
@@ -29,6 +28,6 @@ def _is_old(self, record):
2928
tm = time.time()
3029
record_time = record.timestamp
3130
delta = tm - record_time
32-
weeks = self._backup_time * 604800 # weeks in seconds
31+
weeks = self._backup_time * self.WEEK_IN_SECONDS # weeks in seconds
3332
return delta > weeks
3433

0 commit comments

Comments
 (0)