Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/python/bin/gnuboat-log-converter

    re561143 r6fbf790  
    4343           return int(string)
    4444        except ValueError as error:
    45            print('INFO: Failed to convert value from line %s into numeric: {:s}\n      Message: {:s}'.format(current_row, string, error))
     45           print 'INFO: Failed to convert value from line %s into numeric: %s\n      Message: %s' % (current_row, string, error)
    4646           return 0
    4747
    … …  
    5454    matches = regex_nmea_position.match(nmea_value)
    5555    if matches is None:
    56         print('INFO: Failed to convert position value from line {:s} into decimal degrees: {:s}'.format(current_row, nmea_value))
     56        print 'INFO: Failed to convert position value from line %s into decimal degrees: %s' % (current_row, nmea_value)
    5757        return
    5858    decimalDegrees = toFloat(matches.group(1), current_row)
    … …  
    6666        output_file = open(output_file_path, 'w', 0)
    6767    except IOError as error:
    68         print('ERROR: Could not open the output file: {}'.format(error))
     68        print "ERROR: Could not open the output file: %s" % error
    6969        sys.exit(3)
    7070
    … …  
    8181        input_file = open(input_file_path, 'r')
    8282    except IOError as error:
    83         print('ERROR: Could not open the input file: {}'.format(error))
     83        print "ERROR: Could not open the input file: %s" % error
    8484        sys.exit(3)
    8585    current_row = 1
    … …  
    8989        matches = regex_nmea_sentence.match(line)
    9090        if matches is None:
    91             print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row))
     91            print 'INFO: Failed to parse nmea sentence (%s) at line %s\n' % (line, current_row)
    9292            if not errors_ignore:
    9393                input_file.close()
    … …  
    9999                if last_row is not None:
    100100                    output_file_csv.writerow(last_row)
    101                 last_row = {'datetime': '{} {}'.format(nmea_sentence.datestamp, nmea_sentence.timestamp),
     101                last_row = {'datetime': '%s %s' % (nmea_sentence.datestamp, nmea_sentence.timestamp),
    102102                            'gps_status': nmea_sentence.status,
    103103                            'latitude': nmeaToDecimalDegrees(nmea_sentence.lat, current_row),
    … …  
    125125        output_file = open(output_file_path, 'w', 0)
    126126    except IOError as error:
    127         print('ERROR: Could not open the output file: {}'.format(error))
     127        print "ERROR: Could not open the output file: %s" % error
    128128        sys.exit(3)
    129129
    … …  
    132132        input_file = open(input_file_path, 'r')
    133133    except IOError as error:
    134         print('ERROR: Could not open the input file: {}'.format(error))
     134        print "ERROR: Could not open the input file: %s" % error
    135135        sys.exit(3)
    136136    current_row = 1
    … …  
    140140        matches = regex_nmea_sentence.match(line)
    141141        if matches is None:
    142             print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row))
     142            print 'INFO: Failed to parse nmea sentence (%s) at line %s\n' % (line, current_row)
    143143            if not errors_ignore:
    144144                input_file.close()
    … …  
    149149            output_string = str(nmea_sentence)
    150150            if not strip_time and matches.group(1):
    151                 output_string = '{}{}'.format(matches.group(1), output_string)
    152             output_file.write('{}\r\n'.format(str(output_string)))
     151                output_string = '%s%s' % (matches.group(1), output_string)
     152            output_file.write("%s\r\n" % str(output_string))
    153153    output_file.close()
    154154    input_file.close()
    … …  
    177177      formats.append(file_format.name)
    178178
    179     parser = argparse.ArgumentParser(description='Convert gnuboat logfiles into other formats')
     179    parser = argparse.ArgumentParser(description="Convert gnuboat logfiles into other formats")
    180180    parser.add_argument('-f', '--format', dest='output_format', metavar='output_format', type=str,
    181181                        help='Format of the output file.', choices=formats, default='CSV')
    … …  
    197197               format_found = True
    198198        if not format_found:
    199             print('ERROR: Invalid input format specified: {}'.format(arguments.output_format))
     199            print 'ERROR: Invalid input format specified: %s' % arguments.output_format
    200200            sys.exit(1)
    201201
    … …  
    207207           
    208208    if arguments.input_file is None:
    209         print('ERROR: No input file specified')
     209        print 'ERROR: No input file specified'
    210210        sys.exit(2)
    211211    elif not os.path.exists(arguments.input_file):
    212         print('ERROR: Specified input file does not exists: {}'.format(arguments.input_file))
     212        print 'ERROR: Specified input file does not exists: %s' % arguments.input_file
    213213        sys.exit(3)
    214214    else:
    … …  
    216216       
    217217    if arguments.output_file is None:
    218         print('ERROR: No output file specified')
     218        print 'ERROR: No output file specified'
    219219        sys.exit(2)
    220220    elif not os.path.exists(os.path.dirname(arguments.output_file)):
    221         print('ERROR: Specified directory of output file does not exists: {}'.format(arguments.output_file))
     221        print 'ERROR: Specified directory of output file does not exists: %s' % arguments.output_file
    222222        sys.exit(3)
    223223    else:
    … …  
    231231        convertToGpx(input_file_path, output_file_path, errors_ignore, strip_time)
    232232    else:
    233         print('ERROR: Undefined output format!\n')
     233        print "ERROR: Undefined output format!\n";
    234234        sys.exit(1)
    235235
Note: See TracChangeset for help on using the changeset viewer.