Use url checker cli instead of importing it

Depends-On: I7cb455edc905ade90f1754e264c2b045b0c446f5
Closes-Bug: #1528599
Change-Id: I2b416a64d79f7217db2f4fdfd1b556d090edd567
This commit is contained in:
Vladimir Kozhukalov 2015-12-22 17:40:15 +03:00
parent e27947f3b8
commit ddbe5faf59
2 changed files with 24 additions and 6 deletions

View File

@ -82,3 +82,17 @@ def get_fuel_version(versionfile='/etc/fuel_release'):
except IOError:
log.error("Unable to set Fuel version from %s" % versionfile)
return ""
def execute(command):
"""Executes commands
:param command: A list of shell lexemes
:returns: Tuple of (return_code, stdout, stderr)
"""
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = proc.communicate()
return proc.poll(), out, err

View File

@ -17,8 +17,6 @@ import logging
import re
import six
import url_access_checker.api as urlck
import url_access_checker.errors as url_errors
import urwid
import urwid.raw_display
import urwid.web_display
@ -410,11 +408,17 @@ class bootstrapimg(urwid.WidgetWrap):
self._update_defaults(self.defaults, newsettings)
def check_url(self, url, proxies):
try:
return urlck.check_urls([url], proxies=proxies)
except (url_errors.UrlNotAvailable,
url_errors.InvalidProtocol):
command = ['/usr/bin/urlaccesscheck', 'check']
if proxies.get('http'):
command += ['--http-proxy', proxies['http']]
if proxies.get('https'):
command += ['--https-proxy', proxies['https']]
command.append(url)
return_code, _, err = utils.execute(command)
if return_code != 0:
log.error("Error while checking url: %s error: %s", url, err)
return False
return True
def _check_repo(self, base_url, suite, proxies):
release_url = '{base_url}/dists/{suite}/Release'.format(