Changeset b45e75d for src/python/bin/gnuboat-log-converter
- Timestamp:
- Sep 21, 2017, 3:17:50 PM (9 years ago)
- Branches:
- 0.5, debian/bullseye, debian/jessie, master
- Children:
- f29f4d3
- Parents:
- 3145648
- git-author:
- Joachim Langenbach <joachim.langenbach@…> (09/21/17 14:52:42)
- git-committer:
- Joachim Langenbach <joachim.langenbach@…> (09/21/17 15:17:50)
- File:
-
- 1 edited
-
src/python/bin/gnuboat-log-converter (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/python/bin/gnuboat-log-converter
r3145648 rb45e75d 43 43 return int(string) 44 44 except ValueError as error: 45 print 'INFO: Failed to convert value from line %s into numeric: %s\n Message: %s' % (current_row, string, error)45 print('INFO: Failed to convert value from line %s into numeric: {:s}\n Message: {:s}'.format(current_row, string, error)) 46 46 return 0 47 47 … … 54 54 matches = regex_nmea_position.match(nmea_value) 55 55 if matches is None: 56 print 'INFO: Failed to convert position value from line %s into decimal degrees: %s' % (current_row, nmea_value)56 print('INFO: Failed to convert position value from line {:s} into decimal degrees: {:s}'.format(current_row, nmea_value)) 57 57 return 58 58 decimalDegrees = toFloat(matches.group(1), current_row) … … 66 66 output_file = open(output_file_path, 'w', 0) 67 67 except IOError as error: 68 print "ERROR: Could not open the output file: %s" % error68 print('ERROR: Could not open the output file: {}'.format(error)) 69 69 sys.exit(3) 70 70 … … 81 81 input_file = open(input_file_path, 'r') 82 82 except IOError as error: 83 print "ERROR: Could not open the input file: %s" % error83 print('ERROR: Could not open the input file: {}'.format(error)) 84 84 sys.exit(3) 85 85 current_row = 1 … … 89 89 matches = regex_nmea_sentence.match(line) 90 90 if matches is None: 91 print 'INFO: Failed to parse nmea sentence (%s) at line %s\n' % (line, current_row)91 print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row)) 92 92 if not errors_ignore: 93 93 input_file.close() … … 99 99 if last_row is not None: 100 100 output_file_csv.writerow(last_row) 101 last_row = {'datetime': ' %s %s' %(nmea_sentence.datestamp, nmea_sentence.timestamp),101 last_row = {'datetime': '{} {}'.format(nmea_sentence.datestamp, nmea_sentence.timestamp), 102 102 'gps_status': nmea_sentence.status, 103 103 'latitude': nmeaToDecimalDegrees(nmea_sentence.lat, current_row), … … 125 125 output_file = open(output_file_path, 'w', 0) 126 126 except IOError as error: 127 print "ERROR: Could not open the output file: %s" % error127 print('ERROR: Could not open the output file: {}'.format(error)) 128 128 sys.exit(3) 129 129 … … 132 132 input_file = open(input_file_path, 'r') 133 133 except IOError as error: 134 print "ERROR: Could not open the input file: %s" % error134 print('ERROR: Could not open the input file: {}'.format(error)) 135 135 sys.exit(3) 136 136 current_row = 1 … … 140 140 matches = regex_nmea_sentence.match(line) 141 141 if matches is None: 142 print 'INFO: Failed to parse nmea sentence (%s) at line %s\n' % (line, current_row)142 print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row)) 143 143 if not errors_ignore: 144 144 input_file.close() … … 149 149 output_string = str(nmea_sentence) 150 150 if not strip_time and matches.group(1): 151 output_string = ' %s%s' % (matches.group(1), output_string)152 output_file.write( "%s\r\n" % str(output_string))151 output_string = '{}{}'.format(matches.group(1), output_string) 152 output_file.write('{}\r\n'.format(str(output_string))) 153 153 output_file.close() 154 154 input_file.close() … … 177 177 formats.append(file_format.name) 178 178 179 parser = argparse.ArgumentParser(description= "Convert gnuboat logfiles into other formats")179 parser = argparse.ArgumentParser(description='Convert gnuboat logfiles into other formats') 180 180 parser.add_argument('-f', '--format', dest='output_format', metavar='output_format', type=str, 181 181 help='Format of the output file.', choices=formats, default='CSV') … … 197 197 format_found = True 198 198 if not format_found: 199 print 'ERROR: Invalid input format specified: %s' % arguments.output_format199 print('ERROR: Invalid input format specified: {}'.format(arguments.output_format)) 200 200 sys.exit(1) 201 201 … … 207 207 208 208 if arguments.input_file is None: 209 print 'ERROR: No input file specified'209 print('ERROR: No input file specified') 210 210 sys.exit(2) 211 211 elif not os.path.exists(arguments.input_file): 212 print 'ERROR: Specified input file does not exists: %s' % arguments.input_file212 print('ERROR: Specified input file does not exists: {}'.format(arguments.input_file)) 213 213 sys.exit(3) 214 214 else: … … 216 216 217 217 if arguments.output_file is None: 218 print 'ERROR: No output file specified'218 print('ERROR: No output file specified') 219 219 sys.exit(2) 220 220 elif not os.path.exists(os.path.dirname(arguments.output_file)): 221 print 'ERROR: Specified directory of output file does not exists: %s' % arguments.output_file221 print('ERROR: Specified directory of output file does not exists: {}'.format(arguments.output_file)) 222 222 sys.exit(3) 223 223 else: … … 231 231 convertToGpx(input_file_path, output_file_path, errors_ignore, strip_time) 232 232 else: 233 print "ERROR: Undefined output format!\n";233 print('ERROR: Undefined output format!\n') 234 234 sys.exit(1) 235 235
Note:
See TracChangeset
for help on using the changeset viewer.
