Cannot handle spaces in project path
matthijskooijman opened this issue · comments
Matthijs Kooijman commented
When the project path includes a space, the installer breaks:
matthijs@grubby:~/with space$ djangocms mysite
Creating the project
Please wait while I install dependencies
Dependencies installed
Creating the project
usage: django-admin.py startproject [-h] [--version] [-v {0,1,2,3}]
[--settings SETTINGS]
[--pythonpath PYTHONPATH] [--traceback]
[--no-color] [--template TEMPLATE]
[--extension EXTENSIONS] [--name FILES]
name [directory]
django-admin.py startproject: error: unrecognized arguments: space/mysite
The installation has failed.
The problem comes from these lines: https://github.com/nephila/djangocms-installer/blob/develop/djangocms_installer/django/__init__.py#L56-L59
There, the command to run is joined into a single string, without proper escaping, and then passed to the shell to split again. There does not seem any point to this, since the argument is already nicely split and can be passed to subprocess
as-is:
cmd_args = [sys.executable, start_cmd, 'startproject'] + args
if config_data.verbose:
sys.stdout.write('Project creation command: {0}\n'.format(''.join(cmd_args)))
output = subprocess.check_output(cmd_args)
Iacopo Spalletti commented
Thanks for reporting
Iacopo Spalletti commented
Closed via #313