def test_load_path_resources(root_dir): r_dict = utils.resources_in_path(os.path.join(root_dir, 'data/modules')) assert r_dict is not None assert len(list(r_dict.keys())) == 3 filted_dict = utils.resources_in_path(os.path.join(root_dir, 'data/modules'), include_filter=Subsystem) print(Subsystem._BASE_RESOURCES) assert len(list(filted_dict.keys())) == 1
def run_ss(ctx, ss_id, build_dir): r_dict = utils.resources_in_path(ctx.obj['input_dir'], include_filter=Subsystem) if not ss_id in r_dict: click.echo( f'{ss_id} not found in input resources. [{", ".join(r_dict.keys())}]', err=True) click.echo(r_dict) exit(1) ss_cls = r_dict[ss_id] ss_build_base = os.path.join(build_dir, ss_cls._RESOURCE_NAME) ss_bin_dir = os.path.join(ss_build_base, 'bin') if not os.path.exists(ss_bin_dir): click.echo( f'{ss_bin_dir} not found. Have you compiled this subsystem?', err=True) exit(1) sys.path.insert(0, ss_bin_dir) ss = ss_cls() loop = asyncio.get_event_loop() loop.run_until_complete(ss.run()) loop.close()
def list_ss(ctx): r_dict = utils.resources_in_path(ctx.obj['input_dir'], include_filter=Subsystem) headers = ["ID", "Description"] click.echo( tabulate([(k, ) + (v._RESOURCE_DESCRIPTION, ) for k, v in r_dict.items()], headers=headers))
def build(ctx, ss, build_dir, dev_img): r_dict = utils.resources_in_path(ctx.obj['input_dir'], include_filter=Subsystem) if len(ss) == 0: for s in r_dict.values(): s.build(build_dir) else: for s in ss: if s in r_dict: r_dict[s].build(build_dir) else: click.echo(f'Subsystem {s} not found.', err=True)
def deploy(ctx, sos, build_dir): r_dict = utils.resources_in_path(ctx.obj['input_dir'], include_filter=SystemOfSystems) if sos not in r_dict.keys(): click.echo( f'SoS {sos} not found in input directory {ctx.obj["input_dir"]}') exit(1) click.echo(f'Deplpying {sos}') sos_cls = r_dict[sos] sos_cls.deploy(build_dir)
def register_fields(ctx): r_dict = utils.resources_in_path(ctx.obj['input_dir'], include_filter=Field) client = FTGRepoClient() for f in r_dict.values(): client.register_field(f)