11
11
import sys
12
12
from enum import Enum
13
13
14
-
14
+ # Set up basic logger
15
15
logger = logging .getLogger ('pingdom.pingdomWrapper' )
16
- handler = logging .StreamHandler (sys .stdout )
17
- logger .addHandler (handler )
16
+
17
+ # Setup stdout logger
18
+ soh = logging .StreamHandler (sys .stdout )
19
+ # Can optionally set logging levels per handler
20
+ # soh.setLevel(logging.WARN)
21
+ logger .addHandler (soh )
22
+
23
+ # File handler for logging to a file
24
+ # fh = logging.FileHandler('apiWrapper.log')
25
+ # fh.setLevel(logging.DEBUG)
26
+ # logger.addHandler(fh)
18
27
19
28
# Get log level from env vars
20
29
log_level = os .environ .get ('LOG_LEVEL' , 'INFO' ).upper ()
@@ -46,7 +55,8 @@ def __init__(
46
55
client_app_secret = None ,
47
56
user_oauth_token = None ,
48
57
user_oauth_token_secret = None ,
49
- api_app_key = None
58
+ api_app_key = None ,
59
+ auth_type = None
50
60
):
51
61
'''Set up client for API communications
52
62
This is where you'll need to specify all the authentication and
@@ -67,7 +77,8 @@ def __init__(
67
77
# If interested in using a config file instead of env vars, load with
68
78
# self._load_key(config_key, path)
69
79
# Feel free to clear out auth methods not implemented by the API
70
- auth_type = AuthType [os .getenv ('AUTHTYPE' , default = 'NONE' )]
80
+ if not auth_type :
81
+ auth_type = AuthType [os .getenv ('AUTHTYPE' , default = 'NONE' )]
71
82
if (auth_type == AuthType .HTTPBASICAUTH or
72
83
auth_type == AuthType .HTTPDIGESTAUTH ):
73
84
if not user :
@@ -343,7 +354,11 @@ def create_new_maintenance_window(
343
354
344
355
345
356
if __name__ == "__main__" :
346
- account = Pingdom (
'[email protected] ' ,
'password' )
357
+ account = Pingdom (
358
+
359
+ 'password' ,
360
+ auth_type = AuthType .HTTPBASICAUTH
361
+ )
347
362
from_datetime = datetime .now ()
348
363
to_datetime = datetime .now () + timedelta (1 )
349
364
account .list_checks ()
0 commit comments