Exemplo n.º 1
0
 def run(self):
     while True:
         event = self.queue.get()
         events.process(event, self.list)
         self.queue.task_done()
Exemplo n.º 2
0
 def run(self):
     while True:
         event = self.queue.get()
         events.process(event, self.list)
         self.queue.task_done()
Exemplo n.º 3
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
Exemplo n.º 4
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