Total Complexity | 4 |
Total Lines | 28 |
Duplicated Lines | 0 % |
1 | #!/usr/bin/env python |
||
22 | class Ping(Action): |
||
23 | def run(self): |
||
24 | """ |
||
25 | Ping the Duo Platorm. |
||
26 | |||
27 | Returns: An dict with info returned by Duo. |
||
28 | |||
29 | Raises: |
||
30 | ValueError: On Auth Failure. |
||
31 | """ |
||
32 | |||
33 | try: |
||
34 | ikey = self.config['auth']['ikey'] |
||
35 | skey = self.config['auth']['skey'] |
||
36 | host = self.config['auth']['host'] |
||
37 | except KeyError: |
||
38 | raise ValueError("Duo config not found in config.") |
||
39 | |||
40 | auth = duo_client.Auth(ikey=ikey, |
||
41 | skey=skey, |
||
42 | host=host) |
||
43 | |||
44 | try: |
||
45 | data = auth.ping() |
||
46 | except: |
||
47 | raise ValueError("Ping failed!") |
||
48 | else: |
||
49 | return data |
||
50 |