list_sesames.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 
5 import argparse
6 import os.path as osp
7 import pprint
8 import sys
9 
10 import requests
11 
12 
13 def list_sesames(auth_token):
14  if osp.isfile(osp.expanduser(auth_token)):
15  with open(osp.expanduser(auth_token), 'r') as f:
16  auth_token = f.readline().rstrip()
17 
18  ret = requests.get(
19  'https://api.candyhouse.co/public/sesames',
20  headers={'Authorization': auth_token})
21  if ret.status_code == 200:
22  pprint.pprint(ret.json())
23  else:
24  print('[HTTP status code: {}]\n'
25  '{}\n'
26  'No Sesames found.'.format(
27  ret.status_code, ret.text), file=sys.stderr)
28 
29 
30 if __name__ == '__main__':
31  parser = argparse.ArgumentParser()
32  parser.add_argument(
33  'auth_token', type=str,
34  help='Your authorization token or path to its file.')
35  args = parser.parse_args()
36 
37  list_sesames(args.auth_token)
def list_sesames(auth_token)
Definition: list_sesames.py:13


sesame_ros
Author(s): Yuto Uchimi
autogenerated on Tue May 11 2021 02:55:52