MCPcopy Create free account
hub / github.com/apache/storm / main

Function main

dev-tools/gitact/save-logs.py:20–49  ·  view source on GitHub ↗
(file, cmd)

Source from the content-addressed store, hash-verified

18
19
20def main(file, cmd):
21 print(cmd, "writing to", file)
22 out = open(file, "w")
23 count = 0
24 process = subprocess.Popen(cmd,
25 stderr=subprocess.STDOUT,
26 stdout=subprocess.PIPE)
27
28 start = datetime.now()
29 nextPrint = datetime.now() + timedelta(seconds=1)
30 # wait for the process to terminate
31 pout = process.stdout
32 line = pout.readline()
33 while line:
34 line = line.decode('utf-8')
35 count = count + 1
36 if datetime.now() > nextPrint:
37 diff = datetime.now() - start
38 sys.stdout.write(f"\r{diff.seconds} seconds {count} log lines")
39 sys.stdout.flush()
40 nextPrint = datetime.now() + timedelta(seconds=10)
41 out.write(line)
42 line = pout.readline()
43 out.close()
44 errcode = process.wait()
45 diff = datetime.now() - start
46 sys.stdout.write(f"\r{diff.seconds} seconds {count} log lines")
47 print()
48 print(cmd, "done", errcode)
49 return errcode
50
51
52if __name__ == "__main__":

Callers 1

save-logs.pyFile · 0.70

Calls 5

nowMethod · 0.80
writeMethod · 0.65
flushMethod · 0.65
closeMethod · 0.65
decodeMethod · 0.45

Tested by

no test coverage detected