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

Keep getting message to generate my token... #2

Closed
tallship opened this issue May 4, 2016 · 8 comments
Closed

Keep getting message to generate my token... #2

tallship opened this issue May 4, 2016 · 8 comments

Comments

@tallship
Copy link

tallship commented May 4, 2016

After installing the cloudboard.vim plugin with Vundle and activating it, I generated my token at github.

The permissions I gave it were for "repo" and "gist".

After that I open Vim and do a:

:CBInit

Then I receive the message:

To use CloudBoard, you must generate your personal access token (https://github.com/settings/tokens), then input it here:

I input my personal access token and get an error that reads:

TypeError: string indices must be integers

Here's what the output looks like in my terminal: http://screencast.com/t/hATIZTiGWej

Is this because I need to check more options other than just the four checkboxes in the 'repo' section and the 'gist' section of the token creation section at github? Or is this the result of some other error?

Thanks! 👍
cloudboard vim-fail

@tallship
Copy link
Author

tallship commented May 4, 2016

I tried updating my token by selecting and enabling all checkboxes, thereby providing the token access to do anything/everything. After a :CBInit and entering the token again I now receive the following error:

TypeError: 'NoneType' object has no attribute '__getitem__'

This would truly be a great plugin if I can just get it to work, cutting and pasting from one machine to another via a cloud-based clipboard and file store.

Any ideas where I should look from here?

Here's the system:

Vim 7.4.1530
Linux hammer 4.4.0 #1 SMP Mon Jan 11 22:25:06 CST 2016 x86_64 AMD Opteron(tm) Processor 6128 AuthenticAMD GNU/Linux
Python 2.7.11

@brookhong
Copy link
Owner

Only check on gist is enough to go.

It seems that gist API returned something unexpected, could you please add below line at cloudboard.py:35 to print out the response from https://api.github.com/gists?

print gists

@tallship
Copy link
Author

tallship commented May 4, 2016

Here's what I got after adding/inserting:

print gists

after line 35 in ~/.vim/bundle/cloudboard.vim/plugin/cloudboard.py

http://screencast.com/t/5oL9S5DPl

cloudboard vim-fail

@tallship
Copy link
Author

tallship commented May 4, 2016

Or perhaps this is what you wanted to see?

http://awesomescreenshot.com/04e5ucacc0

Let me know because it seems to be a really great plugin if I can just get it to work 👍

cloudboard vim-fail

@brookhong
Copy link
Owner

I did not see anything wrong in the response from https://api.github.com/gists. To debug the issue, save below snippet as a file t.py, run python t.py <your_token_here>.

import base64, os, sys
import urllib, urllib2, json

def request(url, headers, data=None, httpErrorHandler=None, json_decode=True):
    req = urllib2.Request(url, data)
    for k in headers.keys():
        req.add_header(k, headers[k])
    try:
        response = urllib2.urlopen(req)
        jstr = response.read()
    except urllib2.HTTPError, e:
        jstr = '{"error": "%s"}' % e
        if httpErrorHandler:
            httpErrorHandler(e)
    except urllib2.URLError, e:
        jstr = '{"error": "%s"}' % e
    ret = jstr
    if json_decode:
        ret = json.loads(jstr)
    return ret

reload(sys)
sys.setdefaultencoding('utf8')

gists = request('https://api.github.com/gists', {'Authorization': 'token %s' % sys.argv[1]})
for g in gists:
    print g['description'][:10]
    print g['files']

@tallship
Copy link
Author

tallship commented May 4, 2016

Thanks Brook!

Here's what I got when running that script:

$ python ./t.py 5f6285f749072a20b12e207eb4b6f4a1d9bf084b
Install tm
{u'install_tmux_centos6.sh': {u'size': 830, u'raw_url': u'https://gist.githubusercontent.com/tallship/5119391/raw/12ec5ded22188802b66b0f981b27243f00c9152b/install_tmux_centos6.sh', u'type': u'application/x-sh', u'language': u'Shell', u'filename': u'install_tmux_centos6.sh'}}
Traceback (most recent call last):
  File "./t.py", line 27, in <module>
    print g['description'][:10]
TypeError: 'NoneType' object has no attribute '__getitem__'

I went and generated another token after this so not to worry about the one above.

@brookhong brookhong reopened this May 5, 2016
@brookhong
Copy link
Owner

This commit 2032a76 should fix the issue, please have a try.

@tallship
Copy link
Author

tallship commented May 5, 2016

Yes, it works flawlessly now - and this is going to be an invaluable tool keeping files up and ready to paste into vim for quick deployments, etc.

Thank you so much for addressing this and the fix Brook!

@tallship tallship closed this as completed May 5, 2016
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

2 participants