コード例 #1
0
						data_PowerBox['Vp'], data_PowerBox['Vm'],
						1E+3*data_Noise['NOISE'], 1E+3*data_Noise['NOISE_STDDEV']))
				else:
					print time.strftime("%Y-%m-%d @ %H:%M:%S (%Z): ") + "{0:6.2f}%\t{1:12.4f} Hz  |  battery status: {2:5.2f} / {3:5.2f} (V)  |  noise: {4:6.4f} +/- {5:6.4f} mV".format(
						100.*_count/frequencies_number, frequencies_list[_count],
						data_PowerBox['Vp'], data_PowerBox['Vm'],
						1E+3*data_Noise['NOISE'], 1E+3*data_Noise['NOISE_STDDEV'])
				handle.flush()
				os.fsync(handle.fileno())
		except (LIB.Exceptions.SocketException, LIB.Exceptions.USBException):
			logger.error("(socket.error, USBError): trying to reconnect to our devices if necessary...")
			if args.external and not sFuncGen.is_open():
				sFuncGen.connect()
			if not sLockIn.is_open():
				sLockIn.connect()
			if not sOsci.is_open():
				sOsci.connect()
			continue
		except KeyboardInterrupt:
			SIGTERM = True
			logger.warning("received KeyboardInterrupt at {_strftime}".format(_strftime=time.strftime("%Y-%m-%d @ %H:%M:%S")))
			break
		_count += 1
	# while _count < ... AND not SIGTERM

	handle.close()

	# Either compress file and print saved message or just print that message
	if args.compress:
		LIB.Compression.gzip_file(data_directory + filename)
		os.remove(data_directory + filename)