Пример #1
0
def test_new (tmpdir):
	dataprint.to_newfile(str(tmpdir) + "/new.file", a)
	fd = open(str(tmpdir) + "/new.file", "r")
	temp = fd.read()
	fd.close()
	assert temp == a_default
Пример #2
0
		module_node_id,rest = line.split(maxsplit=1)
		module_nodes[module_node_id] = rest.split()
except IOError:
	pass

for node in (('A','0'), ('B','1'), ('C','2')):
	node_id = meta[node[1]]
	row = []
	for conf in print_order:
		try:
			row.append(calibration[node[0]][conf])
		except KeyError:
			row.append(-1)
	module_nodes[nodeid_to_module_id(node_id)] = row

outdata = []
outdata.append('# Columns are formatted as (channel, antenna)'.split())
header = ['# Node ID',]
header.extend(map(str, print_order))
outdata.append(header)

for module_id in sorted(module_nodes.keys()):
	row = [module_id,]
	row.extend(module_nodes[module_id])
	outdata.append(row)

print(outdata)

dataprint.to_newfile(OUTPUT_FNAME, outdata, overwrite=True)

Пример #3
0
def test_file_permission_denied (tmpdir):
	with pytest.raises(dataprint.DataPrinterException):
		dataprint.to_newfile("/write.file", a)
Пример #4
0
def test_file_permission_denied(tmpdir):
    with pytest.raises(dataprint.DataPrinterException):
        dataprint.to_newfile("/write.file", a)
Пример #5
0
								if not k in ['_meta', 'id', 'device']:
									devices[id]['columns'].append(k)
							devices[id]['columns'] = ['timestamp', 'isotime'] + sorted(devices[id]['columns'])

						# Pull out the data from this packet
						dev = devices[id]
						new_row = []
						try:
							tstamp = int(iso8601.parse_date(blob['_meta']['received_time']).timestamp()*1000)
							blob['timestamp'] = tstamp
							blob['isotime'] = blob['_meta']['received_time']

							for c in dev['columns']:
								new_row.append(blob[c])

							# Save this
							dev['rows'].append(new_row)
						except Exception as e:
							print(e)


				except json.decoder.JSONDecodeError as e:
					print('invalid json: {}'.format(l))
					print(e)

	# Save each device
	print('Writing data files.')
	for device_id, data in devices.items():
		rows = sorted(data['rows'], key=lambda c: c[0])
		dataprint.to_newfile('gateway_log_{}.data'.format(device_id), [data['columns']] + rows, overwrite=True)
Пример #6
0
					data[rnd][0] = t1
					data[rnd][3] = t2
					data[rnd][5] = t3


			except:
				pass



outdata = []

outdata.append(['RoundNum', 'NodeBeingCalibrated',
                'L', 'M', 'N', 'O', 'P', 'Q'])

for key in sorted(data):
	if -1 in data[key]:
		continue
	node = ['A', 'B', 'C'][(((key % 3) + 2) % 3)]
	outdata.append([key, node] + data[key])


outfilename_base = 'tripoint_calibration_' + timestamp


with open(outfilename_base + '.meta', 'w') as f:
	f.write(json.dumps(meta))


dataprint.to_newfile(outfilename_base+'.condensed', outdata, overwrite=True)
Пример #7
0
                        # Pull out the data from this packet
                        dev = devices[id]
                        new_row = []
                        try:
                            tstamp = int(
                                iso8601.parse_date(
                                    blob['_meta']
                                    ['received_time']).timestamp() * 1000)
                            blob['timestamp'] = tstamp
                            blob['isotime'] = blob['_meta']['received_time']

                            for c in dev['columns']:
                                new_row.append(blob[c])

                            # Save this
                            dev['rows'].append(new_row)
                        except Exception as e:
                            print(e)

                except json.decoder.JSONDecodeError as e:
                    print('invalid json: {}'.format(l))
                    print(e)

    # Save each device
    print('Writing data files.')
    for device_id, data in devices.items():
        rows = sorted(data['rows'], key=lambda c: c[0])
        dataprint.to_newfile('gateway_log_{}.data'.format(device_id),
                             [data['columns']] + rows,
                             overwrite=True)
Пример #8
0
            continue
        tripoint_node_id, rest = line.split(maxsplit=1)
        tripoint_nodes[tripoint_node_id] = rest.split()
except IOError:
    pass

for node in (("A", "0"), ("B", "1"), ("C", "2")):
    node_id = meta[node[1]]
    row = []
    for conf in print_order:
        try:
            row.append(calibration[node[0]][conf])
        except KeyError:
            row.append(-1)
    tripoint_nodes[nodeid_to_tripoint_id(node_id)] = row

outdata = []
outdata.append("# Columns are formatted as (channel, antenna)".split())
header = ["# Node ID"]
header.extend(map(str, print_order))
outdata.append(header)

for tripoint_id in sorted(tripoint_nodes.keys()):
    row = [tripoint_id]
    row.extend(tripoint_nodes[tripoint_id])
    outdata.append(row)

print(outdata)

dataprint.to_newfile(OUTPUT_FNAME, outdata, overwrite=True)
Пример #9
0
def test_new(tmpdir):
    dataprint.to_newfile(str(tmpdir) + "/new.file", a)
    fd = open(str(tmpdir) + "/new.file", "r")
    temp = fd.read()
    fd.close()
    assert temp == a_default
Пример #10
0
					data[rnd][2] = t2
					data[rnd][4] = t3
				else:
					data[rnd][0] = t1
					data[rnd][3] = t2
					data[rnd][5] = t3

			except:
				pass

outdata = []

outdata.append(['RoundNum', 'NodeBeingCalibrated',
                'L', 'M', 'N', 'O', 'P', 'Q'])

for key in sorted(data):
	if -1 in data[key]:
		continue
	node = ['A', 'B', 'C'][(((key % 3) + 2) % 3)]
	outdata.append([key, node] + data[key])


# Print into new file

outfilename_base = 'module_calibration_' + timestamp

with open(outfilename_base + '.meta', 'w') as f:
	f.write(json.dumps(meta))

dataprint.to_newfile(outfilename_base+'.condensed', outdata, overwrite=True)