示例#1
0
def scanarchive(filepath, jobs, cpulimit):
    removeAll(exceptions=[RESULTS_FILENAME])
    download_and_unpack(filepath)

    def keep_predicate(path):
        return os.path.splitext(path)[1] in ['.txt']
    removeLargeFiles('', keep_predicate)

    filename = filepath[filepath.rfind('/') + 1:]
    print(strfCurrTime('[%H:%M] cppcheck ') + filename)

    if cpulimit:
        cmd = 'cpulimit --limit=' + cpulimit
    else:
        cmd = 'nice --adjustment=1000'
    cmd = cmd + ' ../cppcheck-O2 -D__GCC__ --enable=style --inconclusive --error-exitcode=0 --exception-handling=stderr ' + jobs + ' .'
    cmds = cmd.split()
    cmds.append('--template={callstack}: ({severity}) {message} [{id}]')

    p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    comm = p.communicate()

    if p.returncode == 0:
        logging.info(comm[1] + strfCurrTime('[%H:%M]'))
    elif comm[0].find('cppcheck: error: could not find or open any of the paths given.') < 0:
        logging.error(comm[1] + strfCurrTime('[%H:%M]'))
        logging.error('Exit code is not zero! Crash?\n')
示例#2
0
def scanarchive(filepath, jobs):
    removeAll(exceptions=[RESULTS_FILENAME])

    download_and_unpack(filepath)

#
# List of skipped packages - which trigger known yet unresolved problems with cppcheck.
# The issues on trac (http://trac.cppcheck.net) are given for reference
# boost #3654 (?)
# flite #5975
# insight#5184
# valgrind #6151
# gcc-arm - no ticket. Reproducible timeout in daca2 though as of 1.73/early 2016.
#

    if filename[:5] == 'flite' or filename[:5] == 'boost' or filename[:7] == 'insight' or filename[:8] == 'valgrind' or filename[:7] == 'gcc-arm':
        results = open('results.txt', 'at')
        results.write('fixme: skipped package to avoid hang\n')
        results.close()
        return

    def keep_predicate(path):
        return os.path.splitext(path)[1] in ['.txt']
    removeLargeFiles('', keep_predicate)

    print('cppcheck ' + filename)

    p = subprocess.Popen(
        ['nice',
         '../cppcheck-O2',
         '--dump',
         '-D__GCC__',
         '--enable=style',
         '--error-exitcode=0',
         jobs,
         '.'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
    comm = p.communicate()

    results = open('results.txt', 'at')

    addons = sorted(glob.glob(os.path.expanduser('~/cppcheck/addons/*.py')))
    for dumpfile in sorted(dumpfiles('')):
        for addon in addons:
            if addon.find('cppcheckdata.py') > 0:
                continue

            p2 = subprocess.Popen(['nice',
                                   'python',
                                   addon,
                                   dumpfile],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
            comm = p2.communicate()
            results.write(comm[1])
    results.close()
示例#3
0
def downloadpackage(filepath, outpath):
    removeAll()
    download_and_unpack(filepath)

    def keep_predicate(path):
        return os.path.splitext(path)[1] in SOURCE_EXTENSIONS
    removeLargeFiles('', keep_predicate)

    filename = filepath[filepath.rfind('/') + 1:]

    for g in glob.glob('[#_A-Za-z0-9]*'):
        if os.path.isdir(g):
            subprocess.call(['tar', '-cJvf', outpath + filename[:filename.rfind('.')] + '.xz', g])
            break