Debian Codegraph @

ansible_collections/community/postgresql/.azure-pipelines/scripts/time-command.py

raw
1 #!/usr/bin/env python
2 """Prepends a relative timestamp to each input line from stdin and writes it to stdout."""
3
4 from __future__ import absolute_import, division, print_function
5
6 __metaclass__ = type
7
8 import sys
9 import time
10
11
12 def main():
13 """Main program entry point."""
14 start = time.time()
15
16 sys.stdin.reconfigure(errors='surrogateescape')
17 sys.stdout.reconfigure(errors='surrogateescape')
18
19 for line in sys.stdin:
20 seconds = time.time() - start
21 sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
22 sys.stdout.flush()
23
24
25 if __name__ == '__main__':
26 main()