Beispiel #1
0
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("-")


print("find for org:")
topics = manager.find_for_org(api_auth.org_id)

for topic in topics:
    print(topic)
print("-")

            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 = []

        for subscription in cmd.subscriptions:
            sub_comms = DomainSocket(
                subscription.address) if subscription.address else StdIO()

            # handler...
Beispiel #3
0
                cmd.print_help(sys.stderr)
                exit(1)

            name = topic.name if cmd.name is None else cmd.name
            description = topic.description if cmd.description is None else cmd.description

            info = TopicInfo(
                TopicInfo.FORMAT_JSON) if topic.info is None else topic.info

            # update Topic...
            updated = Topic(None, name, description, topic.is_public, info,
                            None, None)

            manager.update(topic.path, updated)

            topic = manager.find(topic.path)

        else:
            if not cmd.is_complete():
                print(
                    "All fields required for topic creation must be provided.",
                    file=sys.stderr)
                cmd.print_help(sys.stderr)
                exit(1)

            info = TopicInfo(TopicInfo.FORMAT_JSON)

            # create Topic...
            topic = Topic(cmd.path, cmd.name, cmd.description, True, info,
                          True, cmd.schema_id)
            manager.create(topic)
Beispiel #4
0
    # ----------------------------------------------------------------------------------------------------------------
    # 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)

            name = topic.name if cmd.name is None else cmd.name
            description = topic.description if cmd.description is None else cmd.description
Beispiel #5
0
        creator.construct_topic(project.control_topic_path(system_id),
                                ProjectTopic.CONTROL)

        project.save(Host)

    project = Project.load(Host)
    print(JSONify.dumps(project))

    # report...
    if cmd.verbose and project is not None:
        print("-", file=sys.stderr)

        print("     gases_project: %s" % gases_topic, file=sys.stderr)
        print("-", file=sys.stderr)

        found = manager.find(project.climate_topic_path())

        if found is not None:
            print("     climate_topic: %s" % found.path, file=sys.stderr)

        found = manager.find(project.gases_topic_path())

        if found is not None:
            print("       gases_topic: %s" % found.path, file=sys.stderr)

        if include_particulates:
            found = manager.find(project.particulates_topic_path())

            if found is not None:
                print("particulates_topic: %s" % found.path, file=sys.stderr)
Beispiel #6
0
        # 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)

        # 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("start: %s" % start, file=sys.stderr)
            print("end: %s" % end, file=sys.stderr)
            sys.stderr.flush()
Beispiel #7
0
        # 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)
            sys.stderr.flush()

        # tag...
        # 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)
            sys.stderr.flush()

        # manager...
        manager = TopicManager(HTTPClient(), api_auth.api_key)

        # check topic...
        if not manager.find(cmd.topic):
            print("Topic not available: %s" % cmd.topic, file=sys.stderr)
            exit(1)

        # responder...
        handler = OSIOMQTTControlHandler()
        subscriber = MQTTSubscriber(cmd.topic, handler.handle)

        # client...
        client = MQTTClient(subscriber)

        if cmd.verbose:
            print(client, file=sys.stderr)
            sys.stderr.flush()

        # tag...
            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)

        # ------------------------------------------------------------------------------------------------------------
        # run...