def do(args):
    """"Create a new project """
    # Try to open a worktree.
    # If not, ask the user if he wants to create one:
    qiwt = None
    try:
        qiwt = qibuild.worktree_open(args.work_tree)
    except qibuild.worktree.WorkTreeException:
        if qibuild.interact.ask_yes_no(
                "Warning, no worktree found. Create one"):
            qibuild.run_action("qibuild.actions.init", ["--interactive"])
            qiwt = qibuild.worktree_open(args.work_tree)

    project_name = args.project_name
    if qiwt:
        project_path = os.path.join(qiwt.work_tree, project_name)
    else:
        project_path = os.path.join(os.getcwd(), project_name)

    if os.path.exists(project_path):
        raise Exception("%s already exists" % project_path)
    os.mkdir(project_path)
    copy_helper(project_name, project_path)

    if args.git:
        qibuild.command.call(["git", "init"], cwd=project_path)
        with open(os.path.join(project_path, ".gitignore"), "w") as fp:
            fp.write("build-*\n")
        qibuild.command.call(["git", "add", "."], cwd=project_path)
        qibuild.command.call(["git", "commit", "-m", "initial commit"],
                             cwd=project_path)

    LOGGER.info("New project initialized in %s", project_path)
Exemplo n.º 2
0
def do(args):
    """"Create a new project """
    # Try to open a worktree.
    # If not, ask the user if he wants to create one:
    qiwt = None
    try:
        qiwt = qibuild.worktree_open(args.work_tree)
    except qibuild.worktree.WorkTreeException:
        if qibuild.interact.ask_yes_no("Warning, no worktree found. Create one"):
            qibuild.run_action("qibuild.actions.init", ["--interactive"])
            qiwt = qibuild.worktree_open(args.work_tree)

    # Module Name can be Capitalized.
    # Project Name must be lowered.
    project_name = args.project_name.lower()
    module_name  = args.project_name
    if qiwt:
        project_path = os.path.join(qiwt.work_tree, project_name)
    else:
        project_path = os.path.join(os.getcwd(), project_name)

    if os.path.exists(project_path):
        raise Exception("%s already exists" % project_path)
    os.mkdir(project_path)
    copy_helper(module_name, project_path)


    if args.git:
        qibuild.command.call(["git", "init"], cwd=project_path)
        with open(os.path.join(project_path, ".gitignore"), "w") as fp:
            fp.write("build-*\n")
        qibuild.command.call(["git" , "add" , "."], cwd=project_path)
        qibuild.command.call(["git" , "commit" , "-m" , "initial commit"], cwd=project_path)

    LOGGER.info("New project initialized in %s", project_path)
def do(args):
    """Main entry point"""
    logger = logging.getLogger(__name__)
    qiwt = qibuild.worktree_open(args.work_tree)

    if args.force:
        logger.info("preparing to remove:")
    else:
        logger.info("Build directory that will be removed (use -f to apply):")
    folders = dict()
    for project in qiwt.buildable_projects.values():
        result = list_build_folder(project, args.build_directory,
                                   qiwt.work_tree)
        for k, v in result.iteritems():
            if folders.get(k):
                folders[k].extend(v)
            else:
                folders[k] = v
    for k, v in folders.iteritems():
        logger.info(k)
        print " ", ",".join(v)
        # for p in v:
        #     print "  %s" % p

    if args.force:
        logger.info("")
        logger.info("removing:")
        for project in qiwt.buildable_projects.values():
            cleanup(project, args.build_directory, qiwt.work_tree, args.force)
Exemplo n.º 4
0
def do(args):
    """Main entry point"""
    logger   = logging.getLogger(__name__)
    qiwt     = qibuild.worktree_open(args.work_tree)

    if args.force:
        logger.info("preparing to remove:")
    else:
        logger.info("Build directory that will be removed (use -f to apply):")
    folders = dict()
    for project in qiwt.buildable_projects.values():
        result = list_build_folder(project, args.build_directory, qiwt.work_tree)
        for k, v in result.iteritems():
            if folders.get(k):
                folders[k].extend(v)
            else:
                folders[k] = v
    for k, v in folders.iteritems():
        logger.info(k)
        print " ", ",".join(v)
        # for p in v:
        #     print "  %s" % p

    if args.force:
        logger.info("")
        logger.info("removing:")
        for project in qiwt.buildable_projects.values():
            cleanup(project, args.build_directory, qiwt.work_tree, args.force)
Exemplo n.º 5
0
def do(args):
    """ Main method """
    qiwt = qibuild.worktree_open(args.work_tree)
    gitrepo = list()
    dirty = list()
    sz = len(qiwt.git_projects.values())
    i = 1
    oldsz = 0
    for git_project in qiwt.git_projects.values():
        git = qisrc.git.open(git_project)
        if sys.stdout.isatty():
            name = os.path.split(git_project)
            name = git_project if len(name) <= 0 else name[-1]
            to_write = "checking (%d/%d)" % (i, sz)
            to_write += name
            to_write += _pad(oldsz, len(name))
            sys.stdout.write(to_write + "\r")
            sys.stdout.flush()
            oldsz = len(name)
            if i == sz:
                print "checking (%d/%d): done" % (i, sz), _pad(oldsz, 2)
        i = i + 1
        if git.is_valid():
            clean = git.is_clean(untracked=args.untracked_files)
            if args.show_branch or not clean:
                gitrepo.append(git_project)
            if not clean:
                dirty.append(git_project)

    LOGGER.info("Dirty projects: %d/%d", len(dirty), len(qiwt.git_projects))

    max_len = _max_len(qiwt.work_tree, gitrepo)
    for git_project in gitrepo:
        git = qisrc.git.open(git_project)
        shortpath = os.path.relpath(git_project, qiwt.work_tree)
        if git.is_valid():
            branch = git.get_current_branch()
            tracking = git.get_tracking_branch()
            line = _add_pad(max_len, shortpath,
                            " : %s tracking %s" % (branch, tracking))
            LOGGER.info(line)
        if not git.is_clean(untracked=args.untracked_files):
            if args.untracked_files:
                (status_, out) = git.call("status", "-s", raises=False)
            else:
                (status_, out) = git.call("status", "-suno", raises=False)
            nlines = [
                x[:3] + shortpath + "/" + x[3:] for x in out.splitlines()
                if len(x.strip()) > 0
            ]
            print "\n".join(nlines)

    if not args.untracked_files:
        print
        print("Tips: use -u to show untracked files")
def do(args):
    """Main entry point"""
    qiwt = qibuild.worktree_open(args.work_tree)
    max_len = 0
    for pname, ppath in qiwt.buildable_projects.iteritems():
        if len(pname) > max_len:
            max_len = len(pname)

    for pname, ppath in qiwt.buildable_projects.iteritems():
        LOGGER.info("%s", os.path.relpath(ppath, qiwt.work_tree))
        list_build_dir(ppath)
Exemplo n.º 7
0
def do(args):
    """Main entry point"""
    qiwt = qibuild.worktree_open(args.work_tree)
    max_len = 0
    for pname, ppath in qiwt.buildable_projects.iteritems():
        if len(pname) > max_len:
            max_len = len(pname)

    for pname, ppath in qiwt.buildable_projects.iteritems():
        LOGGER.info("%s", os.path.relpath(ppath, qiwt.work_tree))
        list_build_dir(ppath)
Exemplo n.º 8
0
def do(args):
    """Main entry point"""
    qiwt = qibuild.worktree_open(args.work_tree)
    logger = logging.getLogger(__name__)
    for pname, ppath in qiwt.git_projects.iteritems():
        logger.info("Running `%s` for %s", " ".join(args.command), pname)
        try:
            qibuild.command.call(args.command, cwd=ppath)
        except qibuild.command.CommandFailedException:
            if args.ignore_errors:
                continue
            else:
                raise
def do(args):
    """Main entry point"""
    qiwt = qibuild.worktree_open(args.work_tree)
    logger = logging.getLogger(__name__)
    for pname, ppath in qiwt.git_projects.iteritems():
        logger.info("Running `%s` for %s", " ".join(args.command), pname)
        try:
            qibuild.command.call(args.command, cwd=ppath)
        except qibuild.command.CommandFailedException:
            if args.ignore_errors:
                continue
            else:
                raise
Exemplo n.º 10
0
def do(args):
    """Main entry point"""
    fail = list()
    qiwt = qibuild.worktree_open(args.work_tree)
    toc  = qibuild.toc_open(args.work_tree, args)

    manifest = toc.config.local.manifest
    if manifest:
        try:
            qibuild.run_action("qisrc.actions.fetch",
                args=[manifest.url],
                forward_args=args)
        except Exception, e:
            mess  = "Could not run qisrc fetch\n"
            mess += "Error was: %s\n" % e
            LOGGER.warning(mess)
Exemplo n.º 11
0
def do(args):
    """Main entry point"""
    fail = list()
    qiwt = qibuild.worktree_open(args.work_tree)
    toc = qibuild.toc_open(args.work_tree, args)

    manifest = toc.config.local.manifest
    if manifest:
        try:
            qibuild.run_action("qisrc.actions.fetch",
                               args=[manifest.url],
                               forward_args=args)
        except Exception, e:
            mess = "Could not run qisrc fetch\n"
            mess += "Error was: %s\n" % e
            LOGGER.warning(mess)
Exemplo n.º 12
0
def do(args):
    """ Main method """
    qiwt = qibuild.worktree_open(args.work_tree)
    gitrepo = list()
    dirty = list()
    sz = len(qiwt.git_projects.values())
    i = 1
    oldsz = 0
    for git_project in qiwt.git_projects.values():
        git = qisrc.git.open(git_project)
        if sys.stdout.isatty():
            name = os.path.split(git_project)
            name = git_project if len(name) <= 0 else name[-1]
            print "checking (%d/%d): " % (i, sz), name, _pad(oldsz, len(name)), "\r",
            oldsz = len(name)
            if i == sz:
                print "checking (%d/%d): done" % (i, sz), _pad(oldsz, 2)
        i = i + 1
        if git.is_valid():
            clean = git.is_clean(untracked=args.untracked_files)
            if args.show_branch or not clean:
                gitrepo.append(git_project)
            if not clean:
                dirty.append(git_project)

    LOGGER.info("Dirty projects: %d/%d", len(dirty), len(qiwt.git_projects))

    max_len = _max_len(qiwt.work_tree, gitrepo)
    for git_project in gitrepo:
        git = qisrc.git.open(git_project)
        shortpath = os.path.relpath(git_project, qiwt.work_tree)
        if git.is_valid():
            line = _add_pad(max_len, shortpath, " : %s tracking %s" % (git.get_current_branch(), git.get_tracking_branch()))
            LOGGER.info(line)
        if not git.is_clean(untracked=args.untracked_files):
            if args.untracked_files:
                lines = git.cmd.call_output("status", "-s")
            else:
                lines = git.cmd.call_output("status", "-suno")
            nlines = [ x[:3] + shortpath + "/" + x[3:] for x in lines if len(x.strip()) > 0 ]
            print "\n".join(nlines)


    if not args.untracked_files:
        print
        print("Tips: use -u to show untracked files")
Exemplo n.º 13
0
def do(args):
    """Main entry point

    """
    toc = qibuild.toc.toc_open(args.work_tree)
    if args.url:
        manifest_url = args.url
    else:
        manifest = toc.config.local.manifest
        if manifest is None:
            mess = "Could not find URL fo fetch from.\n"
            mess += "Here is what you can do:\n"
            mess += " - specify an URL from the command line\n"
            mess += " - edit %s to have: \n\n" % toc.config_path
            mess += """<qibuild>
            <manifest
                url = ftp://example.com/foo.manifest
            />
</qibuild>
"""
            raise Exception(mess)
        manifest_url = manifest.url

    qiwt = qibuild.worktree_open(args.work_tree)

    projects = qisrc.parse_manifest(manifest_url)
    for (project_name, project_url) in projects.iteritems():
        if project_name not in qiwt.git_projects.keys():
            qibuild.run_action("qisrc.actions.add",
                               [project_url, project_name])
        else:
            p_path = qiwt.git_projects[project_name]
            LOGGER.info("Found project %s, skipping", project_name)

    # Everything went fine, store the manifest URL for later use:
    toc.config.set_manifest_url(manifest_url)
    toc.save_config()
Exemplo n.º 14
0
def do(args):
    """Main entry point

    """
    toc = qibuild.toc.toc_open(args.work_tree)
    if args.url:
        manifest_url = args.url
    else:
        manifest = toc.config.local.manifest
        if manifest is None:
            mess  = "Could not find URL fo fetch from.\n"
            mess += "Here is what you can do:\n"
            mess += " - specify an URL from the command line\n"
            mess += " - edit %s to have: \n\n" % toc.config_path
            mess += """<qibuild>
            <manifest
                url = ftp://example.com/foo.manifest
            />
</qibuild>
"""
            raise Exception(mess)
        manifest_url = manifest.url

    qiwt = qibuild.worktree_open(args.work_tree)

    projects = qisrc.parse_manifest(manifest_url)
    for (project_name, project_url) in projects.iteritems():
        if project_name not in qiwt.git_projects.keys():
            qibuild.run_action("qisrc.actions.add", [project_url, project_name])
        else:
            p_path = qiwt.git_projects[project_name]
            LOGGER.info("Found project %s, skipping", project_name)

    # Everything went fine, store the manifest URL for later use:
    toc.config.set_manifest_url(manifest_url)
    toc.save_config()