2017-06-04 22:51:48 +02:00
|
|
|
#!/usr/bin/env python
|
2015-08-20 12:57:45 +02:00
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import pexpect
|
|
|
|
import os
|
|
|
|
import sys
|
2017-10-03 17:37:08 +02:00
|
|
|
import time
|
2015-08-20 12:57:45 +02:00
|
|
|
|
2018-08-07 09:18:41 +02:00
|
|
|
BASE = '1.84'
|
|
|
|
|
2017-06-03 11:34:11 +02:00
|
|
|
def compilecppcheck(CPPFLAGS):
|
|
|
|
subprocess.call(['nice', 'make', 'clean'])
|
2017-06-04 22:51:48 +02:00
|
|
|
subprocess.call(['nice', 'make', 'SRCDIR=build', 'CFGDIR=' +
|
|
|
|
os.path.expanduser('~/cppcheck/cfg'), 'CXXFLAGS=-g -O2', 'CPPFLAGS=' + CPPFLAGS])
|
2018-06-28 22:35:48 +02:00
|
|
|
subprocess.call(['cp', 'cppcheck', os.path.expanduser('~/daca2/cppcheck-head')])
|
2017-06-03 11:34:11 +02:00
|
|
|
|
2017-06-04 22:51:48 +02:00
|
|
|
|
2017-06-04 14:05:34 +02:00
|
|
|
def runcppcheck(rev, folder):
|
2017-06-03 11:34:11 +02:00
|
|
|
subprocess.call(['rm', '-rf', os.path.expanduser('~/daca2/' + folder)])
|
2017-06-04 22:51:48 +02:00
|
|
|
subprocess.call(['nice', '--adjustment=19', 'python',
|
2018-06-21 09:26:06 +02:00
|
|
|
os.path.expanduser('~/cppcheck/tools/daca2.py'), folder, '--rev=' + rev,
|
2018-08-07 09:18:41 +02:00
|
|
|
'--baseversion='+BASE, '--skip=hashdeep', '--skip=lice'])
|
2017-06-04 22:51:48 +02:00
|
|
|
|
2017-06-03 12:10:41 +02:00
|
|
|
|
2017-06-04 14:05:34 +02:00
|
|
|
def daca2report(reportfolder):
|
2017-06-03 12:10:41 +02:00
|
|
|
subprocess.call(['rm', '-rf', reportfolder])
|
|
|
|
subprocess.call(['mkdir', reportfolder])
|
2017-06-04 14:05:34 +02:00
|
|
|
subprocess.call(['python', os.path.expanduser('~/cppcheck/tools/daca2-report.py'), reportfolder])
|
2017-06-03 11:34:11 +02:00
|
|
|
|
2017-06-04 22:51:48 +02:00
|
|
|
|
2017-06-03 11:34:11 +02:00
|
|
|
# Upload file to sourceforge server using scp
|
2018-08-06 13:37:42 +02:00
|
|
|
def upload(localfolder, webfolder, password):
|
|
|
|
if len(password) < 3:
|
2017-06-03 15:53:43 +02:00
|
|
|
return
|
2017-09-28 09:57:13 +02:00
|
|
|
tries = 1
|
|
|
|
while tries <= 5:
|
|
|
|
try:
|
|
|
|
child = pexpect.spawn(
|
|
|
|
'scp -r ' + localfolder + ' danielmarjamaki,cppcheck@web.sf.net:htdocs/' + webfolder)
|
|
|
|
# child.expect('upload@trac.cppcheck.net\'s password:')
|
|
|
|
child.expect('Password:')
|
2018-08-06 13:37:42 +02:00
|
|
|
child.sendline(password)
|
2017-09-28 09:57:13 +02:00
|
|
|
child.interact()
|
|
|
|
return
|
|
|
|
except (IOError, OSError, pexpect.TIMEOUT, pexpect.EOF):
|
2018-06-29 11:27:49 +02:00
|
|
|
print('rundaca2.py: Upload failed. Sleep for 10 seconds..')
|
2017-09-28 09:57:13 +02:00
|
|
|
time.sleep(10)
|
|
|
|
tries = tries + 1
|
2015-08-20 12:57:45 +02:00
|
|
|
|
2018-08-07 09:18:41 +02:00
|
|
|
def getDate(filename):
|
|
|
|
for line in open(filename):
|
2018-08-07 09:19:33 +02:00
|
|
|
if line.startswith('DATE '):
|
2018-08-07 09:18:41 +02:00
|
|
|
return line[5:]
|
|
|
|
return None
|
2015-08-21 10:55:19 +02:00
|
|
|
|
2018-08-07 09:18:41 +02:00
|
|
|
def getFolderNum():
|
|
|
|
folders = '0123456789abcdefghijklmnopqrstuvwxyz'
|
|
|
|
oldestDate = None
|
|
|
|
oldestFolderNum = 0
|
|
|
|
for folderNum in range(len(folders)):
|
|
|
|
folder = folders[folderNum]
|
|
|
|
path = os.path.expanduser('~/daca2/' + folder)
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
if folder == '0' or folder >= 'a':
|
|
|
|
return folderNum
|
|
|
|
continue
|
|
|
|
if not os.path.isfile(path + '/results-head.txt'):
|
|
|
|
return folderNum
|
|
|
|
if not os.path.isfile(path + '/results-'+BASE+'.txt'):
|
|
|
|
return folderNum
|
|
|
|
d1 = getDate(path + '/results-head.txt')
|
|
|
|
if d1 is None: # results are unfinished so they need to be recreated
|
|
|
|
return folderNum
|
|
|
|
d2 = getDate(path + '/results-'+BASE+'.txt')
|
|
|
|
if d2 is None: # results are unfinished so they need to be recreated
|
|
|
|
return folderNum
|
|
|
|
if oldestDate is None or d1 < oldestDate:
|
|
|
|
oldestDate = d1
|
|
|
|
oldestFolderNum = folderNum
|
|
|
|
if d2 < oldestDate:
|
|
|
|
oldestDate = d2
|
|
|
|
oldestFolderNum = folderNum
|
|
|
|
|
|
|
|
return oldestFolderNum
|
|
|
|
|
|
|
|
|
|
|
|
def daca2(folderNum, password):
|
2015-08-20 12:57:45 +02:00
|
|
|
folders = '0123456789abcdefghijklmnopqrstuvwxyz'
|
2018-08-07 09:18:41 +02:00
|
|
|
folder = folders[folderNum % len(folders)]
|
2015-08-20 12:57:45 +02:00
|
|
|
|
|
|
|
print('Daca2 folder=' + folder)
|
|
|
|
|
|
|
|
os.chdir(os.path.expanduser('~/cppcheck'))
|
2017-06-03 12:10:41 +02:00
|
|
|
subprocess.call(['git', 'pull'])
|
2015-08-20 12:57:45 +02:00
|
|
|
p = subprocess.Popen(['git', 'show', '--format=%h'],
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
comm = p.communicate()
|
|
|
|
rev = comm[0]
|
|
|
|
rev = rev[:rev.find('\n')]
|
|
|
|
|
2018-06-28 22:35:48 +02:00
|
|
|
print('rundaca2.py: compile cppcheck')
|
2017-06-04 14:05:34 +02:00
|
|
|
compilecppcheck('-DMAXTIME=600 -DDACA2')
|
2018-06-28 22:35:48 +02:00
|
|
|
|
|
|
|
print('rundaca2.py: runcppcheck')
|
2017-06-04 14:05:34 +02:00
|
|
|
runcppcheck(rev, folder)
|
2017-06-04 14:09:41 +02:00
|
|
|
runcppcheck(rev, 'lib' + folder)
|
2018-06-28 22:35:48 +02:00
|
|
|
|
|
|
|
print('rundaca2.py: daca2 report')
|
2017-06-04 14:05:34 +02:00
|
|
|
daca2report(os.path.expanduser('~/daca2-report'))
|
2018-06-28 22:35:48 +02:00
|
|
|
|
|
|
|
print('rundaca2.py: upload')
|
2018-08-06 13:37:42 +02:00
|
|
|
upload(os.path.expanduser('~/daca2-report'), 'devinfo/', password)
|
2015-08-21 15:46:10 +02:00
|
|
|
|
2018-08-06 13:37:42 +02:00
|
|
|
|
|
|
|
print('enter password:')
|
|
|
|
password = sys.stdin.readline().rstrip()
|
2018-08-07 09:18:41 +02:00
|
|
|
folderNum = getFolderNum()
|
2015-08-20 12:57:45 +02:00
|
|
|
while True:
|
2018-08-07 09:18:41 +02:00
|
|
|
daca2(folderNum, password)
|
|
|
|
folderNum = folderNum + 1
|
2018-08-06 13:37:42 +02:00
|
|
|
|