Skip to content

Commit 85f2ef4

Browse files
committed
Add tee2log script
1 parent e237380 commit 85f2ef4

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

.github/scripts/tee2log

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
import os, sys
4+
from subprocess import CalledProcessError, call
5+
from subprocess_tee import run
6+
7+
def mvntee():
8+
args = sys.argv[1:]
9+
if (len(args) < 2):
10+
print("Usage prbuild.py <logPath> <stepOutputPath> <cmd> ...")
11+
return 99
12+
logpath = args[0]
13+
outpath = args[1]
14+
try:
15+
run(args[2:], check=True, echo=True)
16+
except CalledProcessError as ex:
17+
with open(logpath, 'w') as ansi:
18+
ansi.write(ex.stdout)
19+
htmlpath = logpath + ".html"
20+
call(f"ansi2html --no-wrap < {logpath} > {htmlpath}", shell=True)
21+
htmlpath = os.path.abspath(htmlpath)
22+
with open(outpath, 'a') as out:
23+
out.write(f"loghtml={htmlpath}\n")
24+
return ex.returncode
25+
return 0
26+
27+
if __name__ == '__main__':
28+
sys.exit(mvntee())

0 commit comments

Comments
 (0)