Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed tests/data/sample-database-2016-04.wlk.bz2
Binary file not shown.
15 changes: 9 additions & 6 deletions weatherlink/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ def _process_download(self, download_response_handle):
self.records = []

for i in range(0, self.record_count):
record = ArchiveIntervalRecord.load_from_download(download_response_handle, self.record_minute_span)
if not record:
print('WARN: Halted at record %s because false-y' % i)
break

self.records.append(record)
try:
record = ArchiveIntervalRecord.load_from_download(download_response_handle, self.record_minute_span)
if not record:
print('WARN: Halted at record %s because false-y' % i)
break

self.records.append(record)
except AssertionError:
continue
25 changes: 14 additions & 11 deletions weatherlink/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ def import_data(self):
for day, day_index in enumerate(self.header.day_indexes):
if day > 0:
for r in range(0, day_index.record_count - 1):
if r == 0:
self.daily_summaries[day] = DailySummary.load_from_wlk(
file_handle,
self.year,
self.month,
day,
)
else:
record = ArchiveIntervalRecord.load_from_wlk(file_handle, self.year, self.month, day)
self.records.append(record)
self.daily_records[day].append(record)
try: # Added so as to filled though errors
if r == 0:
self.daily_summaries[day] = DailySummary.load_from_wlk(
file_handle,
self.year,
self.month,
day,
)
else:
record = ArchiveIntervalRecord.load_from_wlk(file_handle, self.year, self.month, day)
self.records.append(record)
self.daily_records[day].append(record)
except AssertionError:
continue
3 changes: 3 additions & 0 deletions weatherlink/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class WindDirection(enum.Enum):
WNW = 13
NW = 14
NNW = 15
NONE = -9999

def __init__(self, value):
self.degrees = value * 22.5
Expand Down Expand Up @@ -452,6 +453,8 @@ def load_from_wlk(cls, file_handle, year, month, day):
for i, v in enumerate(arguments):
if i not in cls.RECORD_VERIFICATION_MAP_WLK and i not in cls.RECORD_SPECIAL_HANDLING_WLK:
k = cls.RECORD_ATTRIBUTE_MAP_WLK[i][0]
if 'wind' in k.lower() and v < 0:
v = -9999
if v == cls.RECORD_ATTRIBUTE_MAP_WLK[i][2]:
kwargs[k] = None
else:
Expand Down