Kaydet (Commit) afba52dc authored tarafından shin-'s avatar shin-

Added utils.ping and used to expand registry URL (http VS https)

üst addecd49
......@@ -18,6 +18,8 @@ import os
import six
import utils
INDEX_URL = 'https://index.docker.io/v1/'
def swap_protocol(url):
......@@ -33,7 +35,8 @@ def expand_registry_url(hostname):
if '/' not in hostname[9:]:
hostname = hostname + '/v1/'
return hostname
#FIXME: ping https then fallback to http
if utils.ping('https://' + hostname + '_ping'):
return 'https://' + hostname + '/v1/'
return 'http://' + hostname + '/v1/'
......
......@@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
import tarfile
import tempfile
import requests
import six
if six.PY3:
from io import StringIO
else:
......@@ -44,5 +46,14 @@ def tar(self, path):
f.seek(0)
return f
def compare_version(v1, v2):
return float(v2) - float(v1)
\ No newline at end of file
return float(v2) - float(v1)
def ping(url):
try:
res = requests.get(url)
return res.status >= 400
except Exception:
return False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment