Exemplo n.º 1
0
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")

    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",
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()
            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
  while i < len(target_executables):
    if not io.runCommandMuted("screen -XS {}__{} quit".format(target_packages[i], target_executables[i])):
      io.println(io.Fail(), "failed to kill", target_executables[i], "in", target_packages[i])

    io.println(io.Success(), "killed", target_executables[i], "in", target_packages[i])
    i = i + 1

  io.exitSuccess()
    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()

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')
    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,
              "\b..", io.Progress())
uncommitted_changes = pkg.getUncommittedChanges(repo)
if len(uncommitted_changes) > 0:
    package_clear = False
    io.println(io.Warn(), "found", len(uncommitted_changes),
               "uncommitted changes:")
    for uncommitted_change in uncommitted_changes:
        io.println(io.WarnList(), uncommitted_change)
    io.newLine()

if not package_clear:
    io.println(io.Warn(), "done,", args.package, "is not clear")
    io.exitSuccess()

io.println(io.Success(), "done,", args.package, "is clear")
io.exitSuccess()
Exemplo n.º 6
0
except ValueError:
    committed_time = datetime.datetime.now()

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']
Exemplo n.º 7
0
    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())
log_file = os.path.join(pkg.workspace_path, 'log',
                        '{}__{}.log'.format(args.package, args.executable))
if os.path.exists(log_file):
    io.println(io.Success(), "removed previous log file")
    os.remove(log_file)

io.println(io.Success(), "running", 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")

run_script = os.path.join(pkg.workspace_path, 'run.sh')
command = "bash {} {} {} {}".format(run_script, args.package, args.executable,
                                    log_file)
        io.println(io.WarnList(), "remote does not have", repo.active_branch,
                   "branch")
        all_clear = False
        continue

    if len(commits_behind) == 0:
        if len(commits_ahead) > 0:
            if package_clear:
                io.println(io.Warn(), package, "pull from origin remote:")
                package_clear = False
            io.println(io.WarnList(), package, "is ahead of master by",
                       io.PluralCount('commit', len(commits_ahead)))
            all_clear = False
            continue
        else:
            io.println(io.Success(), package, "is up to date with origin")
            continue

    io.printAsync(io.Empty(), "checking dirty state..", io.Progress())
    if pkg.repoIsNotClean(repo):
        inp = io.scanln(
            io.WarnList(),
            "found dirty state, are you sure you want to reset it? (yes/no):")
        io.newLine()
        if inp == 'yes':
            io.printAsync(io.EmptyList(), "resetting package..", io.Progress())
            pkg.resetRepo(repo)
            io.println(io.SuccessList(), "done reset package")
            io.newLine()
        elif inp != 'no':
            io.println(io.FailList(), "invalid input, skipped")
Exemplo n.º 9
0
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()
                   "modified files")

    io.printAsync(io.Empty(), "checking uncommitted changes in", package,
                  "\b..", io.Progress())
    uncommitted_changes = pkg.getUncommittedChanges(repo)
    if len(uncommitted_changes) > 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(uncommitted_changes),
                   "uncommitted changes")

    if package_clear:
        io.println(io.Success(), package, "({})".format(repo.active_branch),
                   "is clear")

io.printAsync(io.Empty(), "searching untracked packages..", io.Progress())
untracked_clear = True
for package in os.listdir(pkg.packages_path):
    if package in pkg.packages:
        continue

    if not pkg.packageIsDir(package):
        continue

    if not pkg.packageIsGitRepository(package):
        continue

    if untracked_clear:
    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

io.printAsync(io.Empty(), "fetching", args.package, "\b..", io.Progress())
for fetch_info in repo.remotes['origin'].fetch():
    if fetch_info.flags & git.FetchInfo.NEW_HEAD != 0:
        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")
Exemplo n.º 12
0
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()
Exemplo n.º 13
0
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)")
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())
Exemplo n.º 14
0
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()
    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

    if not avaliable_pkg:
        io.printAsync(io.Empty(), "cloning package..", io.Progress())
        try:
            repo = pkg.masterCloneRepo(package)
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()

if pkg.packageIsGitRepository(args.package):
    io.println(io.Success(), args.package, "already cloned")
    io.exitFail()

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)
        io.exitFail()

if args.branch == 'master' and not avaliable_pkg:
    io.printAsync(io.Empty(), "cloning package..", io.Progress())
    try:
        repo = pkg.masterCloneRepo(args.package)