Example #1
0
def resolve_errors(gen, title=None, errorMsg=None, errorHandling=None):
    printed = False
    error = False
    if title is not None:
        print BOLD(title)
    for submodule, ret in gen:
        if ret[1] is not None:
            printed = True
            error = True
            print "%s:%s\n%s\n%s\n" % (
            UNDERLINE("ERROR for " + submodule), FILLER, ret[0] + "\n" if ret[0] is not None else "", RED(ret[1]))
        else:
            if ret[0] is not None and len(ret[0].strip()) > 0:
                printed = True
                print "%s:%s\n%s" % (UNDERLINE(submodule), FILLER, ret[0])
            else:
                printp(submodule)
    if not printed:
        print "ALL DONE" + FILLER
    if error:
        if errorMsg is not None:
            print RED(errorMsg)
        if errorHandling is not None and callable(errorHandling):
            errorHandling()
    return not error
Example #2
0
def resolve_errors(gen, title=None, errorMsg=None, errorHandling=None):
    printed = False
    error = False
    if title is not None:
        print BOLD(title)
    for submodule, ret in gen:
        if ret[1] is not None:
            printed = True
            error = True
            print "%s:%s\n%s\n%s\n" % (
                UNDERLINE("ERROR for " + submodule),
                FILLER,
                ret[0] + "\n" if ret[0] is not None else "",
                RED(ret[1]),
            )
        else:
            if ret[0] is not None and len(ret[0].strip()) > 0:
                printed = True
                print "%s:%s\n%s" % (UNDERLINE(submodule), FILLER, ret[0])
            else:
                printp(submodule)
    if not printed:
        print "ALL DONE" + FILLER
    if error:
        if errorMsg is not None:
            print RED(errorMsg)
        if errorHandling is not None and callable(errorHandling):
            errorHandling()
    return not error
Example #3
0
    def delete_merged_local(self):
        printp("Deleting merged local branches...")
        branches, _ = gitcmd(["branch", "--no-color", "--merged", "origin/master"])
        branch_list = branches.split("\n")
        branch_list = map(str.strip, branch_list)
        branch_list = [x.strip() for x in branch_list if (x not in self.PROTECTED and not "*" in x)]
        deleted_branches = list()
        for branch in branch_list:
            if self.should_delete(branch):
                deleted_branches.append(branch)
                if not self.dry_run:
                    gitcmd(["branch", "-d", branch])

        return deleted_branches
Example #4
0
    def delete_merged_local(self):
        printp('Deleting merged local branches...')
        branches, _ = gitcmd(['branch', '--no-color', '--merged', 'origin/master'])
        branch_list = branches.split('\n')
        branch_list = map(str.strip, branch_list)
        branch_list = [x.strip() for x in branch_list if (x not in self.PROTECTED and not '*' in x)]
        deleted_branches = list()
        for branch in branch_list:
            if self.should_delete(branch):
                deleted_branches.append(branch)
                if not self.dry_run:
                    gitcmd(['branch', '-d', branch])

        return deleted_branches
Example #5
0
    def delete_merged_remote(self):
        printp("Deleting local refs to remote branches that don't exist...")
        gitcmd(["remote", "prune", "origin"])
        printp("Deleting merged remote branches...")
        branches, _ = gitcmd(["branch", "-r", "--no-color", "--merged", "origin/master"])
        branch_list = branches.split()
        branch_list = map(str.strip, branch_list)
        if branch_list:
            branch_list = [x.strip() for x in branch_list if (x not in self.PROTECTED and not "*" in x)]

        deleted_branches = list()
        trimmed_branches = list()
        for branch in branch_list:
            if self.should_delete(branch):
                deleted_branches.append(branch)
                split = branch.split("/")
                trimmed_branches.append(split[1])

        if not self.dry_run:
            gitcmd(["push", "origin", "--delete"] + trimmed_branches)
        return deleted_branches
Example #6
0
    def delete_merged_remote(self):
        printp("Deleting local refs to remote branches that don't exist...")
        gitcmd(['remote', 'prune', 'origin'])
        printp('Deleting merged remote branches...')
        branches, _ = gitcmd(['branch', '-r', '--no-color', '--merged', 'origin/master'])
        branch_list = branches.split()
        branch_list = map(str.strip, branch_list)
        if branch_list:
            branch_list = [x.strip() for x in branch_list if (x not in self.PROTECTED and not '*' in x)]

        deleted_branches = list()
        trimmed_branches = list()
        for branch in branch_list:
            if self.should_delete(branch):
                deleted_branches.append(branch)
                split = branch.split('/')
                trimmed_branches.append(split[1])

        if not self.dry_run:
            gitcmd(['push', 'origin', '--delete'] + trimmed_branches)
        return deleted_branches
Example #7
0
game_worker = os.path.join(basedir, 'python_starter_package', 'tools', 'PlayGame.jar')

cmdline = """java -jar %s %s 1000 1000 log.txt "%s" "%s" """
### end of config

logger = logging.getLogger("tournament")
hdlr = logging.FileHandler('tournament.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
logger.info("Starting")

if os.path.isfile(game_worker):
    common.printp("Game worker")
else:
    raise Exception("Game worker not found: %s" % game_worker)

my_env = os.environ.copy()
my_env["PYTHONPATH"] = my_env.get("PYTHONPATH","") + ":" + envstr
semaphore = threading.Semaphore()
results = [0,0]

def merge_results(a,b):
    return [sum(i) for i in zip(a,b)]

def genBotStartCmd(botpath):
    if botpath.endswith('.jar'):
        return "java -jar %s" % botpath
    elif botpath.endswith('.py'):