-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
47 lines (33 loc) · 1.19 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import logging
import sys
import os
import atlassian
import zdesk
def setup_logging():
root = logging.getLogger()
root.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
root.addHandler(ch)
setup_logging()
def get_conf_opt(name, default=None):
try:
return os.environ[name]
except KeyError:
if default is not None:
return default
raise Exception("{} env var must be set. See README.".format(name))
CONFLUENCE_URL = get_conf_opt('CONFLUENCE_URL')
CONFLUENCE_USER = get_conf_opt('CONFLUENCE_USER')
CONFLUENCE_PASSWORD = get_conf_opt('CONFLUENCE_PASSWORD')
CREATE_AS_DRAFT = (get_conf_opt('CREATE_AS_DRAFT', "0") == "1")
ZENDESK_URL = get_conf_opt('ZENDESK_URL')
ZENDESK_EMAIL = get_conf_opt('ZENDESK_EMAIL')
ZENDESK_PASSWORD = get_conf_opt('ZENDESK_PASSWORD')
def confluence():
return atlassian.Confluence(CONFLUENCE_URL, CONFLUENCE_USER,
CONFLUENCE_PASSWORD)
def zendesk():
return zdesk.Zendesk(ZENDESK_URL, ZENDESK_EMAIL, ZENDESK_PASSWORD)