diff options
Diffstat (limited to 'helm/plugin/tasks.py')
-rw-r--r-- | helm/plugin/tasks.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/helm/plugin/tasks.py b/helm/plugin/tasks.py index be59472..535f14e 100644 --- a/helm/plugin/tasks.py +++ b/helm/plugin/tasks.py @@ -1,6 +1,7 @@ # ============LICENSE_START========================================== # =================================================================== # Copyright (c) 2018 AT&T +# Copyright (c) 2020 Pantheon.tech. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +16,6 @@ # limitations under the License. # ============LICENSE_END============================================ -from cloudify.decorators import operation import shutil import errno import sys @@ -25,17 +25,21 @@ import os import re import getpass import subprocess -from cloudify import ctx -from cloudify.exceptions import OperationRetry -from cloudify_rest_client.exceptions import CloudifyClientError -import pip import json import base64 import yaml -import urllib2 -from cloudify.decorators import operation +try: + from urllib.request import Request, urlopen +except ImportError: + from urllib2 import Request, urlopen + +from cloudify import ctx from cloudify import exceptions +from cloudify.decorators import operation +from cloudify.exceptions import OperationRetry from cloudify.exceptions import NonRecoverableError +from cloudify_rest_client.exceptions import CloudifyClientError + def debug_log_mask_credentials(_command_str): debug_str = _command_str @@ -186,18 +190,18 @@ def pop_config_info(url, config_file, f_format, repo_user, repo_user_passwd): head, auth = head.rsplit('//', 1) url = head + '//' + end username, password = auth.rsplit(':', 1) - request = urllib2.Request(url) + request = Request(url) base64string = base64.encodestring( '%s:%s' % (username, password)).replace('\n', '') request.add_header("Authorization", "Basic %s" % base64string) - response = urllib2.urlopen(request) + response = urlopen(request) elif repo_user != '' and repo_user_passwd != '': - request = urllib2.Request(url) + request = Request(url) base64string = base64.b64encode('%s:%s' % (repo_user, repo_user_passwd)) request.add_header("Authorization", "Basic %s" % base64string) - response = urllib2.urlopen(request) + response = urlopen(request) else: - response = urllib2.urlopen(url) + response = urlopen(url) config_obj = {} if f_format == 'json': |