def DemoCommand(demo_name, destination=None): if not demo_name: print('Usage: biodynamo demo <demo name> [target directory]') print('Known demos:\n {}'.format('\n '.join(KNOWN_DEMOS))) return if demo_name not in KNOWN_DEMOS: Print.error('Demo name "{}" is not known.'.format(demo_name)) print('Known demos:\n {}'.format('\n '.join(KNOWN_DEMOS))) sys.exit(1) if destination is None: destination = '.' if os.path.exists(destination): destination = os.path.join(destination, demo_name) if os.path.exists(destination): Print.error('Destination directory "{}" exists.'.format(destination)) sys.exit(2) src_dir = os.path.join(DEMO_DIR, demo_name) print('Copying files from "{}" to "{}"...'.format(src_dir, destination)) shutil.copytree(src_dir, destination) CopySupportFiles(destination) InitializeNewGitRepo(destination) Print.success('The demo "{}" has been created in "{}".'.format( demo_name, destination))
def DemoCommand(demo_name, destination=None): if not demo_name: print("Usage: biodynamo demo <demo name> [target directory]") print("Known demos:\n {}".format("\n ".join(KNOWN_DEMOS))) return if demo_name not in KNOWN_DEMOS: Print.error("Demo name \"{}\" is not known.".format(demo_name)) print("Known demos:\n {}".format("\n ".join(KNOWN_DEMOS))) sys.exit(1) if destination is None: destination = "." if os.path.exists(destination): destination = os.path.join(destination, demo_name) if os.path.exists(destination): Print.error("Destination directory \"{}\" exists.".format(destination)) Print.error( "Please remove it or create the demo in a different place.") Print.error("Abort \"biodynamo demo {}\".".format(demo_name)) sys.exit(2) src_dir = os.path.join(DEMO_DIR, demo_name) print("Copying files from \"{}\" to \"{}\"...".format( src_dir, destination)) shutil.copytree(src_dir, destination) CopySupportFiles(destination) InitializeNewGitRepo(destination) Print.success("The demo \"{}\" has been created in \"{}\".".format( demo_name, destination))
def NewCommand(sim_name, no_github): print("Info: This command requires a Github.com account.") print(" Please have your account details ready, or ") print(" go over to https://github.com/join to sign up.") ValidateSimName(sim_name) DownloadTemplateRepository(sim_name) CustomizeFiles(sim_name) InitializeNewGitRepo(sim_name) if (not no_github): CreateNewGithubRepository(sim_name) Print.success(sim_name + " has been created successfully!") print( 'To compile and run this simulation, change the directory by calling ' '"cd %s"' % (sim_name))
def RunCommand(args, debug=False): sim_name = GetBinaryName() args_str = ' '.join(args) cmd = "./build/" + sim_name try: BuildCommand() Print.new_step("Run " + sim_name + ' ' + args_str) if debug: sp.check_output([cmd, "&>", "debug/runtime_output.log"]) else: print( sp.check_output([cmd, args_str], stderr=sp.STDOUT).decode('utf-8')) Print.success("Finished successfully") except sp.CalledProcessError as err: print(err.output.decode("utf-8")) Print.error("Error during execution of {0}".format(cmd))
def RunCommand(args, debug=False): sim_name = GetBinaryName() args_str = " ".join(args) cmd = "./build/" + sim_name if platform.system() == "Darwin": launcher = os.environ["BDMSYS"] + "/bin/launcher.sh" else: launcher = "" try: BuildCommand() Print.new_step("Run " + sim_name + " " + args_str) if debug: sp.check_output( [launcher + " " + cmd, "&>", "debug/runtime_output.log"]) else: print( sp.check_output([launcher + " " + cmd, args_str], stderr=sp.STDOUT, shell=True).decode("utf-8")) Print.success("Finished successfully") except sp.CalledProcessError as err: print(err.output.decode("utf-8")) Print.error("Error during execution of {0}".format(cmd))