Skip to content

Commit ad18ec4

Browse files
authored
Merge branch 'master' into aliasmrchips-patch-1
2 parents 89fc822 + 9b25ae9 commit ad18ec4

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

descarteslabs/scripts/descarteslabs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import getpass
2323

2424
from descarteslabs.auth import Auth, base64url_decode
2525

26+
import descarteslabs as dl
27+
2628
if __name__ == "__main__":
2729

2830
parser = argparse.ArgumentParser()
@@ -35,10 +37,9 @@ if __name__ == "__main__":
3537

3638
if args.command == 'login':
3739

38-
print(
39-
'Follow this link to login: https://iam.descarteslabs.com/auth/login?refresh_token=true&destination=/auth/refresh_token')
40+
print('Follow this link to login https://iam.descarteslabs.com/auth/login?refresh_token=true&destination=/auth/refresh_token')
4041

41-
s = getpass.getpass('...then come back and paste the generated token here: ')
42+
s = raw_input('...then come back here and paste the generated token: ')
4243

4344
if s:
4445

@@ -58,18 +59,36 @@ if __name__ == "__main__":
5859

5960
os.chmod(file, stat.S_IRUSR | stat.S_IWUSR)
6061

62+
keys = dl.metadata.keys()
63+
64+
name = auth.payload['name']
65+
groups = ', '.join(auth.payload['groups'])
66+
67+
if len(keys):
68+
69+
print('Welcome, %s!' % name)
70+
71+
else:
72+
73+
print('Welcome, %s! Your %s role(s) do not permit access to any imagery at this time.' % (name, groups))
74+
print('Contact [email protected] if you believe you received this message in error or have any questions.')
75+
76+
if args.command == 'token':
77+
print(auth.token)
78+
6179
if args.command == 'name':
80+
auth.token
6281
print(auth.payload['name'])
6382

6483
if args.command == 'groups':
84+
auth.token
6585
print(json.dumps(auth.payload['groups']))
6686

67-
if args.command == 'token':
68-
print(auth.token)
69-
7087
if args.command == 'payload':
88+
auth.token
7189
print(auth.payload)
7290

7391
if args.command == 'env':
92+
auth.token
7493
print('%s=%s' % ('CLIENT_ID', auth.client_id))
7594
print('%s=%s' % ('CLIENT_SECRET', auth.client_secret))

0 commit comments

Comments
 (0)