コード例 #1
0
        # 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 = []
コード例 #2
0
    if cmd.verbose:
        print("user: %s" % api_auth, file=sys.stderr)

    # ClientAuth...
    client_auth = ClientAuth.load(Host)

    if client_auth is None:
        print("user: ClientAuth not available.", file=sys.stderr)
        exit(1)

    if cmd.verbose:
        print("user: %s" % client_auth, file=sys.stderr)
        sys.stderr.flush()

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

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

    # find self...
    user = manager.find(client_auth.user_id)

    if user is None:
        print("user: User not found.", file=sys.stderr)
        exit(1)

    if cmd.set():
        name = user.name if cmd.name is None else cmd.name
        email = user.email if cmd.email is None else cmd.email
        password = user.password if cmd.password is None else cmd.password
コード例 #3
0
    if cmd.verbose:
        print("schema_list: %s" % cmd, file=sys.stderr)

    # ----------------------------------------------------------------------------------------------------------------
    # resources...

    # APIAuth...
    auth = APIAuth.load(Host)

    if auth is None:
        print("schema_list: APIAuth not available.", file=sys.stderr)
        exit(1)

    if cmd.verbose:
        print("schema_list: %s" % auth, file=sys.stderr)
        sys.stderr.flush()

    # manager...
    manager = SchemaManager(HTTPClient(), auth.api_key)

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

    schemas = manager.find_all()

    for schema in schemas:
        print(JSONify.dumps(schema))

    if cmd.verbose:
        print("schema_list: total: %d" % len(schemas), file=sys.stderr)
コード例 #4
0
    # ----------------------------------------------------------------------------------------------------------------
    # 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 = DeviceManager(HTTPClient(), api_auth.api_key)

    # check for existing registration...
    device = manager.find(api_auth.org_id, cmd.client_id)

    if device is None:
        print("Device not found.", file=sys.stderr)
        exit(1)

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

    if cmd.set():
        # update Device...
        updated = ProjectSource.update(device, cmd.lat, cmd.lng, cmd.postcode,
                                       cmd.description)
コード例 #5
0
    # ----------------------------------------------------------------------------------------------------------------
    # resources...

    # APIAuth...
    api_auth = APIAuth.load(Host)

    if api_auth is None:
        print("osio_client_auth: APIAuth not available.", file=sys.stderr)
        exit(1)

    if cmd.verbose:
        print("osio_client_auth: %s" % api_auth, file=sys.stderr)

    # User manager...
    user_manager = UserManager(HTTPClient(), api_auth.api_key)

    # Device manager...
    device_manager = DeviceManager(HTTPClient(), api_auth.api_key)

    # check for existing registration...
    device = device_manager.find_for_name(api_auth.org_id, Host.name())

    # check for existing ClientAuth...
    client_auth = ClientAuth.load(Host)


    # ----------------------------------------------------------------------------------------------------------------
    # remove non-matching record...

    if device and client_auth:
コード例 #6
0
ファイル: device_topics.py プロジェクト: seoss/scs_osio
        # ----------------------------------------------------------------------------------------------------------------
        # resources...

        # APIAuth...
        api_auth = APIAuth.load(Host)

        if api_auth is None:
            print("device_topics: APIAuth not available.", file=sys.stderr)
            exit(1)

        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():
コード例 #7
0
        # ------------------------------------------------------------------------------------------------------------
        # 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()

        # message manager...
        message_manager = MessageManager(HTTPClient(), api_auth.api_key,
                                         cmd.verbose)

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

        # ------------------------------------------------------------------------------------------------------------
        # 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
コード例 #8
0
ファイル: organisation.py プロジェクト: RawPlutonium/scs_osio
    # ----------------------------------------------------------------------------------------------------------------
    # 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 = OrganisationManager(HTTPClient(), api_auth.api_key)

    # check for existing registration...
    org = manager.find(cmd.org_id)

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

    if cmd.set():
        if org:
            name = org.name if cmd.name is None else cmd.name
            website = org.website if cmd.website is None else cmd.website
            description = org.description if cmd.description is None else cmd.description
            email = org.email if cmd.email is None else cmd.email

            # update Organisation...
コード例 #9
0
        # APIAuth...
        api_auth = APIAuth.load(Host)

        if api_auth is None:
            print("aws_topic_history: APIAuth not available.", file=sys.stderr)
            exit(1)

        if cmd.verbose:
            print("aws_topic_history: %s" % api_auth, file=sys.stderr)

        # reporter...
        reporter = AWSTopicHistoryReporter(cmd.verbose)

        # byline manager...
        byline_manager = BylineManager(HTTPClient(), api_auth)

        # message manager...
        message_manager = MessageManager(HTTPClient(), api_auth, reporter)

        if cmd.verbose:
            print("aws_topic_history: %s" % message_manager, file=sys.stderr)
            sys.stderr.flush()

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

        # start / end times...
        if cmd.latest:
            byline = byline_manager.find_latest_byline_for_topic(cmd.topic)
コード例 #10
0
    cmd = CmdAFECalib()

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

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

    if cmd.set():
        if cmd.test:
            jstr = AFECalib.TEST_JSON

        else:
            client = HTTPClient()
            client.connect(AFECalib.HOST)

            try:
                path = AFECalib.PATH + cmd.serial_number
                jstr = client.get(path, None, AFECalib.HEADER)

            finally:
                client.close()

        jdict = json.loads(jstr, object_pairs_hook=OrderedDict)

        calib = AFECalib.construct_from_jdict(jdict)

        if calib is not None:
            calib.save(Host)
コード例 #11
0
print(api_key)

topic = "/orgs/south-coast-science-dev/exhibition/loc/1/climate"
print(topic)

end_date = LocalizedDatetime.now()
start_date = LocalizedDatetime.construct_from_timestamp(end_date.timestamp() -
                                                        60)

print("start: %s" % start_date)
print("end: %s" % end_date)

print("-")

# --------------------------------------------------------------------------------------------------------------------

# manager...
manager = MessageManager(HTTPClient(), api_key)
print(manager)
print("=")

messages = manager.find_for_topic(topic, start_date, end_date)

print("got:%d" % (len(messages)))
print("-")

for message in messages:
    print(message)

print("-")
コード例 #12
0
        # ------------------------------------------------------------------------------------------------------------
        # 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)
コード例 #13
0
    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...
http_client = HTTPClient()

manager = DeviceManager(http_client, api_auth.api_key)

print(manager)
print("-")


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

print("find:")
device = manager.find(api_auth.org_id, client_auth.client_id)

print(device)
print("-")
コード例 #14
0
ファイル: aws_byline.py プロジェクト: tim-seoss/scs_analysis
    try:
        # ------------------------------------------------------------------------------------------------------------
        # resources...

        # APIAuth...
        api_auth = APIAuth.load(Host)

        if api_auth is None:
            print("aws_byline: APIAuth not available.", file=sys.stderr)
            exit(1)

        if cmd.verbose:
            print("aws_byline: %s" % api_auth, file=sys.stderr)

        # byline manager...
        manager = BylineManager(HTTPClient(), api_auth)

        if cmd.verbose:
            print("aws_byline: %s" % manager, file=sys.stderr)
            sys.stderr.flush()

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

        latest = None

        try:
            # get...
            if cmd.topic:
                bylines = manager.find_bylines_for_topic(cmd.topic)