halcy / Mastodon.py

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
MIT License
876 stars 150 forks source link

AttributeError: 'tuple' object has no attribute 'startswith' #346

Closed mispp closed 1 year ago

mispp commented 1 year ago

Found a possible bug: making a bot in the same VM as the gotosocial instance and connecting locally via http.

Traceback (most recent call last): File "/opt/bot/scripts/./bot-01-define-app.py", line 10, in Mastodon.create_app( File "/home/bot/.local/lib/python3.10/site-packages/mastodon/authentication.py", line 50, in create_app api_base_url = Mastodon.protocolize(api_base_url) File "/home/bot/.local/lib/python3.10/site-packages/mastodon/internals.py", line 646, in protocolize if not base_url.startswith("http://") and not base_url.startswith("https://"):

halcy commented 1 year ago

Hm! Could you post the code you are running? What does the full call to create_app look like?

mispp commented 1 year ago
#!/bin/python3

import argparse

from mastodon import Mastodon

api_base_url = 'http://localhost:8080',
bot_clientcred = 'bot_clientcred.secret'

Mastodon.create_app(
    'bot',
    api_base_url = api_base_url,
    to_file = bot_clientcred
)
codl commented 1 year ago

you have a stray comma on the line

api_base_url = 'http://localhost:8080',

which makes it equivalent to

api_base_url = ('http://localhost:8080', )

please remove the comma and try again

mispp commented 1 year ago

thanks @codl

i cant believe i missed that...