示例#1
0
            if cmd.user_id:
                print("osio_client_auth: Device owner-id cannot be updated.", file=sys.stderr)
                exit(1)

            # update Device...
            updated = ProjectClient.update(device, cmd.description, tags)
            device_manager.update(api_auth.org_id, device.client_id, updated)

            # find updated device...
            device = device_manager.find(api_auth.org_id, device.client_id)

        else:
            # create Device...
            device = ProjectClient.create(Host.name(), api_auth, cmd.description, tags)
            device = device_manager.create(cmd.user_id, device)

            # create ClientAuth...
            client_auth = ClientAuth(cmd.user_id, device.client_id, device.password)

            client_auth.save(Host)

    else:
        # find ClientAuth...
        client_auth = ClientAuth.load(Host)


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

    print(JSONify.dumps(client_auth))
示例#2
0

# TODO: upgrade this, to take client_id explicitly

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

if __name__ == '__main__':

    # ----------------------------------------------------------------------------------------------------------------
    # cmd...

    cmd = CmdClientAuth()

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


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

    if cmd.set():
        auth = ClientAuth(cmd.user_id, cmd.client_id, cmd.client_password)
        auth.save(Host)

    else:
        # find self...
        auth = ClientAuth.load(Host)

    print(JSONify.dumps(auth))