def find_big_files(fatal=True):
    #load the exception file
    exceptions = set()
    with open('travis_file_exceptions', 'rU') as e:
        for L in e:
            exceptions.add(tuple(map(str.strip, L.split())))

    revisions = getOutput("git rev-list HEAD").split()
    violations = set()
    for r in revisions:
        tree = getOutput("git ls-tree -rlz {}".format(r)).split("\0")
        for obj in tree:
            try:
                data = obj.split()
                commit, size, name = data[2], int(data[3]), data[4]
                if (commit, name) not in exceptions and size > MAX_FILESIZE:
                    violations.add((size, name, commit))
            except (IndexError, ValueError):
                continue

    if violations:
        for v in sorted(violations, reverse=True):
            print "{} {} {}".format(*v)
        tc.raise_msg("Large files present",
                     fatal=fatal,
                     category=tc.BuildWarning)
示例#2
0
def find_big_files(fatal=True):

    # Load the names of the files listed in the exceptions file.
    with open('travis_file_exceptions', 'rU') as ex:
        approved_files = {name for name in ex.read().split('\n') if name != ""}
    
    # Get the objects in the tree at the most recent commit.
    this_commit = getOutput("git rev-list HEAD").split()[0]
    tree = getOutput("git ls-tree -rlz {}".format(this_commit)).split("\0")

    # Check that the objects in the tree are not too big.
    violations = set()
    for obj in tree:
        try:
            data = obj.split()
            size, name = int(data[3]), data[4]
            if name not in approved_files and size > MAX_FILESIZE:
                violations.add((name, size))
        except (IndexError, ValueError):
            continue
    
    if violations:
        files = "\n".join(sorted(["\t{:.<50}{:.>20} bytes".format(*v)
                                                        for v in violations]))
        raise_msg("Large files present:\n{}\n".format(files), fatal=fatal)
示例#3
0
def find_big_files(fatal=True):

    # Load the names of the files listed in the exceptions file.
    with open('travis_file_exceptions', 'rU') as ex:
        approved_files = {name for name in ex.read().split('\n') if name != ""}

    # Get the objects in the tree at the most recent commit.
    this_commit = getOutput("git rev-list HEAD").split()[0]
    tree = getOutput("git ls-tree -rlz {}".format(this_commit)).split("\0")

    # Check that the objects in the tree are not too big.
    violations = set()
    for obj in tree:
        try:
            data = obj.split()
            size, name = int(data[3]), data[4]
            if name not in approved_files and size > MAX_FILESIZE:
                violations.add((name, size))
        except (IndexError, ValueError):
            continue

    if violations:
        files = "\n".join(
            sorted(["\t{:.<50}{:.>20} bytes".format(*v) for v in violations]))
        raise_msg("Large files present:\n{}\n".format(files), fatal=fatal)
示例#4
0
def all_present(fatal=True):
    try:
        assert isfile("Vol1.pdf"), "Vol1.pdf is missing"
        assert isfile("Vol2.pdf"), "Vol2.pdf is missing"
        assert isfile("Vol3.pdf"), "Vol3.pdf is missing"
        assert isfile("Vol4.pdf"), "Vol4.pdf is missing"
        assert isfile("ExtraLabs.pdf"), "ExtraLabs.pdf is missing"
    except AssertionError as e:
        raise_msg(e, fatal)
示例#5
0
def all_present(fatal=True):
    try:
        assert isfile("Vol1.pdf"), "Vol1.pdf is missing"
        assert isfile("Vol2.pdf"), "Vol2.pdf is missing"
        assert isfile("Vol3.pdf"), "Vol3.pdf is missing"
        assert isfile("Vol4.pdf"), "Vol4.pdf is missing"
        assert isfile("ExtraLabs.pdf"), "ExtraLabs.pdf is missing"
    except AssertionError as e:
        raise_msg(e, fatal)
示例#6
0
def find_big_files(fatal=True):
    #load the exception file
    exceptions = set()
    with open('travis_file_exceptions', 'rU') as e:
        for L in e:
            exceptions.add(tuple(map(str.strip, L.split())))
        
    revisions = getOutput("git rev-list HEAD").split()
    violations = set()
    for r in revisions:
        tree = getOutput("git ls-tree -rlz {}".format(r)).split("\0")
        for obj in tree:
            try:
                data = obj.split()
                commit, size, name = data[2], int(data[3]), data[4]
                if (commit, name) not in exceptions and size > MAX_FILESIZE:
                    violations.add((size, commit, name))
            except (IndexError, ValueError):
                continue
    
    if violations:
        for v in sorted(violations, reverse=True):
            print "{} {} {}".format(*v)
        tc.raise_msg("Large files present", fatal=fatal, category=tc.BuildWarning)