Changeset 9af0638 for src/common/gnuboat_common/datahandler/loghandler.py
- Timestamp:
- Feb 2, 2020, 5:30:22 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- ec9e811
- Parents:
- 75f09e4
- git-author:
- Joachim Langenbach <joachim.langenbach@…> (02/02/20 12:49:19)
- git-committer:
- Joachim Langenbach <joachim.langenbach@…> (02/02/20 17:30:22)
- File:
-
- 1 moved
-
src/common/gnuboat_common/datahandler/loghandler.py (moved) (moved from src/gnuboat/gnuboat/datahandler/loghandler.py ) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/common/gnuboat_common/datahandler/loghandler.py
r75f09e4 r9af0638 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2016 - 20 18EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.3 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 25 25 import math 26 26 27 from gnuboat.datahandler import logdataset 27 from gnuboat_common.datahandler import logdataset 28 29 class LogParsingResult: 30 def __init__(self): 31 self._success = False 32 self._errors = [] 33 34 def error_add(self, error): 35 self._errors.append(error) 36 37 def errors(self): 38 return self._errors 39 40 def messages(self): 41 if len(self._errors) > 0: 42 return True 43 return False 44 45 def succeeded(self, status): 46 self._success = status 47 48 def success(self): 49 return self._success 28 50 29 51 """@class LogHandler … … 107 129 callback must be of a function wich excepts the LogDataset as a parameter. 108 130 """ 109 def gnuboat_read(self, input_file_path, callback, checksums_fix = False, errors_ignore = False): 131 def gnuboat_read_file(self, input_file_path, callback, checksums_fix = False, errors_ignore = False): 132 result = LogParsingResult() 133 110 134 # reading input file 111 135 try: 112 136 input_file = open(input_file_path, 'r') 113 137 except IOError as error: 114 print('ERROR: Could not open the input file: {}'.format(error)) 115 return False 138 result.error_add('ERROR: Could not open the input file: {}'.format(error)) 139 result.succeeded(False) 140 return result 141 result = self.gnuboat_read(input_file, callback, checksums_fix, errors_ignore = False) 142 input_file.close() 143 return result 144 145 """ Reads the original gnuboat log from input_list and calls a callable function on all complete LogDataset 146 callback must be of a function wich excepts the LogDataset as a parameter. 147 """ 148 def gnuboat_read(self, input_list, callback, checksums_fix = False, errors_ignore = False): 149 result = LogParsingResult() 150 116 151 current_row = 1 117 152 last_row = None 118 for line in input_ file:153 for line in input_list: 119 154 nmea_sentence = self.parse_nmea_sentence(line, checksums_fix) 120 155 if nmea_sentence is None: 121 print('INFO: Failed to parse nmea sentence ({}) at line {}'.format(line.strip(), current_row))156 result.error_add('INFO: Failed to parse nmea sentence ({}) at line {}'.format(line.strip(), current_row)) 122 157 if not errors_ignore: 123 input_file.close()124 return False158 result.succeeded(False) 159 return result 125 160 else: 126 161 nmea_sentence = nmea_sentence['nmea_sentence'] … … 146 181 if last_row is not None: 147 182 callback(last_row) 148 input_file.close()149 return True183 result.succeeded(True) 184 return result 150 185 151 186 def _to_float(self, string, current_row):
Note:
See TracChangeset
for help on using the changeset viewer.
