Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't work plugin #5

Closed
shcoderAlex opened this issue Apr 8, 2014 · 5 comments
Closed

don't work plugin #5

shcoderAlex opened this issue Apr 8, 2014 · 5 comments

Comments

@shcoderAlex
Copy link

CrunchBang, sublimetext 3

Traceback (most recent call last):
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello.py", line 100, in
sublime.set_timeout_async(lambda: self.call(fn, progress), delay)
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello.py", line 103, in call
fn()
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello.py", line 26, in
self.defer(lambda: self.work(trello_connection))
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello_navigate.py", line 10, in work
BoardOperation(connection.me).execute(self)
File "/home/alex/.config/sublime-text-3/Packages/Trello/executable.py", line 6, in execute
self.command.display(self.items(), self.callback)
File "/home/alex/.config/sublime-text-3/Packages/Trello/operations.py", line 23, in items
self.set_collection()
File "/home/alex/.config/sublime-text-3/Packages/Trello/operations.py", line 27, in set_collection
self.collection = TrelloCollection(self.trello_element, self.trello_element_property())
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello_collection.py", line 3, in init
if hasattr(trello_element, attr):
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/trollop/lib.py", line 207, in get
data = json.loads(instance._conn.get(path))
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/trollop/lib.py", line 44, in get
return self.request('GET', path, params)
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/trollop/lib.py", line 40, in request
response.raise_for_status()
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/requests/models.py", line 686, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: None

@nicosantangelo
Copy link
Owner

Hmm, Trello responds with HTTPError: 401 (Unauthorized) when the token isn't correct. Maybe the token is missing some character?

If you're using the default app, try removing your token from the settings (Preferences -> Package Settings -> Trello -> Settings - User) like this:

{
    "token": ""
}

and running the plugin again. That will prompt the token URL so you can copy it in your browser and get the token again.

If you're using a custom app, make sure your key and secret are present, like this (the values are not real):

{
    "key"   : "4035637bf0cc1afe60cd62795839999",
    "secret": "22da22634e63c6b73dfe126f1b177e1e03e73d74f93980dc4cb650c9a899999",
    "token": "e5d85f0aa6cad0a8141696ab865bff73ba0f09568c0ef50cf79aac9b72899999"
}

Another option is that the app isn't authorized, to check this, go to: https://trello.com/{YOURUSERNAME}/account. If you scroll down to Applications you should see sublime_app or the name of your custom app.
If it isn't there, try deleting your token as explained above, and make sure that the app is granted permissions (when the, generally green, Authorize button appears).

(I'll add a nicer message to this error when I have the time :), thanks for the report)

@hc12
Copy link

hc12 commented Apr 10, 2014

I managed to fix the issue by switching the priority of user settings to override default settings.
Replacing line 32 & 33 in trello.py with the following should work:

        self.key    = user_settings.get("key") or default_settings.get("key")
        self.secret = user_settings.get("secret") or default_settings.get("secret")

The default settings has a default key & secret which are invalid.

PS: Anyway to batch create cards with description?
I've modified the operations.py to include batch of cards:

class CardOperation(BaseOperation):
    def after_init(self):
        self.custom_actions.remove("Open in Browser")
        self.custom_actions.rename("Create Card", "Quick create card")
        self.custom_actions.add("Create card with description", self.create_with_description)

    def trello_element_property(self):
        return "cards"

    def next_operation_class(self):
        return CardOptions

    def create_with_description(self):
        message = "Replace this with the card name\n\nReplace this with the card description (the card will be saved when this tab is closed, leave empty to cancel)"
        self.command.output_editable(message, self)

    def full_add(self, content):
        for card in self.split_cards(content):
            name, description = self.split_card_contents(card)
            self.add(name, description)
        self.restart()

    def add(self, text, description = None):
        self.trello_element.add_card(text, description)

    def split_cards(self, content):
        return content.split("##\n")

    def split_card_contents(self, content):
        splitted = content.split("\n\n", 1)
        return (splitted[0], splitted[1] if len(splitted) > 1 else None)

@nicosantangelo
Copy link
Owner

Thanks a lot for checking out the settings bug, sorry if I wasn't very helpful.

I'll take a look to the batch creation in a little while :), if you want to fork the project to submit a pull request, you're more than welcome.

Thanks again.

@hc12
Copy link

hc12 commented Apr 11, 2014

No worries Nico. I'm still rather new to Git & Github, haven't had the time to learn the Git API yet.

I will fork the project when time permits but no guarantee ;P

Keep up the good work, i like what you've done so far.

@nicosantangelo
Copy link
Owner

Thanks :)

I didn't get a chance to look at your code today, I'll close this issue and add another one for the batch of cards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants