Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. def auth():
  2. global url
  3. global aParams
  4. with open('token.txt', 'r') as data:
  5. load = json.load(data)
  6. loaded = load['tstmp']
  7. print('__', loaded)
  8. if int(datetime.datetime.now().strftime('%s')) - int(loaded) >= 900:
  9. print('old token:', load['key'])
  10. return load['key']
  11. else:
  12. with open('token.txt', 'w') as data:
  13. get_token = requests.get(url + '/api/auth', params=aParams).text
  14. timestamp = int(datetime.datetime.now().strftime('%s'))
  15. load = json.dump({'key': get_token, 'tstmp': timestamp}, data)
  16. print('new token', load['key'])
  17. return load['key']
  18.  
  19. Traceback (most recent call last):
  20. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/getreport.py", line 61, in <module>
  21. token = str(auth())
  22. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/getreport.py", line 56, in auth
  23. print('new token', load['key'])
  24. TypeError: 'NoneType' object is not subscriptable
  25.  
  26. Process finished with exit code 1
  27.  
  28. "/Volumes/My Files/Python/slack/slackenv/bin/python" "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/iiko/getreport.py"
  29. __ 1469428422
  30. Traceback (most recent call last):
  31. old token: 243c2e38-f329-aeda-4d03-4a631f247415
  32. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/iiko/getreport.py", line 85, in <module>
  33. <function auth at 0x101a7ad08>
  34. get_report(t=auth())
  35. __ 1469428422
  36. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/iiko/getreport.py", line 77, in get_report
  37. old token: 243c2e38-f329-aeda-4d03-4a631f247415
  38. r = requests.get(reportUrl, cookies=str(token)).json()
  39. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/requests/api.py", line 71, in get
  40. return request('get', url, params=params, **kwargs)
  41. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/requests/api.py", line 57, in request
  42. return session.request(method=method, url=url, **kwargs)
  43. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/requests/sessions.py", line 461, in request
  44. prep = self.prepare_request(req)
  45. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/requests/sessions.py", line 371, in prepare_request
  46. cookies = cookiejar_from_dict(cookies)
  47. File "/Volumes/My Files/Python/slack/slackenv/lib/python3.5/site-packages/requests/cookies.py", line 469, in cookiejar_from_dict
  48. cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
  49. TypeError: string indices must be integers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement