"WindowsError: [Error 2]"
HaveF opened this issue · 2 comments
When I use git-bzr-ng the first time, it occurs error:
(my system is win7, use the newest of git-bzr-ng source code)
git bzr clone lp:leo-editor leo-editor
Traceback (most recent call last):
File "C:\Git\bin/git-bzr", line 709, in
sys.exit(main(sys.argv))
File "C:\Git\bin/git-bzr", line 703, in main
return func(argv[2:])
File "C:\Git\bin/git-bzr", line 411, in cmd_clone
init_repo(cl)
File "C:\Git\bin/git-bzr", line 348, in init_repo
bzr(['init-repo', '--no-trees', cl.bzr_dir()])
File "C:\Git\bin/git-bzr", line 63, in bzr
return run_command(cmd, **kwargs)
File "C:\Git\bin/git-bzr", line 37, in run_command
proc = subprocess.Popen(cmd, stdout=stdout, stdin=stdin)
File "C:\Python26\lib\subprocess.py", line 633, in init
errread, errwrite)
File "C:\Python26\lib\subprocess.py", line 842, in _execute_child
startupinfo)
WindowsError: [Error 2]
Solution
This repo https://github.com/alexreg/git-bzr-ng/commits/master has a wrong solution
- proc = subprocess.Popen(cmd, stdout=stdout, stdin=stdin)
+ proc = subprocess.Popen(cmd, stdout=stdout, stdin=stdin, shell=True)
because in Linux "shell=True" don't run args[1] etc.
cat /etc/issue
Ubuntu 13.04 \n \l
# arg is a program that print its arguments
python -c "import subprocess; subprocess.Popen(['arg', 'a'])"
0: arg
1: a
python -c "import subprocess; subprocess.Popen(['arg', 'a'], shell=True)"
0: arg
The right solution is therefore
if hasattr(cmd, '__iter__')
proc = subprocess.Popen(cmd, stdout=stdout, stdin=stdin)
# a bug http://stackoverflow.com/a/36327/1299708 require shell=True
else
proc = subprocess.Popen(cmd, stdout=stdout, stdin=stdin, shell=True)