[英]Redirecting django manage.py output (in windows) to a text file
I'm trying to redirect the output from manage.py to a text file, but only some output is getting redirected to the text file. 我正在尝试将manage.py的输出重定向到文本文件,但只有一些输出被重定向到文本文件。 How do I redirect all output to the text file?
如何将所有输出重定向到文本文件?
My command prompt: 我的命令提示符:
C:\Development\web-py\p1st2\pianos1st-system>python manage.py test > test_results.txt
.....................................................................................................................
----------------------------------------------------------------------
Ran 117 tests in 2.026s
OK
My test_results.txt file: 我的test_results.txt文件:
Creating test database for alias 'default'...
Destroying test database for alias 'default'...
I'm using Windows 7 32bit SP1 and Django SVN. 我正在使用Windows 7 32位SP1和Django SVN。
Certain types of console messages will bypass the output redirection (or whatever using ">" is called). 某些类型的控制台消息将绕过输出重定向(或使用“>”调用的任何内容)。 I noticed that sys.stderr.write() for instance did this.
我注意到sys.stderr.write()就是这样做的。
Adding a "2>&1" at the end helps with this: 最后添加“2>&1”有助于:
python manage.py test purchaseplans > test_results.txt 2>&1
Edit: Explanation of what is going on: 编辑:解释发生了什么:
http://en.wikipedia.org/wiki/Redirection_(computing)#Redirecting_to_and_from_the_standard_file_handles http://en.wikipedia.org/wiki/Redirection_(computing)#Redirecting_to_and_from_the_standard_file_handles
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.