def main() -> int: """ Run the simulation """ parser = argparse.ArgumentParser(prog='opentrons_simulate', description='Simulate an OT-2 protocol') parser = get_arguments(parser) args = parser.parse_args() # Try to migrate api v1 containers if needed runlog, maybe_bundle = simulate(args.protocol, args.protocol.name, getattr(args, 'custom_labware_path', []), getattr(args, 'custom_data_path', []) + getattr(args, 'custom_data_file', []), hardware_simulator_file_path=getattr( args, 'custom_hardware_simulator_file'), log_level=args.log_level) if maybe_bundle: bundle_name = getattr(args, 'bundle', None) if bundle_name == args.protocol.name: raise RuntimeError('Bundle path and input path must be different') bundle_dest = _get_bundle_dest(bundle_name, 'PROTOCOL.ot2.zip', args.protocol.name) if bundle_dest: bundle.create_bundle(maybe_bundle, bundle_dest) if args.output == 'runlog': print(format_runlog(runlog)) return 0
def test_write_bundle(get_bundle_fixture): fixture = get_bundle_fixture('simple_bundle') buf = io.BytesIO(fixture['binary_zipfile']) buf.seek(0) zf = zipfile.ZipFile(buf) original_contents = bundle.extract_bundle(zf) t = io.BytesIO() bundle.create_bundle(original_contents, t) zf2 = zipfile.ZipFile(t) new_contents = bundle.extract_bundle(zf2) assert new_contents == original_contents