nchah / github-traffic-stats

Get statistics on web traffic to your GitHub repositories.
https://pypi.org/project/github-traffic-stats/
121 stars 31 forks source link

Bad credentials #5

Closed 29988122 closed 7 years ago

29988122 commented 7 years ago

I already installed requests package.

But, for example, when I executed python github-traffic-stats.py '29988122' 'ALL' 'save_csv' and provided password, I got Bad credentials response. On the repo traffic page, I can view them without any issue.

Does this mean that I need to give permission to github api or what? Thank you for your project!

nchah commented 7 years ago

Hello,

I tried to test it out but I didn't get a "Bad credentials" response. Do you think it could be from a failed login attempt? It can sometimes be hard to see what password you're typing on the command line since there's no indicator. https://developer.github.com/v3/#failed-login-limit

29988122 commented 7 years ago

It was my environment's problem..whether it's incomplete install of requests or python 2/3. I tried a clean VM, and your script worked very well.

Sorry for taking your time, I ignored basic things!

29988122 commented 7 years ago

Sorry for asking another question: Is this error due to non-ascii path?

Traceback (most recent call last): File "github-traffic-stats.py", line 277, in main(args.username, args.repo, args.save_csv) File "github-traffic-stats.py", line 267, in main store_csv(csv_file_name, repo, traffic_response, 'views') File "github-traffic-stats.py", line 206, in store_csv with open(file_path, 'a') as csvfile: IOError: [Errno 2] No such file or directory: '/home/a29988122/\xe6\xa1\x8c\xe9\x9d\xa2/github-traffic-stats/data/2017-09-13-01h-09m-traffic-stats.csv'

EDIT: I changed desktop path name, and it's like this: Traceback (most recent call last): File "github-traffic-stats.py", line 277, in main(args.username, args.repo, args.save_csv) File "github-traffic-stats.py", line 267, in main store_csv(csv_file_name, repo, traffic_response, 'views') File "github-traffic-stats.py", line 206, in store_csv with open(file_path, 'a') as csvfile: IOError: [Errno 2] No such file or directory: '/home/a29988122/Desktop/github-traffic-stats/data/2017-09-13-01h-29m-traffic-stats.csv'

Sorry I'm a noob on this...it might seem easy to you, but I sucked : (

nchah commented 7 years ago

No worries!! Everyone is learning something new :) Could you tell me what directory you are running the script from and also what are you typing on the command line?:

29988122 commented 7 years ago

Thank you!

It was under ~/Desktop/github-traffic-stats/python (or should I write /home/a29988122/Desktop/github-traffic-stats/python ?)

And I executed: sudo python github-traffic-stats.py '29988122' 'Fate-Grand-Order_Lua' 'save_csv'

The results are the same with or without sudo. Python 2.7 I guess, linux mint 18.2 Fresh new install.

Password:
> Fate-Grand-Order_Lua - Visitors
Date        Views   Unique visitors
Totals      1026    149
2017-08-29  1   1
2017-08-30  99  19
2017-08-31  33  15
2017-09-01  67  17
2017-09-02  55  13
2017-09-03  23  9
2017-09-04  44  9
2017-09-05  29  10
2017-09-06  54  7
2017-09-07  65  12
2017-09-08  65  11
2017-09-09  31  11
2017-09-10  246 58
2017-09-11  165 22
2017-09-12  49  13

> Fate-Grand-Order_Lua - Git clones
Date        Clones  Unique cloners
Totals      4   4
2017-09-01  2   2
2017-09-02  2   2

> Fate-Grand-Order_Lua - Referring sites
Date        Views   Unique visitors
Totals      327 64
github.c... 248 38 
ptt.cc      56  14 
Google      13  5 
ankulua-... 4   3 
translat... 3   2 
l.facebo... 2   1 
medium.c... 1   1 

Traceback (most recent call last):
  File "github-traffic-stats.py", line 277, in <module>
    main(args.username, args.repo, args.save_csv)
  File "github-traffic-stats.py", line 267, in main
    store_csv(csv_file_name, repo, traffic_response, 'views')
  File "github-traffic-stats.py", line 206, in store_csv
    with open(file_path, 'a') as csvfile:
IOError: [Errno 2] No such file or directory: '/home/a29988122/Desktop/github-traffic-stats/data/2017-09-13-01h-30m-traffic-stats.csv'
nchah commented 7 years ago

Okay, I could replicate it. If I copied just the "github-traffic-stats.py" script into a completely new folder and ran it I got the same error.

Try to make sure that a directory like "/home/a29988122/Desktop/github-traffic-stats/data/" exists.

Or to explain what the code does now, if your current directory is "/home/user/my/folder/" and the script is at "/home/user/my/folder/github-traffic-stats.py" then try to make sure there is a "/home/user/my/folder/data/" directory. The script tries to save the CSV with that logic.

29988122 commented 7 years ago

Okay, it's due to the fact that I directly cloned your repo, and there's no /data folder in it, only sample-data. The problem's exactly as you said, solved after I manually created /data folder!

Thank you for your work, it helped a lot. (now I can brag about visitor count on my resume.. XD )

nchah commented 7 years ago

Great! Glad it worked out =)