cmd = CmdTopicDelete() if not cmd.is_valid(): cmd.print_help(sys.stderr) exit(2) if cmd.verbose: print(cmd, file=sys.stderr) sys.stderr.flush() # ---------------------------------------------------------------------------------------------------------------- # resources... # APIAuth... auth = APIAuth.load(Host) if auth is None: print("APIAuth not available.", file=sys.stderr) exit(1) # manager... manager = TopicManager(HTTPClient(), auth.api_key) # ---------------------------------------------------------------------------------------------------------------- # run... success = manager.delete(cmd.path) if cmd.verbose: print("deleted: %s" % success, file=sys.stderr)
# ClientAuth... client_auth = ClientAuth.load(Host) if client_auth is None: print("ClientAuth not available.", file=sys.stderr) exit(1) if cmd.verbose: print(client_auth, file=sys.stderr) # comms... pub_comms = DomainSocket( cmd.uds_pub_addr) if cmd.uds_pub_addr else StdIO() # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) # check topics... unavailable = False for subscription in cmd.subscriptions: if not manager.find(subscription.topic): print("Topic not available: %s" % subscription[0], file=sys.stderr) unavailable = True if unavailable: exit(1) # subscribers... subscribers = []
if cmd.verbose: print("topic: %s" % cmd, file=sys.stderr) sys.stderr.flush() # ---------------------------------------------------------------------------------------------------------------- # resources... # APIAuth... api_auth = APIAuth.load(Host) if api_auth is None: print("topic: APIAuth not available.", file=sys.stderr) exit(1) # manager... manager = TopicManager(api_auth.api_key) # check for existing registration... topic = manager.find(cmd.path) # ---------------------------------------------------------------------------------------------------------------- # run... if cmd.set(): if topic: if cmd.schema_id is not None: print( "topic: It is not possible to change the schema ID of an existing topic.", file=sys.stderr) cmd.print_help(sys.stderr) exit(1)
print("APIAuth not available.", file=sys.stderr) exit(1) print(api_auth) # ClientAuth... client_auth = ClientAuth.load(Host) if client_auth is None: print("ClientAuth not available.", file=sys.stderr) exit(1) print(client_auth) # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) print(manager) print("-") # -------------------------------------------------------------------------------------------------------------------- # run... print("find:") topic = manager.find('/orgs/south-coast-science-dev/development/loc/2/gases') print(topic) print("-")
if cmd.verbose: print(cmd, file=sys.stderr) sys.stderr.flush() # ---------------------------------------------------------------------------------------------------------------- # resources... # APIAuth... api_auth = APIAuth.load(Host) if api_auth is None: print("APIAuth not available.", file=sys.stderr) exit(1) # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) # check for existing registration... topics = manager.find_for_org(api_auth.org_id, cmd.path) # find TopicSummary topic = topics[0] if len(topics) > 0 else None # ---------------------------------------------------------------------------------------------------------------- # run... if cmd.set(): if topic: if cmd.schema_id is not None: print( "It is not possible to change the schema ID of an existing topic.",
if cmd.verbose: print("device_topics: %s" % api_auth, file=sys.stderr) sys.stderr.flush() # managers... device_manager = DeviceManager(HTTPClient(), api_auth.api_key) # check for existing registration... device = device_manager.find(api_auth.org_id, cmd.client_id) if device is None: print("device_topics: Device not found.", file=sys.stderr) exit(1) topic_manager = TopicManager(HTTPClient(), api_auth.api_key) # ---------------------------------------------------------------------------------------------------------------- # run... # time... if cmd.use_offset(): end = LocalizedDatetime.now() start = end.timedelta(minutes=-cmd.minutes) else: end = LocalizedDatetime.now() if cmd.end is None else cmd.end start = cmd.start if cmd.verbose: print("device_topics: start: %s" % start, file=sys.stderr) print("device_topics: end: %s" % end, file=sys.stderr)
cmd = CmdTopicDelete() if not cmd.is_valid(): cmd.print_help(sys.stderr) exit(2) if cmd.verbose: print("topic_delete: %s" % cmd, file=sys.stderr) sys.stderr.flush() # ---------------------------------------------------------------------------------------------------------------- # resources... # APIAuth... auth = APIAuth.load(Host) if auth is None: print("topic_delete: APIAuth not available.", file=sys.stderr) exit(1) # manager... manager = TopicManager(auth.api_key) # ---------------------------------------------------------------------------------------------------------------- # run... success = manager.delete(cmd.path) if cmd.verbose: print("topic_delete: deleted: %s" % success, file=sys.stderr)
if cmd.verbose: print("osio_project: %s" % system_id, file=sys.stderr) # AFECalib... afe_calib = AFECalib.load(Host) if afe_calib is None: print("osio_project: AFECalib not available.", file=sys.stderr) exit(1) if cmd.verbose: print("osio_project: %s" % afe_calib, file=sys.stderr) sys.stderr.flush() # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) creator = HostProject(manager) # gases schema... gases_topic = ProjectTopic.get_gases_topic(afe_calib.gas_names()) # ---------------------------------------------------------------------------------------------------------------- # run... include_particulates = False if opc_conf is None else opc_conf.has_monitor( ) # set... if cmd.set(): project = Project.construct(api_auth.org_id, cmd.group,
if cmd.verbose: print("osio_mqtt_control: %s" % api_auth, file=sys.stderr) # ClientAuth... client_auth = ClientAuth.load(Host) if client_auth is None: print("osio_mqtt_control: ClientAuth not available.", file=sys.stderr) exit(1) if cmd.verbose: print("osio_mqtt_control: %s" % client_auth, file=sys.stderr) sys.stderr.flush() # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) # check topic... if not manager.find(cmd.device_topic): print("osio_mqtt_control: Topic not available: %s" % cmd.device_topic, file=sys.stderr) exit(1) # responder... handler = OSIOMQTTControlHandler() subscriber = MQTTSubscriber(cmd.device_topic, handler.handle) # client... client = MQTTClient(subscriber) if cmd.verbose: print("osio_mqtt_control: %s" % client, file=sys.stderr)
# ------------------------------------------------------------------------------------------------------------ # resources... # APIAuth... api_auth = APIAuth.load(Host) if api_auth is None: print("APIAuth not available.", file=sys.stderr) exit(1) if cmd.verbose: print(api_auth, file=sys.stderr) sys.stderr.flush() # topic manager... topic_manager = TopicManager(HTTPClient(), api_auth.api_key) # message manager... message_manager = MessageManager(HTTPClient(), api_auth.api_key, cmd.verbose) if cmd.verbose: print(message_manager, file=sys.stderr) # ------------------------------------------------------------------------------------------------------------ # run... # check topics... if not topic_manager.find(cmd.path): print("Topic not available: %s" % cmd.path, file=sys.stderr) exit(1)
# ------------------------------------------------------------------------------------------------------------ # resources... # APIAuth... api_auth = APIAuth.load(Host) if api_auth is None: print("user_topics: APIAuth not available.", file=sys.stderr) exit(1) if cmd.verbose: print("user_topics: %s" % api_auth, file=sys.stderr) sys.stderr.flush() # manager... manager = TopicManager(api_auth.api_key) # ------------------------------------------------------------------------------------------------------------ # run... # find... topics = manager.find_for_user(cmd.user_id) for topic in topics: print(JSONify.dumps(topic)) if cmd.verbose: print("user_topics: total: %d" % len(topics), file=sys.stderr)
print("topic_list: %s" % cmd, file=sys.stderr) # ---------------------------------------------------------------------------------------------------------------- # resources... # APIAuth... api_auth = APIAuth.load(Host) if api_auth is None: print("topic_list: APIAuth not available.", file=sys.stderr) exit(1) if cmd.verbose: print("topic_list: %s" % api_auth, file=sys.stderr) sys.stderr.flush() # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) # ---------------------------------------------------------------------------------------------------------------- # run... topics = manager.find_for_org(api_auth.org_id, cmd.partial_path, cmd.schema_id) for topic in topics: print(JSONify.dumps(topic)) if cmd.verbose: print("topic_list: total: %d" % len(topics), file=sys.stderr)
if cmd.use_domain_conf: domain = DomainConf.load(Host) topic_path = domain.topic_path if domain is None: print("osio_mqtt_subscriber: Domain not available.", file=sys.stderr) exit(1) if cmd.verbose: print(domain, file=sys.stderr) else: topic_path = cmd.topic_path # manager... manager = TopicManager(api_auth.api_key) # check topics... if not manager.find(topic_path): print("osio_mqtt_subscriber: Topic not available: %s" % topic_path, file=sys.stderr) exit(1) # subscribers... handler = OSIOMQTTClientHandler(StdIO(), cmd.verbose) subscriber = MQTTSubscriber(topic_path, handler.handle) # client... client = MQTTClient(subscriber) client.connect(ClientAuth.MQTT_HOST, client_auth.client_id, client_auth.user_id, client_auth.client_password)
# ---------------------------------------------------------------------------------------------------------------- # resources... # APIAuth... api_auth = APIAuth.load(Host) if api_auth is None: print("APIAuth not available.", file=sys.stderr) exit(1) if cmd.verbose: print(api_auth, file=sys.stderr) sys.stderr.flush() # manager... manager = TopicManager(HTTPClient(), api_auth.api_key) # ---------------------------------------------------------------------------------------------------------------- # run... # find... topics = manager.find_for_user(cmd.user_id) for topic in topics: print(JSONify.dumps(topic)) if cmd.verbose: print("total: %d" % len(topics), file=sys.stderr) # ---------------------------------------------------------------------------------------------------------------- # end...
{"msg": {"op": "scs-rpi-006", "spec": "scs-rpi-006"}, "err": null} deliver-change 870725f3-e692-4538-aa81-bfa8b51d44e7 south-coast-science-dev 43308b72-ad41-4555-b075-b4245c1971db """ from scs_core.osio.manager.topic_manager import TopicManager from scs_host.client.http_client import HTTPClient # -------------------------------------------------------------------------------------------------------------------- org_id = "south-coast-science-dev" api_key = "43308b72-ad41-4555-b075-b4245c1971db" # -------------------------------------------------------------------------------------------------------------------- # manager... manager = TopicManager(HTTPClient(), api_key) print(manager) print("=") topics = manager.find_for_org(org_id) for topic in topics: print(topic) print("-")