88from six .moves import input
99
1010argv_iter = iter (sys .argv [1 :])
11- def get_next_arg (prompt ):
11+
12+
13+ def get_next_input (prompt ):
14+ """Collect user input from terminal and return it."""
1215 try :
1316 return next (argv_iter )
1417 except StopIteration :
1518 return input (prompt )
1619
20+
1721def human_time (time : int ) -> str :
1822 """Translate unix time into human readable string"""
1923 if time is None :
2024 date_str = 'Never'
2125 else :
22- date_str = datetime .fromtimestamp (time , timezone .utc ).strftime ("%Y-%m-%m %H:%M:%S" )
26+ date_str = datetime .fromtimestamp (time , timezone .utc ).strftime ("%Y-%m-%m %H:%M:%S" )
2327 return date_str
2428
2529
2630# Configuration and information about objects to create.
27- """
2831admin_api = duo_client .Admin (
29- ikey=get_next_input('Admin API integration key ("DI..."): '),
30- skey=get_next_input('integration secret key: '),
31- host=get_next_input('API hostname ("api-....duosecurity.com"): '),
32- )
33- """
32+ ikey = get_next_input ('Admin API integration key ("DI..."): ' ),
33+ skey = get_next_input ('integration secret key: ' ),
34+ host = get_next_input ('API hostname ("api-....duosecurity.com"): ' ), )
3435
35- admin_api = duo_client .Admin (
36- ikey = 'DIW9XT14VIIAH3L427I8' ,
37- skey = '8iQEKjOCxjjvwYKFZ77ztkcd60c7aToMlf8zZiDs' ,
38- host = 'api-731c6826.duosecurity.com'
39- )
4036# Retrieve user info from API:
4137users = admin_api .get_users ()
4238
4339print (f'{ "Username" :^30} { "Last Login" :^20} { "User Enrolled" } ' )
44- print (f'{ "=" * 30 } { "=" * 20 } { "=" * 15 } ' )
40+ print (f'{ "=" * 30 } { "=" * 20 } { "=" * 15 } ' )
4541for user in users :
4642 line_out = f"{ user ['username' ]:30} "
4743 line_out += f"{ human_time (user ['last_login' ]):20} "
4844 line_out += f" { user ['is_enrolled' ]} "
49- print (line_out )
45+ print (line_out )
0 commit comments