コード例 #1
0
ファイル: commands.py プロジェクト: mugcake/toot
def instance(app, user, args):
    name = args.instance or (app and app.instance)
    if not name:
        raise ConsoleError("Please specify instance name.")

    assert_domain_exists(name)

    try:
        instance = api.get_instance(name, args.scheme)
        print_instance(instance)
    except NotFoundError:
        raise ConsoleError(
            "Instance not found at {}.\n"
            "The given domain probably does not host a Mastodon instance.".
            format(name))
コード例 #2
0
ファイル: auth.py プロジェクト: SteelPangolin/toot
def register_app(domain, scheme='https'):
    print_out("Looking up instance info...")
    instance = api.get_instance(domain)

    print_out(
        "Found instance <blue>{}</blue> running Mastodon version <yellow>{}</yellow>"
        .format(instance['title'], instance['version']))

    try:
        print_out("Registering application...")
        response = api.create_app(domain, scheme)
    except ApiError:
        raise ConsoleError("Registration failed.")

    base_url = scheme + '://' + domain

    app = App(domain, base_url, response['client_id'],
              response['client_secret'])
    config.save_app(app)

    print_out("Application tokens saved.")

    return app
コード例 #3
0
ファイル: app.py プロジェクト: rosenkreuzer233/toot
 def _load_instance():
     return api.get_instance(self.app.instance)