diff --git a/src/main/resources/caflowdock/FlowdockHelper.py b/src/main/resources/caflowdock/FlowdockHelper.py index 5a5e3ef..2ee9bc5 100644 --- a/src/main/resources/caflowdock/FlowdockHelper.py +++ b/src/main/resources/caflowdock/FlowdockHelper.py @@ -8,6 +8,8 @@ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +import os + class FlowdockHelper(object): def __init__(self): @@ -16,3 +18,9 @@ def __init__(self): @staticmethod def get_token(variables): return variables['flowToken'] if variables['flowToken'] else variables['flowdockServer']["flowToken"] + + @staticmethod + def set_proxy(variables): + if variables['flowdockServer']['proxyHost']: + os.environ["HTTP_PROXY"] = "http://%s:%s" % (variables['flowdockServer']['proxyHost'], variables['flowdockServer']['proxyPort']) + os.environ["HTTPS_PROXY"] = "https://%s:%s" % (variables['flowdockServer']['proxyHost'], variables['flowdockServer']['proxyPort']) diff --git a/src/main/resources/caflowdock/SendTeamInboxMessage.py b/src/main/resources/caflowdock/SendTeamInboxMessage.py index 199c1af..8831933 100644 --- a/src/main/resources/caflowdock/SendTeamInboxMessage.py +++ b/src/main/resources/caflowdock/SendTeamInboxMessage.py @@ -9,12 +9,10 @@ # import flowdock -import os from caflowdock.FlowdockHelper import FlowdockHelper -os.environ["HTTP_PROXY"] = "http://%s:%s" % (flowdockServer['proxyHost'], flowdockServer['proxyPort']) -os.environ["HTTPS_PROXY"] = "https://%s:%s" % (flowdockServer['proxyHost'], flowdockServer['proxyPort']) +FlowdockHelper.set_proxy(locals()) api_key = FlowdockHelper.get_token(locals()) fdclient = flowdock.FlowDock(api_key=api_key, app_name=appName, project=project)