args = parser.parse_args() # Set the debug level if args.generic_debug == True: logging.getLogger().setLevel(logging.DEBUG) # Get the login data try: login_data = LoginDataHandler(args.url, args.secret_file) except CLSNoLoginInformationFound: logging.critical("No login information for this host found") sys.exit(10) # Try to login try: clscenter = CLSCenter(args.url, login_data.getUser(), login_data.getPassword(), login_data.getTenant()) except: logging.critical("Login to EMT Instance failed") sys.exit(20) # The use case specific code follows here datastore = clscenter.getDatastore() endTimestamp = int(time.time()) startTimestamp = endTimestamp - (args.timing * 60 * 60) aggregate = '[{"$match": { "geo": { "$exists": true }, "data.ownernumber":"' + args.sensorId + '", "ts.device" : {"$gte": ' + str( startTimestamp ) + ', "$lte": ' + str( endTimestamp
args = parser.parse_args() # Set the debug level if args.generic_debug == True: logging.getLogger().setLevel(logging.DEBUG) # Get the login data try: login_data = LoginDataHandler(args.url, args.secret_file) except CLSNoLoginInformationFound: logging.critical("No login information for this host found") sys.exit(10) # Try to login try: clsCenter = CLSCenter(args.url, login_data.getUser(), login_data.getPassword(), login_data.getTenant()) except: logging.critical("Login to EMT Instance failed") sys.exit(20) # The use case specific code follows here inventory = Inventory(clsCenter) ret = inventory.query("{ \"content.macAddress\": \"%s\" }" % args.mac) data = ret[0] print("Firmware Version: %s" % data["content"]["versionData"]["baseVersion"]) print("Original JSON:") print(json.dumps(data, sort_keys=True, indent=4))
args = parser.parse_args() # Set the debug level if args.generic_debug == True: logging.getLogger().setLevel(logging.DEBUG) # Get the login data try: login_data = LoginDataHandler(args.url, args.secret_file) except CLSNoLoginInformationFound: logging.critical("No login information for this host found") sys.exit(10) # Try to login try: clscenter = CLSCenter(args.url, login_data.getUser(), login_data.getPassword(), login_data.getTenant()) except: logging.critical("Login to EMT Instance failed") sys.exit(20) # The use case specific code follows here payload = {} payload["imme"] = args.imme payload["devEUI"] = args.sensorId payload["data"] = args.payload payload["port"] = 10 # ({'data': {'id': '0018B20000002445_c15ca4ff-4ea1-4e3d-8c77-eb3e9a219829', 'imme': False, 'confirmed': False, 'devEUI': '0018B20000002445', 'data': '3132333435', 'port': 1, 'retriesLeft': 0}, 'replyText': 'data', 'replyCode': 200}, 200) r, header_code = clscenter.postJsonData2("lnsadapter", "downpackets", json.dumps(payload))
args = parser.parse_args() # Set the debug level if args.generic_debug == True: logging.getLogger().setLevel(logging.DEBUG) # Get the login data try: login_data = LoginDataHandler(args.url, args.secret_file) except CLSNoLoginInformationFound: logging.critical("No login information for this host found") sys.exit(10) # Try to login try: clsCenter = CLSCenter(args.url, login_data.getUser(), login_data.getPassword(), login_data.getTenant()) except: logging.critical("Login to EMT Instance failed") sys.exit(20) # The use case specific code follows here sw = clsCenter.getSwitchingPoint(args.sw) value_set = sw.switch(args.value) if value_set != args.value: logging.info("Switching was regulated to %d (we wanted %d)", value_set, args.value) # if we do not succeed we need to use exit code > 100 sys.exit(101)
args = parser.parse_args() # Set the debug level if args.generic_debug == True: logging.getLogger().setLevel(logging.DEBUG) # Get the login data try: login_data = LoginDataHandler(args.url, args.secret_file) except CLSNoLoginInformationFound: logging.critical("No login information for this host found") sys.exit(10) # Try to login try: clsCenter = CLSCenter(args.url, login_data.getUser(), login_data.getPassword(), login_data.getTenant()) except: logging.critical("Login to EMT Instance failed") sys.exit(20) # The use case specific code follows here module = clsCenter.getModule(args.mac) module.prettyPrint() state = module.getLastState() ts_end = (int(state["timestamp"]) / 1000) ts_start = ts_end - (args.hours * 60 * 60)