2013-11-02 17:39:42 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# continuous integration
|
|
|
|
# build daily reports (doxygen,coverage,etc)
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
import time
|
|
|
|
import subprocess
|
|
|
|
import pexpect
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import urllib
|
|
|
|
|
|
|
|
|
|
|
|
# Upload file to sourceforge web server using scp
|
|
|
|
def upload(file_to_upload, destination):
|
|
|
|
try:
|
|
|
|
password = sys.argv[1]
|
|
|
|
child = pexpect.spawn(
|
|
|
|
'scp ' + file_to_upload + ' danielmarjamaki,cppcheck@web.sourceforge.net:' + destination)
|
2014-02-20 10:03:55 +01:00
|
|
|
# child.expect(
|
2013-12-13 06:57:08 +01:00
|
|
|
# 'danielmarjamaki,cppcheck@web.sourceforge.net\'s password:')
|
|
|
|
child.expect('Password:')
|
2013-11-02 17:39:42 +01:00
|
|
|
child.sendline(password)
|
|
|
|
child.interact()
|
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
except pexpect.TIMEOUT:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# git push
|
|
|
|
def gitpush():
|
|
|
|
try:
|
|
|
|
password = sys.argv[1]
|
|
|
|
child = pexpect.spawn('git push')
|
|
|
|
child.expect("Enter passphrase for key '/home/daniel/.ssh/id_rsa':")
|
|
|
|
child.sendline(password)
|
|
|
|
child.interact()
|
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
except pexpect.TIMEOUT:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def iconv(filename):
|
|
|
|
p = subprocess.Popen(['file', '-i', filename],
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
|
|
comm = p.communicate()
|
|
|
|
if comm[0].find('charset=iso-8859-1') >= 0:
|
|
|
|
subprocess.call(
|
|
|
|
["iconv", filename, "--from=ISO-8859-1", "--to=UTF-8", "-o", filename])
|
|
|
|
|
|
|
|
|
|
|
|
# Generate daily webreport
|
|
|
|
def generate_webreport():
|
|
|
|
filenames = glob.glob('*/*.cpp')
|
|
|
|
for filename in filenames:
|
|
|
|
iconv(filename)
|
|
|
|
subprocess.call(
|
|
|
|
["git", "commit", "-a", "-m", '"automatic conversion from iso-8859-1 formatting to utf-8"'])
|
|
|
|
gitpush()
|
|
|
|
|
|
|
|
subprocess.call(["rm", "-rf", "devinfo"])
|
|
|
|
subprocess.call(['nice', "./webreport.sh"])
|
|
|
|
upload('-r devinfo', 'htdocs/')
|
|
|
|
subprocess.call(["make", "clean"])
|
|
|
|
subprocess.call(["rm", "-rf", "devinfo"])
|
|
|
|
|
|
|
|
|
|
|
|
# Perform a git pull.
|
|
|
|
def gitpull():
|
|
|
|
try:
|
|
|
|
password = sys.argv[1]
|
|
|
|
child = pexpect.spawn('git pull')
|
|
|
|
child.expect("Enter passphrase for key '/home/daniel/.ssh/id_rsa':")
|
|
|
|
child.sendline(password)
|
|
|
|
child.expect('Already up-to-date.')
|
|
|
|
child.interact()
|
|
|
|
|
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
except pexpect.TIMEOUT:
|
|
|
|
pass
|
|
|
|
except pexpect.EOF:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
t0 = datetime.date.today()
|
|
|
|
while True:
|
|
|
|
if datetime.date.today() != t0:
|
|
|
|
print("generate daily reports")
|
|
|
|
t0 = datetime.date.today()
|
|
|
|
generate_webreport()
|
|
|
|
|
|
|
|
if gitpull() == True:
|
|
|
|
print("make test")
|
|
|
|
# maketest(False) # Integral make test build
|