Exemple #1
0
def download_cbns(args):
    cs = CS.get(CS.name == args.cs)
    dir_name = 'binaries-cs-%s' % cs.name
    quiet_mkdir(dir_name)

    first = True
    shas = set()
    tm = CSF.cbns.get_through_model()
    for fielding in (CSF.select(
            CSF, Team, Round, tm).join(Team).switch(CSF).join(
                Round, on=(Round.id == CSF.available_round
                           )).switch(CSF).join(tm).join(CBN).where(
                               CSF.cs == cs).order_by(Round.created_at)):
        if first:
            name = "original"
            first = False
        else:
            name = "team-%s" % fielding.team.name

        quiet_mkdir(os.path.join(dir_name, name))

        print "before loop..."
        for cbn in fielding.cbns:
            print "in loop"
            if cbn.sha256 in shas:
                print "already saw this one!"
                continue

            with open(
                    os.path.join(
                        dir_name, name,
                        name + "_round-%s-" % fielding.available_round.num +
                        cbn.name.replace('/', '_')), 'wb') as f:
                f.write(cbn.blob)
            shas.add(cbn.sha256)

    our_patches = os.path.join(dir_name, 'our-patches')
    quiet_mkdir(our_patches)
    for cbn in CBN.select().where(CBN.cs == cs, ~(CBN.sha256.in_(shas))):
        with open(
                os.path.join(our_patches,
                             cbn.name.replace('/', '_') + "-" + cbn.sha256),
                'wb') as f:
            f.write(cbn.blob)
Exemple #2
0
def fieldings(args):
    for cs in CSF.select().join(CS.fielded_in_round(round_=args.round)).where(
            CSF.submission_round):
        pass