forked from danmar/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci.py
More file actions
105 lines (87 loc) · 2.53 KB
/
ci.py
File metadata and controls
105 lines (87 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/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)
# child.expect(
# 'danielmarjamaki,cppcheck@web.sourceforge.net\'s password:')
child.expect('Password:')
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():
for filename in glob.glob('*/*.cpp'):
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 = None
while True:
if datetime.date.today() != t0:
print("generate daily reports")
t0 = datetime.date.today()
gitpull()
generate_webreport()
time.sleep(60)