def test_uuid(): """Test UUID generation from device serial IDs. """ assert l.get_uuid(l.CHANNEL_UUID, 1291) \ == UUID('3efc8b52-73a8-5f75-bb03-550eee537f46') assert l.get_uuid(l.CHANNEL_UUID, 1291).version == 5 assert l.get_uuid(l.CHANNEL_UUID, -1) == None assert l.get_uuid(l.CHANNEL_UUID, 'x') == None assert l.get_uuid(l.CHANNEL_UUID, None) == None
def set_route(self, uuid=None, serial_id=None, channel=CHANNEL_UUID): """Sets serial_id hash for HTTP headers. Parameters ---------- uuid: str real uuid of device serial_id : int Piksi device ID channel : str UUID namespace for device UUID """ if uuid: device_uid = uuid elif serial_id: device_uid = str(get_uuid(channel, serial_id % 1000)) else: print("Improper call of set_route, either a serial number or UUID should be passed") device_uid = str(get_uuid(channel, 1234)) print(("Setting UUID to default value of {0}".format(device_uid))) self.device_uid = device_uid
def set_route(self, serial_id, channel=CHANNEL_UUID): """Sets serial_id hash for HTTP headers. Parameters ---------- serial_id : int Piksi device ID channel : str UUID namespace for device UUID """ device_uid = str(get_uuid(channel, serial_id)) self.device_uid = device_uid if self.http: self.http.device_uid = device_uid
def set_route(self, uuid=None, serial_id=None, channel=CHANNEL_UUID): """Sets serial_id hash for HTTP headers. Parameters ---------- uuid: str real uuid of device serial_id : int Piksi device ID channel : str UUID namespace for device UUID """ if uuid: device_uid = uuid elif serial_id: device_uid = str(get_uuid(channel, serial_id % 1000)) else: print( "Improper call of set_route, either a serial number or UUID should be passed" ) device_uid = str(get_uuid(channel, 1234)) print("Setting UUID to default value of {0}".format(device_uid)) self.device_uid = device_uid
traceback.print_exc() # Make sure that SIGINT (i.e. Ctrl-C from command line) actually stops the # application event loop (otherwise Qt swallows KeyboardInterrupt exceptions) signal.signal(signal.SIGINT, signal.SIG_DFL) # Passing only a base station argument, we just want to display the # base station data in the console. Otherwise, continue, assuming a # rover connected to the serial port. if port is None and base is None: sys.stderr.write("ERROR: No data source specified!") sys.exit(1) if port is None and base and use_broker: device_id = get_uuid(channel, serial_id) with HTTPDriver(str(device_id), base) as http_driver: with sbpc.Handler(sbpc.Framer(http_driver.read, None, args.verbose)) as link: if os.path.isdir(log_filename): log_filename = os.path.join(log_filename, s.LOG_FILENAME) with s.get_logger(args.log, log_filename) as logger: link.add_callback(logger) log_filter = DEFAULT_LOG_LEVEL_FILTER if args.initloglevel[0]: log_filter = args.initloglevel[0] SwiftConsole(link, args.update, log_filter, True).configure_traits() try: os._exit(0) except: pass
import traceback traceback.print_exc() # Make sure that SIGINT (i.e. Ctrl-C from command line) actually stops the # application event loop (otherwise Qt swallows KeyboardInterrupt exceptions) signal.signal(signal.SIGINT, signal.SIG_DFL) # Passing only a base station argument, we just want to display the # base station data in the console. Otherwise, continue, assuming a # rover connected to the serial port. if port is None and base is None: sys.stderr.write("ERROR: No data source specified!") sys.exit(1) if port is None and base and use_broker: device_id = get_uuid(channel, serial_id) with HTTPDriver(str(device_id), base) as http_driver: with sbpc.Handler(sbpc.Framer(http_driver.read, None, args.verbose)) as link: if os.path.isdir(log_filename): log_filename = os.path.join(log_filename, s.LOG_FILENAME) with s.get_logger(args.log, log_filename) as logger: link.add_callback(logger) log_filter = DEFAULT_LOG_LEVEL_FILTER if args.initloglevel[0]: log_filter = args.initloglevel[0] SwiftConsole(link, args.update, log_filter, True).configure_traits() try: os._exit(0) except: