import pkgutils as pkg import argparse import os import subprocess 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")
import pkgutils as pkg 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 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)
import ioutils as io import pkgutils as pkg 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())
import pkgutils as pkg import argparse import datetime import os parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default="") parser.add_argument('message', nargs='?', default="") 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' or len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "commit [message] [-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 last commit date..", io.Progress())
import pkgutils as pkg import argparse import os 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, "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")
import ioutils as io import pkgutils as pkg import argparse import git 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 args.package != 'all' or len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), "kuro clone [-h]") io.exitFail() 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:
import ioutils as io import pkgutils as pkg import argparse import os 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:
import ioutils as io import pkgutils as pkg import argparse import os 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 args.package != 'all' or len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), "kuro status [-h]") io.exitFail() all_clear = True for package in pkg.packages: 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
import argparse import git 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 args.package == 'all': # import kuro_push_all if args.package == 'all' or len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "push [-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:
elif args.command == 'clean': import kuro_clean elif args.command == 'view': import kuro_view_all elif args.command == 'kill': import kuro_kill_all elif args.command == 'clone': import kuro_clone_all else: if args.command == 'run' or args.command == 'log' or args.command == 'commit': io.println("for", io.Yellow(args.command), "command: ") io.println(io.Yellow("usage:"), "<package>", args.command, "[-h]") else: io.println(io.Yellow("usage:"), "kuro [command] [-h]\n") printCommand() else: if args.command == 'status': import kuro_status elif args.command == 'pull': import kuro_pull elif args.command == 'push':
def printCommand(): io.println("command: ") for cmd in command_names: io.println(" ", cmd, " ") if cmd == command_names[5] and args.package == 'all': break
import ioutils as io import pkgutils as pkg import argparse parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='all') parser.add_argument('count', nargs='?', default='5') 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' 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))
import ioutils as io import pkgutils as pkg import argparse import os import shutil parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='none') 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.package != 'all'or args.help: 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)")
import ioutils as io 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()
import pkgutils as pkg import argparse import os import subprocess 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() 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:
import ioutils as io import pkgutils as pkg import argparse import git 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 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")
import argparse import os import subprocess import re 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 len(args.residuals) > 0 or args.help: 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")
import ioutils as io import pkgutils as pkg import argparse import git parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='all') parser.add_argument('branch', nargs='?', default='master') 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, "clone [branch: default is master] [-h]") io.exitFail() avaliable_pkg = False io.printAsync(io.Empty(), "checking package..", io.Progress()) if not pkg.packageIsDir(args.package): for package in pkg.packages: if args.package == package: avaliable_pkg = True break if not avaliable_pkg: io.println(io.Fail(), args.package, "does not exist") io.exitFail()