Closed dapper-hacker closed 4 years ago
RESOLVED:
I had to change line 32
if db.get(timestamp) is None:
to
if db.get(timestamp) is False:
I think it was never inserting any data while running the script for the first time and directly going into the else condition which invoked
db_data = json.loads(db.get(timestamp))
But there was no value in the db.
Thanks for looking into this!
Will you consider creating a PR with the fix?
btw, I'd go with something like if db.get(timestamp) is None or db.get(timestamp) is False
to cover both options
Good Suggestion, will add it. Will create the pull request.
I've just upgraded github-traffic-stats to Python 3 and fixed this issue also.
Hi, I am trying to run the code with python 2.7 on my mac. When I am running the script, I get this error.
Vinayaks-MacBook-Pro:github-traffic-stats$ python github_traffic_stats.py -t xxxxxxxxxxxxxxxxxxxxxx -o IBM -r db2-samples -c collect Traceback (most recent call last): File "github_traffic_stats.py", line 102, in
main()
File "github_traffic_stats.py", line 99, in main
collect(db=db, user=args.github_user, passwd=args.github_password, token=args.github_access_token, repo=a
rgs.github_repo, org=args.github_org)
File "github_traffic_stats.py", line 39, in collect
db_data = json.loads(db.get(timestamp))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 339, i
n loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
Based on my evaluation, I can fetch the data for traffic and print it properly until it goes into this code snippet for loading it into pickledb:
Perhaps the github json response has changed?