def new_plugin(options): from runway.core.system.lib import files_f import pathlib vals = options.vals if len(vals) != 2: return cli_f.shell_text("Required run command: [b]$ runway new_plugin[/b] name label") name, label = options.vals # Check to see if it exists p = pathlib.Path('{dev_path}/runway/plugins/{name}/__init__.py'.format( name = name, dev_path = config['dev_path'], )) if p.exists(): return cli_f.shell_text("[r]This plugin already exists[/r]") os.system("cp -r {dev_path}/empty_module {dev_path}/runway/plugins/{name}".format( name = name, dev_path = config['dev_path'], )) folder_path = "{dev_path}/runway/plugins/{name}".format( name = name, dev_path = config['dev_path'], ) def file_func(fpath, f): if f[0] in (".",): return if ".cpython" in f: return the_file = "{}/{}".format(fpath, f) with open(the_file, 'r', encoding="utf8") as f: contents = f.read() contents = contents.replace("{{name}}", name) contents = contents.replace("{{label}}", label) with open(the_file, 'w', encoding="utf8") as f: f.write(contents) for fpath, f in files_f.iter_tree(folder_path): file_func(fpath, f) return ""
def main(): parser = argparse.ArgumentParser(description='Runway command line interface.', prog="Runway") parser.add_argument('m', help='the mode being run with, list modes with mode set to "list"') parser.add_argument('vals', nargs="*") parser.add_argument('-v', dest="verbose", action="store_true", help='Verbose mode') parser.add_argument('-q', dest="quick", action="store_true", help='Asks the process to try and skip some steps', required=False) parser.add_argument('--no-duplicate', dest="no_duplicate", action="store_true") parser.add_argument('--coverage', dest="coverage", action="store_true", help="Used in testing, uses coverage rather than the built in testing") if len(sys.argv) > 1: args = parser.parse_args() else: args = namedtuple('args', ['m'])(m='default') # Try the func dict for keys, the_function in func_dict.items(): if isinstance(keys, str): keys = [keys] if args.m.lower() in keys: f, info = the_function print(f(args)) sys.exit() # No mode found from the hard coded, check commands from runway.core.commands import execute_command try: bootstrap(production=False) r = execute_command(args.m.lower(), *getattr(args, "vals", [])) if r != None: print(cli_f.shell_text(r)) return except KeyError as e: if e.args[0][:24] == "Command by the name of '": print(cli_f.shell_text("[y]{}[/y]".format(e.args[0]))) else: raise
def run_build(options): if not options.quick: suite = unittest.TestLoader() if not options.no_duplicate: os.system("{0}/../venv/bin/python {0}/cli.py replicate_for_test".format(config['dev_path'])) suite = suite.discover("%s/runway/" % config['dev_path'], pattern="*_tests.py", top_level_dir=config['dev_path']) test_program = unittest.TextTestRunner().run(suite) if test_program.failures != [] or test_program.errors != []: return cli_f.shell_text("[r]The test suite failed, the build script was not run. To override this use the -f (force) argument[/r]") os.system("cd {}; sh build.sh".format(config['dev_path'])) return ""