if io.runCommandMuted("screen -ls | grep {}".format(package)): io.printAsync(io.Empty(), "checking executables in ", package, "..", io.Progress()) stdout = subprocess.check_output(["screen", "-ls | grep", package]).decode("utf-8") executables = re.findall('__([a-z + _]+)', stdout) if len(executables)>0: for executable in executables: if package_clear: io.println(io.Warn(), "some packages are running:") package_clear = False target_packages.append(package) target_executables.append(executable) io.println(io.WarnList(), executable, "in", package) if len(target_executables) == 0: string = io.println(io.Fail(), "no executable is running") io.exitSuccess() elif len(target_executables) == 1: string = io.scanln(io.Warn(), "do you want to kill it? (yes/no):") else: string = io.scanln(io.Warn(), "do you want to kill them? (yes/no):") io.newLine() if string == 'no': io.println(io.Fail(), "cancelled") io.exitFail() elif string != 'yes': io.println(io.Fail(), "invalid input, cancelled") io.exitFail() i = 0
io.println(io.Yellow("usage:"), args.package, "view <executable> [-h]") io.exitSuccess() if args.executable == 'none': if io.runCommandMuted("screen -ls | grep {}".format(args.package)): io.printAsync(io.Empty(), "checking executables in ", args.package, "..", io.Progress()) stdout = subprocess.check_output( ["screen", "-ls | grep", args.package]).decode("utf-8") executables = re.findall('__([a-z + _]+)', stdout) if len(executables) > 0: for executable in executables: io.println(io.Success(), executable, "is running") else: io.println(io.Fail(), "no executable is running") io.exitSuccess() io.printAsync(io.Empty(), "checking executable..", io.Progress()) if io.runCommandMuted("screen -ls | grep {}__{}".format( args.package, args.executable)): io.println(io.Success(), "resuming", args.executable, "in", args.package) io.println(io.Warn(), "use ctrl+a,d to detach and ctrl+c to exit") io.scanAnyKey(io.Warn(), "press any key to continue") if not io.runCommandMuted("screen -r {}__{}".format( args.package, args.executable)): io.println(io.Fail(), "failed to view", args.executable, "in", args.package) io.exitFail()
import argparse parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='all') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('command') parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "status [-h]") io.exitFail() io.printAsync(io.Empty(), "checking package..", io.Progress()) if not pkg.packageIsDir(args.package): io.println(io.Fail(), args.package, "does not exist") io.exitFail() if not pkg.packageIsGitRepository(args.package): io.println(io.Fail(), args.package, "is not a git repository") io.exitFail() repo = pkg.getPackageRepo(args.package) package_clear = True io.printAsync(io.Empty(), "checking untracked files in", args.package, "\b..", io.Progress()) untracked_files = repo.untracked_files if len(untracked_files) > 0: package_clear = False
import re parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='all') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('command') parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "view <executable> [-h]") io.exitSuccess() if args.package == 'all': executable_exist = False for package in pkg.packages: if io.runCommandMuted("screen -ls | grep {}".format(package)): io.printAsync(io.Empty(), "checking executables in ", package, "..", io.Progress()) stdout = subprocess.check_output(["screen", "-ls | grep", package]).decode("utf-8") executables = re.findall('__([a-z + _]+)', stdout) if len(executables) > 0: executable_exist = True for executable in executables: io.println(io.Success(), executable, "is running") if not executable_exist: io.println(io.Fail(), "no executable is running") io.exitSuccess()
if args.package == 'none' or args.executable == 'none' or len( args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "run <executable> [-h]") io.exitFail() io.printAsync(io.Empty(), "checking executable..", io.Progress()) if io.runCommandMuted("screen -ls | grep {}__{}".format( args.package, args.executable)): io.println(io.Warn(), args.executable, "in", args.package, "has been run") string = io.scanln(io.Warn(), "do you want to kill it? (yes/no):") io.newLine() if string == 'no': io.println(io.Fail(), "cancelled") io.exitFail() elif string != 'yes': io.println(io.Fail(), "invalid input, cancelled") io.exitFail() io.printAsync(io.Empty(), "killing executable..", io.Progress()) if not io.runCommandMuted("screen -XS {}__{} quit".format( args.package, args.executable)): io.println(io.Fail(), "failed to kill", args.executable, "in", args.package) io.exitFail() io.println(io.Success(), "killed", args.executable, "in", args.package) io.printAsync(io.Empty(), "checking log file..", io.Progress())
parser.add_argument('package', nargs='?', default='all') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('command') parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() # if args.package == 'all': # import kuro_reset_all if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "reset [-h]") io.exitFail() io.printAsync(io.Empty(), "checking package..", io.Progress()) if not pkg.packageIsDir(args.package): io.println(io.Fail(), args.package, "does not exist") io.exitFail() if not pkg.packageIsGitRepository(args.package): io.println(io.Fail(), args.package, "is not a git repository") io.exitFail() repo = pkg.getPackageRepo(args.package) if not pkg.repoIsNotClean(repo): io.println(io.Success(), "done, nothing to be reset in", args.package) io.exitSuccess() string = io.scanln(io.Warn(), "are you sure you want to reset", args.package, "\b? (yes/no):") io.newLine()
parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if args.package != 'all' or len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), "kuro pull [-h]") io.exitFail() all_clear = True for package in pkg.packages: package_clear = True io.printAsync(io.Empty(), "checking package..", io.Progress()) if not pkg.packageIsDir(package): io.println(io.Fail(), package, "does not exist") all_clear = False continue if not pkg.packageIsGitRepository(package): io.println(io.Fail(), package, "is not a git repository") all_clear = False continue repo = pkg.getPackageRepo(package) io.printAsync(io.Empty(), "checking remotes..", io.Progress()) if 'origin' not in repo.remotes: io.println(io.Fail(), package, "does not have origin remote") all_clear = False continue
parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='all') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('command') parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), "kuro build [-h]") io.exitFail() command = "colcon build --symlink-install --merge-install" if args.package != 'all': command = "{} --packages-up-to {}".format(command, args.package) io.println(io.Warn(), "calling colcon build") original_path = os.getcwd() os.chdir(pkg.workspace_path) io.newLine() if os.system(command) == 0: io.newLine() io.println(io.Success(), "build succesfully") else: io.newLine() io.println(io.Fail(), "build failed") os.chdir(original_path) io.exitSuccess()
import kuro_log elif args.command == 'reset': import kuro_reset elif args.command == 'build': import kuro_build elif args.command == 'clean': import kuro_clean elif args.command == 'run': import kuro_run elif args.command == 'view': import kuro_view elif args.command == 'kill': import kuro_kill elif args.command == 'clone': import kuro_clone else: io.println(io.Yellow("usage:"), args.package + " [command] [-h]") printCommand() except KeyboardInterrupt: io.println(io.Fail(), "keyboard interrupt, aborted") sys.exit(1)
parser.add_argument('package', nargs='?', default='all') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('command') parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() # if args.package == 'all': # import kuro_pull_all if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "pull [-h]") io.exitFail() io.printAsync(io.Empty(), "checking package..", io.Progress()) if not pkg.packageIsDir(args.package): io.println(io.Fail(), args.package, "does not exist") io.exitFail() if not pkg.packageIsGitRepository(args.package): io.println(io.Fail(), args.package, "is not a git repository") io.exitFail() repo = pkg.getPackageRepo(args.package) io.printAsync(io.Empty(), "checking remotes..", io.Progress()) if 'origin' not in repo.remotes: io.println(io.Fail(), args.package, "does not have origin remote") io.exitFail() is_up_to_date = True
directories_to_clean = [] io.printAsync(io.Empty(), "checking directories..", io.Progress()) for directory in directories: if os.path.exists(os.path.join(pkg.workspace_path, directory)): directories_to_clean.append(directory) if len(directories_to_clean) < 1: io.println(io.Success(), "already cleaned") io.exitSuccess() string = io.scanln(io.Warn(), "are you sure you want to clean the workspace? (yes/no)") io.newLine() if string == 'no': io.println(io.Fail(), "cancelled") io.exitFail() elif string != 'yes': io.println(io.Fail(), "invalid input, cancelled") io.exitFail() for directory in directories_to_clean: io.printAsync(io.Empty(), "checking", directory, "directory..", io.Progress()) path = os.path.join(pkg.workspace_path, directory) if os.path.isdir(path): io.printAsync(io.Empty(), "removing", directory, "directory..", io.Progress()) try: shutil.rmtree(path) except PermissionError:
import argparse parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='none') parser.add_argument('command') parser.add_argument('executable', nargs='?', default='none') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if args.package == 'none' or args.executable == 'none' or len( args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "kill <executable> [-h]") io.exitFail() io.printAsync(io.Empty(), "checking executable..", io.Progress()) if not io.runCommandMuted("screen -ls | grep {}__{}".format( args.package, args.executable)): io.println(io.Fail(), args.executable, "in", args.package, "has not been run") io.exitFail() io.printAsync(io.Empty(), "killing executable..", io.Progress()) if not io.runCommandMuted("screen -XS {}__{} quit".format( args.package, args.executable)): io.println(io.Fail(), "failed to kill", args.executable, "in", args.package) io.exitFail() io.println(io.Success(), "done killing", args.executable, "in", args.package) io.exitSuccess()
all_clear = True for package in pkg.packages: avaliable_pkg = False io.printAsync(io.Empty(), "checking package..", io.Progress()) if not pkg.packageIsDir(package): for package_check in pkg.packages: if package == package_check: avaliable_pkg = True break if not avaliable_pkg: io.println(io.Fail(), package, "does not exist") continue if pkg.packageIsGitRepository(package): io.println(io.Success(), package, "already cloned") continue if avaliable_pkg: io.printAsync(io.Empty(), "cloning package..", io.Progress()) try: pkg.cloneNewRepoFile(args.package, 'master') except Exception as e: io.println(io.Fail(), "could not clone the", args.package) io.println(e) continue