예제 #1
0
def main():
    Args.valid_anywhere = ["help"]
    Args.valid_options = ["version", "verbose", "strict"]
    Args.valid_commands = []
    Args.valid_keys = []
    #Args.command_aliases = {"?":"help", "ls":"list"}
    Args.process()
예제 #2
0
def main():
    # interactive lets you check each flag for the plug-in while projects are being built
    Args.valid_options = ["?", "help", "interactive", "warn", "verbose", "edit", "overwrite", "remove", "list"]
    Args.valid_keys = ["separator-char", "switch-char", "type-default", "switch-default", "title"] # --ignore=context
    Args.process()

    set_program_name(Args.value("title"))

    if Args.option("help") or Args.option("?"):
        help()
        return

    # check for bad options (not yet implemented)
    for bad in ("interactive", "warn", "remove", "edit"):
        if Args.option(bad):
            error("option '%s' not yet implemented" % bad)
            return
    
    # loop through provided filenames
    if Args.filenames:
        for fn in Args.filenames:
            try:
                t = Project(fn)
            except Exception as e:
                error(e)
            #except Exception as e:
            #    return
            # if t:
    else:
        error("missing file operand" % program_name())
        return
예제 #3
0
def main():
    Args.valid_anywhere= ["help"]
    Args.valid_options = ["version", "verbose", "strict"]
    Args.valid_commands = []
    Args.valid_keys = []
    #Args.command_aliases = {"?":"help", "ls":"list"}
    Args.process()
예제 #4
0
def main():
    # interactive lets you check each flag for the plug-in while projects are being built
    Args.valid_options = [
        "?", "help", "interactive", "warn", "verbose", "edit", "overwrite",
        "remove", "list"
    ]
    Args.valid_keys = [
        "separator-char", "switch-char", "type-default", "switch-default",
        "title"
    ]  # --ignore=context
    Args.process()

    set_program_name(Args.value("title"))

    if Args.option("help") or Args.option("?"):
        help()
        return

    # check for bad options (not yet implemented)
    for bad in ("interactive", "warn", "remove", "edit"):
        if Args.option(bad):
            error("option '%s' not yet implemented" % bad)
            return

    # loop through provided filenames
    if Args.filenames:
        for fn in Args.filenames:
            try:
                t = Project(fn)
            except Exception as e:
                error(e)
            #except Exception as e:
            #    return
            # if t:
    else:
        error("missing file operand" % program_name())
        return
예제 #5
0
def main():
    Args.valid_options = ["clean", "list", "debug", "version", "verbose", "strict", "warn", "recursive", "reversive", "execute", "x"] #, "interactive", "cache"
    Args.valid_keys = ["ignore"]
    Args.process()

    # process the build step plugins
    try:
        steps.ignore(Args.value("ignore").split(",")) # disable requested steps
    except AttributeError:
        pass
    steps.process()
    events.process()

    if Args.option("version"):
        splash()
        return 0
    if Args.option("help") or Args.option("?"):
        help()
        return 0
    
    # count of projects succeeded and failed
    success_count = 0
    failed_count = 0

    # if no project filenames are specified, we'll use the current directory (".")
    if not Args.filenames:
        Args.filenames = ["."]

    # check for forward recusion and backward scan settings
    recursive = Args.option("recursive")
    reversive = True
    #reversive = Args.option("reversive")
    execute = Args.option("x") or Args.option("execute")
    
    event("status", "start")

    if recursive:
        # TODO this recursion sucks, fix it later
        # recurse through directories until you find project(s)
        for fn in Args.filenames:
            if fn.startswith(".") and fn != "." and fn != "..":
                continue
            r = 0
            for root, dirs, files in os.walk(fn):
                stop_recurse = False
                for d in dirs:
                    base =  os.path.basename(os.path.join(root,d))
                    if base.startswith(".") and base != ".":
                        continue

                    #print os.path.normpath(os.path.join(root,d))
                    r = try_project(os.path.normpath(os.path.join(root, d)))
                    if r == 1:
                        if not Args.option("list"):
                            success_count += 1
                        stop_recurse = True
                    elif r == -1:
                        if not Args.option("list"):
                            failed_count += 1
                if stop_recurse:
                    dirs[:] = []
                
    elif reversive:
        # TODO search for project by iterating dirs backwards
        # To be used build a sgmake project from within a nested directory or source editor

        for fn in Args.filenames:
            path = os.path.abspath(os.path.join(os.getcwd(), fn))
            
            while os.path.realpath(path) != os.path.expanduser('~'):
            #while os.path.realpath(path) != os.path.realpath(os.path.join(path, "..")): # is root

                r = try_project(os.path.normpath(path))
                if r == 1:
                    if not Args.option("list"):
                        success_count += 1
                    break
                elif r == -1:
                    if not Args.option("list"):
                        failed_count += 1
                    break

                path = os.path.realpath(os.path.join(path, ".."))
            #print "done: %s" % path
    #else:
    #    # try to build projects specified by the user, current dir is default
    #    for fn in Args.filenames:
    #        r = try_project(os.path.join(os.getcwd(),fn))
    #        if r == 1:
    #            success_count += 1
    #        elif r == -1:
    #            failed_count += 1


    if not Args.command("list"):
        # if not in list-only mode, display final status of built projects
        
        if success_count:
            print("%s project(s) completed." % success_count)
            if not failed_count:
                event("status", "success")
                return 0
            else:
                return 1
        if failed_count:
            print("%s project(s) failed." % failed_count)
            event("status", "failure")
            return 1
        elif not success_count and not failed_count:
            event("status", "nothing")
            print("Nothing to be done.")
            return 1
    
    return 0
예제 #6
0
def main():
    Args.valid_options = [
        "clean", "list", "debug", "version", "verbose", "strict", "warn",
        "recursive", "reversive", "execute", "x"
    ]  #, "interactive", "cache"
    Args.valid_keys = ["ignore"]
    Args.process()

    # process the build step plugins
    try:
        steps.ignore(
            Args.value("ignore").split(","))  # disable requested steps
    except AttributeError:
        pass
    steps.process()
    events.process()

    if Args.option("version"):
        splash()
        return 0
    if Args.option("help") or Args.option("?"):
        help()
        return 0

    # count of projects succeeded and failed
    success_count = 0
    failed_count = 0

    # if no project filenames are specified, we'll use the current directory (".")
    if not Args.filenames:
        Args.filenames = ["."]

    # check for forward recusion and backward scan settings
    recursive = Args.option("recursive")
    reversive = True
    #reversive = Args.option("reversive")
    execute = Args.option("x") or Args.option("execute")

    event("status", "start")

    if recursive:
        # TODO this recursion sucks, fix it later
        # recurse through directories until you find project(s)
        for fn in Args.filenames:
            if fn.startswith(".") and fn != "." and fn != "..":
                continue
            r = 0
            for root, dirs, files in os.walk(fn):
                stop_recurse = False
                for d in dirs:
                    base = os.path.basename(os.path.join(root, d))
                    if base.startswith(".") and base != ".":
                        continue

                    #print os.path.normpath(os.path.join(root,d))
                    r = try_project(os.path.normpath(os.path.join(root, d)))
                    if r == 1:
                        if not Args.option("list"):
                            success_count += 1
                        stop_recurse = True
                    elif r == -1:
                        if not Args.option("list"):
                            failed_count += 1
                if stop_recurse:
                    dirs[:] = []

    elif reversive:
        # TODO search for project by iterating dirs backwards
        # To be used build a sgmake project from within a nested directory or source editor

        for fn in Args.filenames:
            path = os.path.abspath(os.path.join(os.getcwd(), fn))

            while os.path.realpath(path) != os.path.expanduser('~'):
                #while os.path.realpath(path) != os.path.realpath(os.path.join(path, "..")): # is root

                r = try_project(os.path.normpath(path))
                if r == 1:
                    if not Args.option("list"):
                        success_count += 1
                    break
                elif r == -1:
                    if not Args.option("list"):
                        failed_count += 1
                    break

                path = os.path.realpath(os.path.join(path, ".."))
            #print "done: %s" % path
    #else:
    #    # try to build projects specified by the user, current dir is default
    #    for fn in Args.filenames:
    #        r = try_project(os.path.join(os.getcwd(),fn))
    #        if r == 1:
    #            success_count += 1
    #        elif r == -1:
    #            failed_count += 1

    if not Args.command("list"):
        # if not in list-only mode, display final status of built projects

        if success_count:
            print("%s project(s) completed." % success_count)
            if not failed_count:
                event("status", "success")
                return 0
            else:
                return 1
        if failed_count:
            print("%s project(s) failed." % failed_count)
            event("status", "failure")
            return 1
        elif not success_count and not failed_count:
            event("status", "nothing")
            print("Nothing to be done.")
            return 1

    return 0