def _getOptions(self, argv): opts, args = getopt.getopt(argv[1:], "i:s:h", ["id=", "sys-id=", "help"]) for opt in opts: if opt[0] in ["-i", "--id"]: self.submission_uuid = str(uuid.UUID(opt[1])) if opt[0] in ["-s", "--sys-id"]: self.system_uuid = str(uuid.UUID(opt[1])) if opt[0] in ["-h", "--help"]: _usage() sys.exit(1) fs = filestorage.FileStorage("importer", web_accessible=False, settings=settings.filestorage_settings) self.submission_file = fs.path(self.submission_uuid + ".rdf")
def _getOptions(self, argv): opts, args = getopt.getopt(argv[1:], "i:h", ["id=", "help"]) for opt in opts: if opt[0] in ["-i", "--id"]: self.submission_uuid = str(uuid.UUID(opt[1])) if opt[0] in ["-h", "--help"]: _usage() sys.exit(1)
def _getOptions(self,argv): opts, args=getopt.getopt(argv[1:], "i:vh", ["id=","verbose", "help"]) for opt in opts: if opt[0] in ["-i", "--id"]: self.submission_uuid = str(uuid.UUID(opt[1])) if opt[0] in ["-h", "--help"]: _usage() sys.exit(1) if opt[0] in [ "-v", "--verbose"]: logging.basicConfig(level=logging.DEBUG)
def _get_system_uuid(store, submission_uuid): graph = Graph(store, identifier=contexts.CONTEXT_NS.SubmissionInfo) submission = ordfm.OriginalSubmission.get(graph, uri="urn:uuid:" + submission_uuid) if submission is None: raise Exception("no submission found " + str(submission_uuid)) storage = filestorage.ResourceStorage( submission, web_accessible=False, settings=settings.filestorage_settings) f = file(storage.path("system", "uuid"), "r") id = str(uuid.UUID(f.readlines()[0])) f.close() return id
def _get_id(submission): storage = filestorage.ResourceStorage(submission, web_accessible=False, settings=settings.filestorage_settings) f=file(storage.path("system","uuid"), "r") id = str(uuid.UUID(f.readlines()[0])) f.close() return id
def runClient(client, reset, ready, devices): """Start a Beetle client""" gapUuid = uuid.UUID(gatt.GAP_SERVICE_UUID) nameUuid = uuid.UUID(gatt.GAP_CHARAC_DEVICE_NAME_UUID) lightUuid = uuid.UUID(LIGHT_SERVICE_UUID) redUuid = uuid.UUID(RED_CHARAC_UUID) greenUuid = uuid.UUID(GREEN_CHARAC_UUID) blueUuid = uuid.UUID(BLUE_CHARAC_UUID) whiteUuid = uuid.UUID(WHITE_CHARAC_UUID) rgbwUuid = uuid.UUID(RGBW_CHARAC_UUID) beetleUuid = uuid.UUID(beetle.BEETLE_SERVICE_UUID) bdAddrUuid = uuid.UUID(beetle.BEETLE_CHARAC_BDADDR_UUID) connTimeUuid = uuid.UUID(beetle.BEETLE_CHARAC_CONNECTED_TIME_UUID) gatewayUuid = uuid.UUID(beetle.BEETLE_CHARAC_CONNECTED_GATEWAY_UUID) def _daemon(): while True: del devices[:] services = client.discoverAll() currDevice = None # proceed down the services, separating out devices printBox("Discovering handles") for service in services: print service if service.uuid == gapUuid: for charac in service.characteristics: print " ", charac if charac.uuid == nameUuid: currDevice = None try: currDeviceName = str(charac.read()) currDevice = LightInstance(name=currDeviceName) except ClientError, err: print err except Exception, err: print err elif service.uuid == lightUuid: for charac in service.characteristics: print " ", charac, charac.userDescription if currDevice is not None: if charac.uuid == whiteUuid: currDevice.w = charac elif charac.uuid == redUuid: currDevice.r = charac elif charac.uuid == greenUuid: currDevice.g = charac elif charac.uuid == blueUuid: currDevice.b = charac elif charac.uuid == rgbwUuid: currDevice.rgbw = charac elif service.uuid == beetleUuid: for charac in service.characteristics: print " ", charac if currDevice is not None: if charac.uuid == bdAddrUuid: try: bdaddr = charac.read()[::-1] currDevice.address = ":".join( "%02X" % x for x in bdaddr) except ClientError, err: print err except Exception, err: print err elif charac.uuid == connTimeUuid: try: raw = charac.read() if len(raw) != 4: continue epoch = struct.unpack('<I', bytes(raw))[0] currDevice.connectTime = \ datetime.utcfromtimestamp(epoch) except ClientError, err: print err
def runClient(client, reset, ready, devices): """Start a beetle client""" gapUuid = uuid.UUID(gatt.GAP_SERVICE_UUID) nameUuid = uuid.UUID(gatt.GAP_CHARAC_DEVICE_NAME_UUID) envSenseUuid = uuid.UUID(ENV_SENSING_SERVICE_UUID) pressureUuid = uuid.UUID(PRESSURE_CHARAC_UUID) temperatureUuid = uuid.UUID(TEMPERATURE_CHARAC_UUID) humidityUuid = uuid.UUID(HUMIDITY_CHARAC_UUID) unk1Uuid = uuid.UUID(UNK1_CHARAC_UUID) unk2Uuid = uuid.UUID(UNK2_CHARAC_UUID) beetleUuid = uuid.UUID(beetle.BEETLE_SERVICE_UUID) bdAddrUuid = uuid.UUID(beetle.BEETLE_CHARAC_BDADDR_UUID) connTimeUuid = uuid.UUID(beetle.BEETLE_CHARAC_CONNECTED_TIME_UUID) gatewayUuid = uuid.UUID(beetle.BEETLE_CHARAC_CONNECTED_GATEWAY_UUID) def _daemon(): while True: del devices[:] services = client.discoverAll() currDevice = None # proceed down the services, separating out devices printBox("Discovering handles") for service in services: print service if service.uuid == gapUuid: for charac in service.characteristics: print " ", charac if charac.uuid == nameUuid: currDevice = None try: currDeviceName = str(charac.read()) currDevice = SensorInstance( name=currDeviceName) except ClientError, err: print err except Exception, err: print err elif service.uuid == envSenseUuid: for charac in service.characteristics: print " ", charac if currDevice is not None: if charac.uuid == pressureUuid: currDevice._pressure = charac elif charac.uuid == temperatureUuid: currDevice._temperature = charac elif charac.uuid == humidityUuid: currDevice._humidity = charac elif charac.uuid == unk1Uuid: currDevice._unk1 = charac elif charac.uuid == unk2Uuid: currDevice._unk2 = charac elif service.uuid == beetleUuid: for charac in service.characteristics: print " ", charac if currDevice is not None: if charac.uuid == bdAddrUuid: try: bdaddr = charac.read()[::-1] currDevice.address = ":".join( "%02X" % x for x in bdaddr) except ClientError, err: print err except Exception, err: print err elif charac.uuid == connTimeUuid: try: raw = charac.read() if len(raw) != 4: continue epoch = struct.unpack('<I', bytes(raw))[0] currDevice.connectTime = \ datetime.utcfromtimestamp(epoch) except ClientError, err: print err
self._getOptions(argv) def _getOptions(self,argv): opts, args=getopt.getopt(argv[1:], "c:h", ["context=", "help"]) for opt in opts: if opt[0] in ["-c", "--context"]: self.context = opt[1] if self.context is None: _usage() sys.exit(1) def _usage(error=None): print "Usage : "+os.path.basename(sys.argv[0])+" --context=context_uuid" print "" if error is not None: print "" print error print "" base_graph = None options = Options(sys.argv) base_graph = graphstore.graph() print "triples: "+str(len(base_graph)) base_graph.remove_context(rdflib.URIRef("urn:uuid:"+str(uuid.UUID(options.context)))) base_graph.commit() print "triples: "+str(len(base_graph))