Пример #1
0
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")

    io.exitSuccess()

io.printAsync(io.Empty(), "checking executable..", io.Progress())
if io.runCommandMuted("screen -ls | grep {}__{}".format(
        args.package, args.executable)):
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()
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:
        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()
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)
    io.exitSuccess()

string = io.scanln(io.Warn(), "are you sure you want to reset", args.package,
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())
untracked_files = repo.untracked_files
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")
        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")
Пример #7
0
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())

try:
    committed_time = datetime.datetime.fromtimestamp(
        repo.head.commit.committed_date)
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:
    io.println(io.Fail(), args.package, "does not have origin remote")
    io.exitFail()
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

    repo = pkg.getPackageRepo(package)

    package_clear = True

    io.printAsync(io.Empty(), "checking untracked files in", package, "\b..",
Пример #10
0
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))

if len(commits) < 1:
  io.println(io.Warn(), "no commit found in", args.package)
Пример #11
0
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)")
io.newLine()

if string == 'no':
  io.println(io.Fail(), "cancelled")
  io.exitFail()
elif string != 'yes':
Пример #12
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()