无法备份帐套
-
你可以在“开始”->“运行“中输入[quote]cmd[/quote],然后在终端窗口中输入
pg_dump,如果显示无法识别的命令,那你就要在windows环境变量path中设置到PostgreSQL下的bin目录的路径。
如何设置windows环境变量,问google吧 -
感谢shelly指导,解决过程是用
def exec_pg_command_pipe(name, *args):
prog = find_pg_tool(name)
if not prog:
raise Exception('Couldn't find %s' % name)
if os.name == "nt":
cmd = '"' + prog + '" ' + ' '.join(args)
else:
cmd = prog + ' ' + ' '.join(args)
return os.popen2(cmd, 'b')
代替了tools下面misc文件的
中的
def exec_pg_command_pipe(name, *args):
prog = find_pg_tool(name)
if not prog:
raise Exception('Couldn't find %s' % name)
pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
return (pop.stdin, pop.stdout)
shelly完美解决了问题,请shelly兄能分享下解决思路!俺还是一知半解,例如怎样知道问题是在tools下的misc。py呢? -
且慢, 这不只是windows下的问题,Linux下也存在问题,查了一下subprocess的文档,发现Open ERP5.0.15在使用subprocess.Popen时参数设定是错误的。正待向Lauchpad上提交Bug Report, 发现该bug在月初时就有人发现并且在版本库中已解决(https://bugs.launchpad.net/openobject-server/+bug/685115),这就是开源的优势之一,修改的方法很简单:
--- /home/mtm/openerp-server-5.0.15/bin/tools/misc.py 2010-11-04 15:12:38.000000000 +0300<br />+++ misc.py 2010-12-04 11:30:04.000000000 +0300<br />@@ -140,7 +140,7 @@<br /> if not prog:<br /> raise Exception('Couldn\'t find %s' % name)<br /> <br />- pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,<br />+ pop = subprocess.Popen((prog,) + args, bufsize= -1,<br /> stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> return (pop.stdin, pop.stdout)<br /> <br />@@ -149,7 +149,7 @@<br /> if not prog:<br /> raise Exception('Couldn\'t find %s' % name)<br /> <br />- pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,<br />+ pop = subprocess.Popen((prog,) + args, bufsize= -1,<br /> stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> return (pop.stdin, pop.stdout)<br /> #----------------------------------------------------------
很不好意思的要给Shelly姐满是唇印的脸颊留个巴掌印了:
Shelly的解法:1.没有找到错误的实质 2. os.popen2是一个Python2.6开始就淘汰(deprecated)的函数,这也是为什么OE会从os.popen2转到subprocess的原因
不过还是要感谢Shelly姐一贯的热心助人,无私奉献的精神,鼓掌!
【EDIT:】刚才在上面直接拷贝了bug report中的patch文件,回过头一看也是错误的,上面贴出的是修改好的。 -
[quote author=Joshua link=topic=2244.msg7246#msg7246 date=1292549568]
但是我有个疑问,好像这个错误在log里面没有显示出来,要跟踪这个错误就只能直接看代码啦?
[/quote]
好象只在trunk里做了修改: [检测到链接无效,已移除] -
顶起来.
今天用 5.0.15 . 按 digitalsatori 的解决方案, 把 misc.py 文件中 的代码 更改为<br />...<br /><br />def exec_pg_command_pipe(name, *args):<br /> prog = find_pg_tool(name)<br /> if not prog:<br /> raise Exception('Couldn\'t find %s' % name)<br /><br /> #pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,<br /> # stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> pop = subprocess.Popen((prog,) + args, bufsize= -1,<br /> stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> return (pop.stdin, pop.stdout)<br /><br />def exec_command_pipe(name, *args):<br /> prog = find_in_path(name)<br /> if not prog:<br /> raise Exception('Couldn\'t find %s' % name)<br /><br /> #pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,<br /> # stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> pop = subprocess.Popen((prog,) + args, bufsize= -1,<br /> stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /><br /> return (pop.stdin, pop.stdout)<br />...<br />
替换后, 还是备份出错. digitalsatori 测试过了吗? 或者再深入看一下? 谢谢.
目前暂时还是使用 os.popen2 解决... -
好吧. 自己解决了.
是因为 windows 不支持 close_fds 参数. 所以, 只需要按校长的 改. 并把 close_fds 参数去掉即可.
既然 校长 B4我了一下... 我也B4校长一下... 哪能不测试就发出来哩... 最起码 os.popen2 的还能用嘛.. 嘿嘿嘿<br />...<br /><br />def exec_pg_command_pipe(name, *args):<br /> prog = find_pg_tool(name)<br /> if not prog:<br /> raise Exception('Couldn\'t find %s' % name)<br /><br /> #pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,<br /> # stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> pop = subprocess.Popen((prog,) + args, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE)<br /> return (pop.stdin, pop.stdout)<br /><br />def exec_command_pipe(name, *args):<br /> prog = find_in_path(name)<br /> if not prog:<br /> raise Exception('Couldn\'t find %s' % name)<br /><br /> #pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1,<br /> # stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)<br /> pop = subprocess.Popen((prog,) + args, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE)<br /><br /> return (pop.stdin, pop.stdout)<br />...<br />
5.0.15 server 测试通过... -
B4的有理,偶也B4一下校长。
多谢Shelly同学 -
library.zip 里的文件都是 .pyo编译过的文件,我在源文件里修改完,用python -O 编译出现缺少模块的编译错误,总不能再生成一个windows的 server 安装包. 或者把misc.py 修改完直接放在library.zip里,是否可行.
-
[quote author=xtjie link=topic=2244.msg7387#msg7387 date=1295311398]
library.zip 里的文件都是 .pyo编译过的文件,我在源文件里修改完,用python -O 编译出现缺少模块的编译错误,总不能再生成一个windows的 server 安装包. 或者把misc.py 修改完直接放在library.zip里,是否可行.
[/quote]
try it .
注意 优先级.
当 .pyc .pyo 文件存在时. python 是不会去理会 .py 文件的.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login