def test_get_index_from_http_with_query_parameters(): import subprocess import sys import time url = 'http://localhost:9876/index_v3.yaml?raw&at=master' # start a http server and wait if sys.version_info < (3, 0, 0): proc = subprocess.Popen([sys.executable, '-m', 'SimpleHTTPServer', '9876'], cwd=FILES_DIR) else: proc = subprocess.Popen([sys.executable, '-m', 'http.server', '9876'], cwd=FILES_DIR) time.sleep(0.5) try: i = get_index(url) assert len(i.distributions.keys()) == 1 assert 'foo' in i.distributions.keys() # test if every url has the same queries for key, dist_urls in i.distributions['foo'].items(): if key in ('distribution_status', 'distribution_type'): continue if not isinstance(dist_urls, list): dist_urls = [dist_urls] for dist_url in dist_urls: assert dist_url.endswith('?raw&at=master') dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 get_distribution_file(i, 'foo') finally: proc.terminate()
def test_get_index_from_http_with_query_parameters(): import subprocess import sys import time url = 'http://localhost:9876/index_v3.yaml?raw&at=master' # start a http server and wait if sys.version_info < (3, 0, 0): proc = subprocess.Popen( [sys.executable, '-m', 'SimpleHTTPServer', '9876'], cwd=FILES_DIR) else: proc = subprocess.Popen([sys.executable, '-m', 'http.server', '9876'], cwd=FILES_DIR) time.sleep(0.5) try: i = get_index(url) assert len(i.distributions.keys()) == 1 assert 'foo' in i.distributions.keys() # test if every url has the same queries for dist_urls in i.distributions['foo'].values(): if not isinstance(dist_urls, list): dist_urls = [dist_urls] for dist_url in dist_urls: assert dist_url.endswith('?raw&at=master') dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 get_distribution_file(i, 'foo') finally: proc.terminate()
def test_get_distribution_file(): url = 'file://' + FILES_DIR + '/index_v2.yaml' i = get_index(url) dist_file = get_distribution_file(i, 'foo') _validate_dist_file(dist_file) dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 1
def get_distribution_file(index, rosdistro_name, build_file): from rosdistro import get_distribution_files dist_files = get_distribution_files(index, rosdistro_name) dist_files = build_file.filter_distribution_files_by_tags(dist_files) while len(dist_files) > 1: dist_files[0].merge(dist_files[1]) del dist_files[1] return dist_files[0] if dist_files else []
def get_distribution_file(index, rosdistro_name, build_file): from rosdistro import get_distribution_files dist_files = get_distribution_files(index, rosdistro_name) dist_files = build_file.filter_distribution_files_by_tags(dist_files) while len(dist_files) > 1: dist_files[0].merge(dist_files[1]) del dist_files[1] return dist_files[0] if dist_files else []
def test_get_distribution_file(): url = 'file://' + FILES_DIR + '/index_v2.yaml' i = get_index(url) dist_file = get_distribution_file(i, 'foo') _validate_dist_file(dist_file) dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 1
def test_get_index_v3(): url = 'file://' + FILES_DIR + '/index_v3.yaml' i = get_index(url) assert len(i.distributions.keys()) == 1 assert 'foo' in i.distributions.keys() dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 get_distribution_file(i, 'foo')
def test_get_index_v3(): url = 'file://' + FILES_DIR + '/index_v3.yaml' i = get_index(url) assert len(i.distributions.keys()) == 1 assert 'foo' in i.distributions.keys() dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 get_distribution_file(i, 'foo')
def test_get_index_v3_invalid(): url = 'file://' + FILES_DIR + '/index_v3_invalid.yaml' i = get_index(url) dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 try: get_distribution_file(i, 'foo') assert False except AssertionError: pass
def test_get_index_v3_invalid(): url = 'file://' + FILES_DIR + '/index_v3_invalid.yaml' i = get_index(url) dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 try: get_distribution_file(i, 'foo') assert False except AssertionError: pass
def test_get_index_v4(): url = 'file://' + FILES_DIR + '/index_v4.yaml' i = get_index(url) assert len(i.distributions.keys()) == 1 assert 'foo' in i.distributions.keys() assert i.distributions['foo']['distribution_status'] == 'active' assert i.distributions['foo']['distribution_type'] == 'ros1' dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 get_distribution_file(i, 'foo')
def get_distribution_file(distro): global _rosdistro_distribution_files if distro not in _rosdistro_distribution_files: # REP 143, get list of distribution files and take the last one files = rosdistro.get_distribution_files(get_index(), distro) if not files: error( "No distribution files listed for distribution '{0}'.".format( distro), exit=True) _rosdistro_distribution_files[distro] = files[-1] return _rosdistro_distribution_files[distro]
def test_get_index_v4(): url = 'file://' + FILES_DIR + '/index_v4.yaml' i = get_index(url) assert len(i.distributions.keys()) == 1 assert 'foo' in i.distributions.keys() assert i.distributions['foo']['distribution_status'] == 'active' assert i.distributions['foo']['distribution_type'] == 'ros1' dist_files = get_distribution_files(i, 'foo') assert len(dist_files) == 2 get_distribution_file(i, 'foo')
def generate_deb_status_table(package, rosdistro_from, rosdistro_to): DISTROS = collections.OrderedDict() rosdistro_index = get_index(get_index_url()) for distro in sorted(rosdistro_index.distributions.keys()): distribution_files = get_distribution_files(rosdistro_index, distro) if len(distribution_files) > 1: sys.stderr.write( 'distribution_files has multiple entories {}\n'.format( distribution_files)) sys.exit(1) platform = distribution_files[0].release_platforms['ubuntu'] DISTROS[distro] = platform #print('DISTROS[{}] = {}'.format(distro, platform)) table = [] for bit, arch in zip(['v8', 'hf', '32', '64'], ['arm64', 'armhf', 'i386', 'amd64']): if not table: # first row headers = ['Package'] row = ['{} ({})'.format(package, arch)] for distro, os_list in DISTROS.items(): if not (ord(rosdistro_from) <= ord(distro[0]) <= ord(rosdistro_to)): continue for os in os_list: if arch.startswith('arm'): if os == 'xenial': os_arch = 'ux{bit}_u'.format(bit=bit) else: os_arch = 'arm_u' else: os_arch = 'u' if not table: # first row headers.append('{} ({})'.format(distro.capitalize(), os.capitalize())) url = 'http://build.ros.org/job/{prefix_ros}bin_{os_arch}{prefix_os}{bit}__{package}__ubuntu_{os}_{arch}__binary' # NOQA url = url.format( bit=bit, arch=arch, os_arch=os_arch, prefix_os=os[0].upper(), prefix_ros=distro[0].upper(), package=package, os=os, ) template_md = '[![Build Status]({url}/badge/icon)]({url})' row.append(template_md.format(url=url)) table.append(row) print(tabulate.tabulate(table, headers=headers, tablefmt='pipe'))
def generate_deb_status_table(package, rosdistro_from, rosdistro_to): DISTROS = collections.OrderedDict() rosdistro_index = get_index(get_index_url()) for distro in sorted(rosdistro_index.distributions.keys()): distribution_files = get_distribution_files(rosdistro_index, distro) if len(distribution_files) > 1: sys.stderr.write('distribution_files has multiple entories {}\n'.format(distribution_files)) sys.exit(1) platform = distribution_files[0].release_platforms['ubuntu'] DISTROS[distro] = platform #print('DISTROS[{}] = {}'.format(distro, platform)) table = [] for bit, arch in zip(['v8', 'hf', '32', '64'], ['arm64', 'armhf', 'i386', 'amd64']): if not table: # first row headers = ['Package'] row = ['{} ({})'.format(package, arch)] for distro, os_list in DISTROS.items(): if not (ord(rosdistro_from) <= ord(distro[0]) <= ord(rosdistro_to)): continue for os in os_list: if arch.startswith('arm'): if os == 'xenial': os_arch = 'ux{bit}_u'.format(bit=bit) else: os_arch = 'arm_u' else: os_arch = 'u' if not table: # first row headers.append( '{} ({})'.format(distro.capitalize(), os.capitalize())) url = 'http://build.ros.org/job/{prefix_ros}bin_{os_arch}{prefix_os}{bit}__{package}__ubuntu_{os}_{arch}__binary' # NOQA url = url.format( bit=bit, arch=arch, os_arch=os_arch, prefix_os=os[0].upper(), prefix_ros=distro[0].upper(), package=package, os=os, ) template_md = '[![Build Status]({url}/badge/icon)]({url})' row.append(template_md.format(url=url)) table.append(row) print(tabulate.tabulate(table, headers=headers, tablefmt='pipe'))
def generate_deb_status_table(package): sys.stderr.write( ';; Wringing DEB status table for {} ...\n'.format(package)) print('[//]: # (!!DO NOT EDIT !!)\n') print('[//]: # (THIS SECTION IS AUTOMATICALLY GENERATED BY)\n') print( '[//]: # (rosrun jsk_tools generate_deb_status_table.py {})\n'.format( package)) print('') DISTROS = collections.OrderedDict() rosdistro_index = get_index(get_index_url()) for distro, distro_info in sorted(rosdistro_index.distributions.items()): if not (distro_info['distribution_status'] != 'end-of-life' and \ distro_info['distribution_type'] == 'ros1'): sys.stderr.write( ';; Skipping {} because of {} and {} ...\n'.format( distro, distro_info['distribution_status'], distro_info['distribution_type'])) continue distribution_files = get_distribution_files(rosdistro_index, distro) if len(distribution_files) > 1: sys.stderr.write( 'distribution_files has multiple entories {}\n'.format( distribution_files)) sys.exit(1) platform = {} for platform_os in ['ubuntu', 'debian']: if platform_os in distribution_files[0].release_platforms: platform[platform_os] = distribution_files[ 0].release_platforms[platform_os] DISTROS[distro] = platform #print('DISTROS[{}] = {}'.format(distro, platform)) table = [] for bit, arch in zip(['v8', 'hf', '32', '64'], ['arm64', 'armhf', 'i386', 'amd64']): if not table: # first row headers = ['Package'] row = ['{} ({})'.format(package, arch)] for distro, platform_list in DISTROS.items(): for platform_os in ['ubuntu', 'debian']: if platform_os not in platform_list: continue os_list = platform_list[platform_os] if ((distro >= 'melodic' and arch == 'i386') or (platform_os == 'debian' and arch == 'armhf')): template_md = '---' else: for os in os_list: if arch.startswith('arm'): if platform_os == 'ubuntu' and 'precise' < os and os < 'xenial': os_arch = 'arm_u' else: os_arch = '{platform_prefix}{prefix_os}{bit}_{platform_prefix}' os_arch = os_arch.format( platform_prefix=platform_os[0], prefix_os=os[0], bit=bit) elif platform_os == 'ubuntu': os_arch = 'u' else: os_arch = '{platform_prefix}{prefix_os}_{platform_prefix}' os_arch = os_arch.format( platform_prefix=platform_os[0], prefix_os=os[0]) if not table: # first row headers.append('{} ({})'.format( distro.capitalize(), os.capitalize())) url = 'http://build.ros.org/job/{prefix_ros}bin_{os_arch}{prefix_os}{bit}__{package}__{platform_os}_{os}_{arch}__binary' # NOQA url = url.format( bit=bit, arch=arch, os_arch=os_arch, prefix_os=os[0].upper(), prefix_ros=distro[0].upper(), package=package, platform_os=platform_os, os=os, ) template_md = '[![Build Status]({url}/badge/icon)]({url})' row.append(template_md.format(url=url)) table.append(row) print(tabulate.tabulate(table, headers=headers, tablefmt='pipe')) print('') print('[//]: #')