Skip to content

Commit

Permalink
Merge pull request #7 from xebialabs-community/proxy
Browse files Browse the repository at this point in the history
Refactoring proxy setting
  • Loading branch information
jdewinne authored Nov 30, 2017
2 parents f663335 + 79c0c41 commit e8c4e45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/resources/caflowdock/FlowdockHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'])
4 changes: 1 addition & 3 deletions src/main/resources/caflowdock/SendTeamInboxMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e8c4e45

Please sign in to comment.