["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() else: io.println(io.Warn(), args.executable, "in", args.package, "has not been run") io.printAsync(io.Empty(), "checking log files..", io.Progress()) log_file = os.path.join(pkg.workspace_path, 'log', '{}__{}.log'.format(args.package, args.executable)) if not os.path.exists(log_file):
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 io.println(io.Warn(), "found", len(untracked_files), "untracked files:") for untracked_file in untracked_files: io.println(io.WarnList(), untracked_file) io.newLine() io.printAsync(io.Empty(), "checking modified files in", args.package, "\b..", io.Progress()) modified_files = [item.a_path for item in repo.index.diff(None)] if len(modified_files) > 0: package_clear = False io.println(io.Warn(), "found", len(modified_files), "modified files:") for modified_file in modified_files: io.println(io.WarnList(), modified_file) io.newLine() io.printAsync(io.Empty(), "checking uncommitted changes in", args.package,
target_packages = list() target_executables = list() if args.package == 'all': package_clear = True 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: 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()
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, "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.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() 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(), "resetting", args.package, "\b..", io.Progress()) repo.git.reset('--hard') io.printAsync(io.Empty(), "cleaning", args.package, "\b..", io.Progress()) repo.git.clean('-xdf')
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()
current_time = datetime.datetime.now() if current_time < committed_time: io.println( io.Fail(), "current date and time are behind last committed date and time") io.exitFail() io.printAsync(io.Empty(), "staging files..", io.Progress()) repo.git.add('--all') uncommitted_changes = pkg.getUncommittedChanges(repo) if len(uncommitted_changes) < 1: io.println(io.Success(), "nothing to be committed") io.exitSuccess() io.println(io.Warn(), "changes to be committed:") for uncommitted_change in uncommitted_changes: io.println(io.WarnList(), uncommitted_change) io.newLine() io.printAsync(io.Empty(), "checking author info..", io.Progress()) author_name = "" author_email = "" try: author_name = os.environ['KURO_AUTHOR_NAME'] author_email = os.environ['KURO_AUTHOR_EMAIL'] if len(author_name) < 1 or len(author_email) < 1: raise KeyError
if is_up_to_date: io.println(io.Success(), "updated branch:") is_up_to_date = False io.println(io.SuccessList(), "update", fetch_info.ref, "to '{}'".format(fetch_info.commit.summary)) if not is_up_to_date: io.newLine() io.printAsync(io.Empty(), "checking diffs..", io.Progress()) try: commits_behind = pkg.getCommitsBehind(repo) commits_ahead = pkg.getCommitsAhead(repo) except git.GitCommandError: io.println(io.Warn(), "remote does not have", repo.active_branch, "branch") io.println(io.Fail(), "aborted") io.exitFail() if len(commits_ahead) == 0: if len(commits_behind) > 0: io.println(io.Warn(), args.package, "is behind of master by", io.PluralCount('commit', len(commits_behind))) io.exitSuccess() else: io.println(io.Success(), args.package, "is up to date with origin") io.exitSuccess() is_up_to_date = True io.printAsync(io.Empty(), "pushing", args.package, "\b..", io.Progress())
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 io.printAsync(io.Empty(), "fetching", package, "\b..", io.Progress()) for fetch_info in repo.remotes['origin'].fetch(): if fetch_info.flags & git.FetchInfo.NEW_HEAD != 0: if package_clear: io.println(io.Warn(), package, "pull from origin remote:") package_clear = False io.println(io.SuccessList(), "update", fetch_info.ref, "to '{}'".format(fetch_info.commit.summary)) io.printAsync(io.Empty(), "checking diffs..", io.Progress()) try: commits_behind = pkg.getCommitsBehind(repo) commits_ahead = pkg.getCommitsAhead(repo) except git.GitCommandError: if package_clear: io.println(io.Warn(), package, "pull from origin remote:") package_clear = False io.println(io.WarnList(), "remote does not have", repo.active_branch, "branch") all_clear = False
if not pkg.packageIsGitRepository(package): io.println(io.Fail(), package, "is not a git repository") all_clear = False continue repo = pkg.getPackageRepo(package) package_clear = True io.printAsync(io.Empty(), "checking untracked files in", package, "\b..", io.Progress()) untracked_files = repo.untracked_files if len(untracked_files) > 0: all_clear = False if package_clear: io.println(io.Warn(), package, "({})".format(repo.active_branch), "has some problems:") package_clear = False io.println(io.WarnList(), "found", len(untracked_files), "untracked files") io.printAsync(io.Empty(), "checking modified files in", package, "\b..", io.Progress()) modified_files = [item.a_path for item in repo.index.diff(None)] if len(modified_files) > 0: all_clear = False if package_clear: io.println(io.Warn(), package, "({})".format(repo.active_branch), "has some problems:") package_clear = False io.println(io.WarnList(), "found", len(modified_files),
parser.add_argument('command') 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:"), args.package, "log [-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(), "getting commits..", io.Progress()) commits = list(repo.iter_commits(repo.active_branch, max_count=args.count)) if len(commits) < 1: io.println(io.Warn(), "no commit found in", args.package) io.exitSuccess() io.println(io.Success(), "found", len(commits), io.Plural("commit", len(commits)), "in", args.package, ":") for commit in commits: io.println(io.EmptyList(), str(commit.name_rev)[:20], "\b,", commit.summary) io.exitSuccess()
if is_up_to_date: io.println(io.Success(), "updated branch:") is_up_to_date = False io.println(io.SuccessList(), "update", fetch_info.ref, "to '{}'".format(fetch_info.commit.summary)) if not is_up_to_date: io.newLine() io.printAsync(io.Empty(), "checking diffs..", io.Progress()) try: commits_behind = pkg.getCommitsBehind(repo) commits_ahead = pkg.getCommitsAhead(repo) except git.GitCommandError: io.println(io.Warn(), "remote does not have", repo.active_branch, "branch") io.println(io.Fail(), "aborted") io.exitFail() if len(commits_behind) == 0: if len(commits_ahead) > 0: io.println(io.Warn(), args.package, "is ahead of master by", io.PluralCount('commit', len(commits_ahead))) io.exitSuccess() else: io.println(io.Success(), args.package, "is up to date with origin") io.exitSuccess() io.printAsync(io.Empty(), "checking dirty state..", io.Progress()) if pkg.repoIsNotClean(repo): inp = io.scanln(
io.println(io.Yellow("usage:"), "kuro clean [-h]") io.exitFail() directories = ['build', 'install', 'log'] 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):
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 if not avaliable_pkg: io.printAsync(io.Empty(), "cloning package..", io.Progress()) try: repo = pkg.masterCloneRepo(package) except Exception as e: io.println(io.Fail(), "could not clone the", args.package) io.println(e) continue if pkg.packageIsGitRepository(package): io.println(io.Success(), "done", package, "cloned") continue if not all_clear: io.println(io.Warn(), "done, not all clear") io.exitSuccess() io.println(io.Success(), "done, all clear") io.exitSuccess()