forked from SymbiFlow/conda-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis-output.py
executable file
·120 lines (93 loc) · 2.35 KB
/
.travis-output.py
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
import io
import pexpect
import re
import string
import sys
import time
output_to=sys.stdout
args = list(sys.argv[1:])
logfile = open(args.pop(0), "w")
child = pexpect.spawn(' '.join(args))
def output_line(line_bits, last_skip):
line = "".join(line_bits)
line = re.sub("/really.*/conda/", "/.../conda/", line)
line = re.sub("/_b_env_[^/]*/", "/_b_env_.../", line)
sline = line.strip()
skip = True
if line.startswith(" ") and not sline.startswith('/'):
skip = False
if "da es fi" in sline:
skip = True
if "setting rpath" in sline:
skip = True
if "Entering directory" in sline:
skip = False
sline = sline.split('make')[-1]
if re.search("[0-9]+\.[0-9]+", line):
skip = False
if len(sline) > 1:
if sline[0] in string.ascii_uppercase and sline[1] not in string.ascii_uppercase:
skip = False
if sline[0] in ('[', '=', '!', '+'):
skip = False
if skip != last_skip:
output_to.write('\n')
if skip:
output_to.write('.')
else:
output_to.write(line)
output_to.flush()
line_bits.clear()
return skip
def find_newline(data):
fulldata = b"".join(data)
newlinechar = fulldata.find(b'\n')
retlinechar = fulldata.find(b'\r')
if newlinechar == -1:
newlinechar = len(fulldata)+1
if retlinechar == -1:
retlinechar = len(fulldata)+1
if retlinechar+1 == newlinechar:
splitpos = newlinechar
else:
splitpos = min(newlinechar, retlinechar)
if splitpos > len(fulldata):
return
newline = fulldata[:splitpos+1]
leftover = fulldata[splitpos+1:]
data.clear()
data.append(leftover)
return newline
last_skip = False
cont = []
data = [b'']
while True:
line = None
while len(data) > 1 or len(data[0]) > 0 or child.isalive():
line = find_newline(data)
if line is not None:
break
try:
data.append(child.read_nonblocking(100))
except pexpect.TIMEOUT:
pass
except pexpect.EOF as e:
data.append(b'\n')
if not line:
break
line = line.decode('utf-8')
logfile.write(line)
logfile.flush()
if line.endswith('\r'):
cont.append(line[:-1])
last_skip = output_line(cont, last_skip)
cont.append('\r')
continue
sline = line.strip('\n\r')
cont.append(sline)
if sline.endswith('\\'):
continue
cont.append('\n')
last_skip = output_line(cont, last_skip)
sys.exit(child.exitstatus)