It's urlopen not url_open

This commit is contained in:
Pedro Algarvio 2014-11-19 22:29:44 +00:00
parent 6b19c7b03e
commit 62c541a2cf
4 changed files with 10 additions and 10 deletions

View File

@ -68,7 +68,7 @@ import os
# pylint: disable=no-name-in-module,import-error # pylint: disable=no-name-in-module,import-error
from salt.ext.six import string_types from salt.ext.six import string_types
from salt.ext.six.moves.urllib.request import ( from salt.ext.six.moves.urllib.request import (
url_open as _url_open, urlopen as _urlopen,
HTTPBasicAuthHandler as _HTTPBasicAuthHandler, HTTPBasicAuthHandler as _HTTPBasicAuthHandler,
HTTPDigestAuthHandler as _HTTPDigestAuthHandler, HTTPDigestAuthHandler as _HTTPDigestAuthHandler,
build_opener as _build_opener, build_opener as _build_opener,
@ -275,9 +275,9 @@ def _http_request(url, request_timeout=None):
request_timeout = __salt__['config.option']('solr.request_timeout') request_timeout = __salt__['config.option']('solr.request_timeout')
if request_timeout is None: if request_timeout is None:
data = json.load(_url_open(url)) data = json.load(_urlopen(url))
else: else:
data = json.load(_url_open(url, timeout=request_timeout)) data = json.load(_urlopen(url, timeout=request_timeout))
return _get_return_dict(True, data, []) return _get_return_dict(True, data, [])
except Exception as err: except Exception as err:
return _get_return_dict(False, {}, ["{0} : {1}".format(url, err)]) return _get_return_dict(False, {}, ["{0} : {1}".format(url, err)])

View File

@ -53,7 +53,7 @@ import re
# pylint: disable=no-name-in-module,import-error # pylint: disable=no-name-in-module,import-error
from salt.ext.six.moves.urllib.parse import urlencode as _urlencode from salt.ext.six.moves.urllib.parse import urlencode as _urlencode
from salt.ext.six.moves.urllib.request import ( from salt.ext.six.moves.urllib.request import (
url_open as _url_open, urlopen as _urlopen,
HTTPBasicAuthHandler as _HTTPBasicAuthHandler, HTTPBasicAuthHandler as _HTTPBasicAuthHandler,
HTTPDigestAuthHandler as _HTTPDigestAuthHandler, HTTPDigestAuthHandler as _HTTPDigestAuthHandler,
build_opener as _build_opener, build_opener as _build_opener,
@ -185,11 +185,11 @@ def _wget(cmd, opts=None, url='http://localhost:8080/manager', timeout=180):
try: try:
# Trying tomcat >= 7 url # Trying tomcat >= 7 url
ret['msg'] = _url_open(url, timeout=timeout).read().splitlines() ret['msg'] = _urlopen(url, timeout=timeout).read().splitlines()
except Exception: except Exception:
try: try:
# Trying tomcat6 url # Trying tomcat6 url
ret['msg'] = _url_open(url6, timeout=timeout).read().splitlines() ret['msg'] = _urlopen(url6, timeout=timeout).read().splitlines()
except Exception: except Exception:
ret['msg'] = 'Failed to create HTTP request' ret['msg'] = 'Failed to create HTTP request'

View File

@ -37,7 +37,7 @@ import copy
# pylint: disable=import-error,no-name-in-module,redefined-builtin # pylint: disable=import-error,no-name-in-module,redefined-builtin
from salt.ext.six import string_types, text_type from salt.ext.six import string_types, text_type
from salt.ext.six.moves import range from salt.ext.six.moves import range
from salt.ext.six.moves.urllib.request import url_open as _url_open from salt.ext.six.moves.urllib.request import urlopen as _urlopen
# pylint: enable=import-error,no-name-in-module,redefined-builtin # pylint: enable=import-error,no-name-in-module,redefined-builtin
# Import salt libs # Import salt libs
@ -526,7 +526,7 @@ def upgrade_bootstrap(directory='.',
'{0}.updated_bootstrap'.format(buildout_ver))) '{0}.updated_bootstrap'.format(buildout_ver)))
except (OSError, IOError): except (OSError, IOError):
LOG.info('Bootstrap updated from repository') LOG.info('Bootstrap updated from repository')
data = _url_open(booturl).read() data = _urlopen(booturl).read()
updated = True updated = True
dled = True dled = True
if 'socket.setdefaulttimeout' not in data: if 'socket.setdefaulttimeout' not in data:

View File

@ -14,7 +14,7 @@ import tempfile
import time import time
# Import 3rd-party libs # Import 3rd-party libs
from salt.ext.six.moves.urllib.request import url_open as _url_open # pylint: disable=no-name-in-module,import-error from salt.ext.six.moves.urllib.request import urlopen as _urlopen # pylint: disable=no-name-in-module,import-error
# Import salt libs # Import salt libs
import salt.key import salt.key
@ -371,7 +371,7 @@ def bootstrap_psexec(hosts='', master=None, version=None, arch='win32',
if not installer_url: if not installer_url:
base_url = 'http://docs.saltstack.com/downloads/' base_url = 'http://docs.saltstack.com/downloads/'
source = _url_open(base_url).read() source = _urlopen(base_url).read()
salty_rx = re.compile('>(Salt-Minion-(.+?)-(.+)-Setup.exe)</a></td><td align="right">(.*?)\\s*<') salty_rx = re.compile('>(Salt-Minion-(.+?)-(.+)-Setup.exe)</a></td><td align="right">(.*?)\\s*<')
source_list = sorted([[path, ver, plat, time.strptime(date, "%d-%b-%Y %H:%M")] source_list = sorted([[path, ver, plat, time.strptime(date, "%d-%b-%Y %H:%M")]
for path, ver, plat, date in salty_rx.findall(source)], for path, ver, plat, date in salty_rx.findall(source)],