I'm automating project creation with a python script. I can create repositories, checkout, commit, and import directories, all from within python.
What it won't seem to do is set the svn:externals
property. I can set this from command line but when I try to run the command with a subprocess.call
it doesn't work.
Here's the command line (that works when in the checked-out project directory):
svn propset svn:externals "trunk/Source/Interactive/Flash.Externals https://server/svn/proj/" .
Here's the script call (which runs after checking the repo out to gv.project_repo_dir
):
# gv is a global variables object
odir = getcwd()
chdir(getcwd() + '/' + gv.project_repo_dir)
res = call(['svn', 'propset', 'svn:externals', \
'"'+ gv.interactive_subpath +'Flash.Externals '+ gv.mirror_project_repo_url +'"', \
'.'])
chdir(odir)
Here's the error from the script run:
svn: Error parsing svn:externals property on '.': '"trunk/Source/Interactive/Flash.Externals https://server/svn/proj/"'
I've tried this with shell=True
as an arg to the call
and without; no dice.
Any ideas?
Stats:
I would recommend looking at the pysvn module vs. doing it through command line:
But if you have to do it through command line, can you use the os.system call instead of the subprocess?
os.system('svn propset svn:externals "trunk/Source/Interactive/Flash.Externals https://server/svn/proj/" . ')
should run "as shell", you just aren't able to get feedback from it - it will run the command and wait until the command is finished.
That, or you could try breaking the command up (not 100% sure if this works in Windows, but pretty sure):
import shlex
commands = shlex.split('svn propset svn:externals "trunk/Source/Interactive/Flash.Externals https://server/svn/proj/" .')
subprocess.call(commands)
I don't know I buy the "it doesn't work with shell=True" statement. The error shows that it interpreted the double quotation marks as literals, as in it's trying to use "trunk/Source/Interactive/Flash.Externals https://server/svn/proj/"
as one of the execvp arguments. The double quotation marks only have special meaning to a shell.
Example:
>>> subprocess.call(["ls", '"."'], shell=False)
ls: ".": No such file or directory
2
With shell=True:
>>> subprocess.call(["ls", '"."'], shell=True)
metrics_poller.sock OSL_PIPE_0_SingleOfficeIPC_b919ef148f655fcebc4bf633c062a098 sv9hg.tmp
metrics.sock proc_mgr_stats userinstall.mBa793
mysql_tzinfo_stderr sess_716518f985ab8de017981347a8b61c611c9880bd userinstall.omY802
Try removing the double quotes if the shell=True variation really doesn't help.
res = call(['svn', 'propset', 'svn:externals', \
gv.interactive_subpath +'Flash.Externals '+ gv.mirror_project_repo_url, \
'.'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.