##// END OF EJS Templates
integrations: extract get_auth to common shared code.
marcink -
r2577:39fd91d9 default
parent child Browse files
Show More
@@ -111,3 +111,15 b' class EEIntegration(IntegrationTypeBase)'
111 def __init__(self, name, key, settings=None):
111 def __init__(self, name, key, settings=None):
112 self.display_name = name
112 self.display_name = name
113 self.key = key
113 self.key = key
114 super(EEIntegration, self).__init__(settings)
115
116
117 # Helpers
118
119 def get_auth(settings):
120 from requests.auth import HTTPBasicAuth
121 username = settings.get('username')
122 password = settings.get('password')
123 if username and password:
124 return HTTPBasicAuth(username, password)
125 return None
@@ -33,7 +33,7 b' from requests.packages.urllib3.util.retr'
33 import rhodecode
33 import rhodecode
34 from rhodecode import events
34 from rhodecode import events
35 from rhodecode.translation import _
35 from rhodecode.translation import _
36 from rhodecode.integrations.types.base import IntegrationTypeBase
36 from rhodecode.integrations.types.base import IntegrationTypeBase, get_auth
37 from rhodecode.lib.celerylib import run_task, async_task, RequestContextTask
37 from rhodecode.lib.celerylib import run_task, async_task, RequestContextTask
38
38
39 log = logging.getLogger(__name__)
39 log = logging.getLogger(__name__)
@@ -64,15 +64,6 b' WEBHOOK_URL_VARS = ['
64 URL_VARS = ', '.join('${' + x + '}' for x in WEBHOOK_URL_VARS)
64 URL_VARS = ', '.join('${' + x + '}' for x in WEBHOOK_URL_VARS)
65
65
66
66
67 def get_auth(settings):
68 from requests.auth import HTTPBasicAuth
69 username = settings.get('username')
70 password = settings.get('password')
71 if username and password:
72 return HTTPBasicAuth(username, password)
73 return None
74
75
76 class WebhookHandler(object):
67 class WebhookHandler(object):
77 def __init__(self, template_url, secret_token, headers):
68 def __init__(self, template_url, secret_token, headers):
78 self.template_url = template_url
69 self.template_url = template_url
General Comments 0
You need to be logged in to leave comments. Login now