示例#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 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