예제 #1
0
    logfile = 'flight-' + d.strftime("%Y-%m-%d-%H:%M:%S") + '.log'
    try:
        f = open(logfile, 'wb')
    except:
        print "Cannot open:", logfile
        quit()
    return f
  
if args.serial:
    try:
        ser = serial.Serial(args.serial, args.baud, timeout=dt)
    except:
        print "Cannot open:", args.serial
        import serial.tools.list_ports
        ports = list(serial.tools.list_ports.comports())
        print "Available ports:"
        for p in ports:
            print p
        quit()

    f = new_logfile()
        
    while True:
        auraparser.serial_read(ser, f)
        current.compute_derived_data()
        commands.update(ser)
        telnet.update()
        httpserver.update()
else:
    print "A serial port must be provided"    
예제 #2
0
    chunk_size = size / divs
    threshold = chunk_size
    print 'len of decompressed file:', size

    bar = Bar('Parsing log file:', max=divs, suffix='%(percent)d%% (%(eta)ds)')

    while True:
        try:
            (id, index, counter) = auraparser.file_read(full)
            if not located:
                if gps_node.getInt('satellites') >= 5:
                    lat = gps_node.getFloat('latitude_deg')
                    lon = gps_node.getFloat('longitude_deg')
                    sec = gps_node.getFloat('unix_time_sec')
                    located = True
            current.compute_derived_data()
            category = logical_category(id)
            record = generate_record(category, index)
            key = '%s-%d' % (category, index)
            # print 'key:', key
            if key in data:
                data[key].append(record)
            else:
                data[key] = [record]
            if counter > threshold:
                threshold += chunk_size
                bar.next()
        except:
            bar.finish()
            print 'end of file'
            break