Mercurial > hg > config
annotate python/logoutput.py @ 694:ebca6d85213a
File "/usr/lib/python3/dist-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/usr/lib/python3/dist-packages/IPython/config/application.py", line 31, in <module>
from IPython.config.configurable import SingletonConfigurable
File "/usr/lib/python3/dist-packages/IPython/config/configurable.py", line 33, in <module>
from IPython.utils.text import indent, wrap_paragraphs
File "/usr/lib/python3/dist-packages/IPython/utils/text.py", line 28, in <module>
from IPython.external.path import path
File "/usr/lib/python3/dist-packages/IPython/external/path/__init__.py", line 2, in <module>
from path import *
File "/home/jhammel/python/path.py", line 25
print root(path)
^
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 09 Jul 2014 16:26:49 -0700 |
parents | d7afa7a0ea3e |
children |
rev | line source |
---|---|
511 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 execute a command and log its output to a file | |
5 """ | |
6 | |
7 import sys | |
8 from subprocess import list2cmdline, STDOUT | |
9 from subprocess import check_output as call | |
10 | |
11 def main(args=sys.argv[1:]): | |
12 """CLI""" | |
13 | |
14 usage = '%prog outputfile command [args]' | |
15 usage += '\n' + __doc__ | |
16 if args < 2: | |
17 print 'Usage: ' + usage | |
18 sys.exit(1) | |
19 | |
20 path = args.pop(0) | |
21 commandline = list2cmdline(args) | |
22 | |
23 with file(path, 'w') as w: | |
24 output = call(args, stderr=STDOUT) | |
25 w.write('\n\n'.join([commandline, output])) | |
26 | |
27 if __name__ == '__main__': | |
28 main() |