Commit 9359dede authored by Marco Mariani's avatar Marco Mariani

grid: detect platform for binary cache support under cygwin

parent 4e428fdc
...@@ -10,7 +10,7 @@ import sys ...@@ -10,7 +10,7 @@ import sys
import prettytable import prettytable
from slapos.grid import networkcache from slapos.grid import networkcache
from slapos.grid.distribution import patched_linux_distribution from slapos.grid.distribution import distribution_tuple
from slapos.cli.config import ConfigCommand from slapos.cli.config import ConfigCommand
...@@ -76,7 +76,7 @@ def do_lookup(logger, cache_dir, software_url): ...@@ -76,7 +76,7 @@ def do_lookup(logger, cache_dir, software_url):
pt = prettytable.PrettyTable(['distribution', 'version', 'id', 'compatible?']) pt = prettytable.PrettyTable(['distribution', 'version', 'id', 'compatible?'])
linux_distribution = patched_linux_distribution() linux_distribution = distribution_tuple()
for os in ostable: for os in ostable:
compatible = 'yes' if networkcache.os_matches(os, linux_distribution) else 'no' compatible = 'yes' if networkcache.os_matches(os, linux_distribution) else 'no'
......
...@@ -13,6 +13,9 @@ patched_linux_distribution(...): ...@@ -13,6 +13,9 @@ patched_linux_distribution(...):
see http://bugs.python.org/issue9514 see http://bugs.python.org/issue9514
otherwise, Ubuntu will always be reported as an unstable Debian, regardless of the version. otherwise, Ubuntu will always be reported as an unstable Debian, regardless of the version.
distribution_tuple()
returns a (distname, version, id) tuple under linux or cygwin
""" """
import platform import platform
...@@ -62,3 +65,10 @@ def patched_linux_distribution(distname='', version='', id='', ...@@ -62,3 +65,10 @@ def patched_linux_distribution(distname='', version='', id='',
pass pass
return platform.linux_distribution(distname, version, id, supported_dists, full_distribution_name) return platform.linux_distribution(distname, version, id, supported_dists, full_distribution_name)
def distribution_tuple():
if platform.system().startswith('CYGWIN_'):
return (platform.system(), platform.platform(), '')
else:
return patched_linux_distribution()
...@@ -18,7 +18,7 @@ import platform ...@@ -18,7 +18,7 @@ import platform
import shutil import shutil
import traceback import traceback
from slapos.grid.distribution import os_matches, patched_linux_distribution from slapos.grid.distribution import os_matches, distribution_tuple
try: try:
try: try:
...@@ -88,7 +88,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root, ...@@ -88,7 +88,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
if tags.get('machine') != platform.machine(): if tags.get('machine') != platform.machine():
continue continue
if not os_matches(ast.literal_eval(tags.get('os')), if not os_matches(ast.literal_eval(tags.get('os')),
patched_linux_distribution()): distribution_tuple()):
continue continue
if tags.get('software_url') != software_url: if tags.get('software_url') != software_url:
continue continue
...@@ -134,7 +134,7 @@ def upload_network_cached(software_root, software_url, cached_key, ...@@ -134,7 +134,7 @@ def upload_network_cached(software_root, software_url, cached_key,
software_url=software_url, software_url=software_url,
software_root=software_root, software_root=software_root,
machine=platform.machine(), machine=platform.machine(),
os=str(patched_linux_distribution()) os=str(distribution_tuple())
) )
f = open(path, 'r') f = open(path, 'r')
......
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