Replaces develop_server.sh with .bat script. Fixes #2308

This commit is contained in:
Robin Daverstam 2018-03-26 19:46:48 +02:00
commit 978e2d4488
2 changed files with 40 additions and 14 deletions

View file

@ -386,22 +386,34 @@ needed by Pelican.
if isinstance(value, six.string_types) and ' ' in value:
value = '"' + value.replace('"', '\\"') + '"'
conf_shell[key] = value
try:
with codecs.open(os.path.join(CONF['basedir'],
if sys.platform == 'win32':
try:
with codecs.open(os.path.join(CONF['basedir'],
'develop_server.bat'),
'w', 'utf-8') as fd:
py_v = 'python'
_template = _jinja_env.get_template('develop_server.bat.jinja2')
fd.write(_template.render(py_v=py_v, **conf_shell))
fd.close()
except OSError as e:
print('Error: {}'.format(e))
else:
try:
with codecs.open(os.path.join(CONF['basedir'],
'develop_server.sh'),
'w', 'utf-8') as fd:
py_v = '${PY:-python}'
if six.PY3:
py_v = '${PY:-python3}'
_template = _jinja_env.get_template('develop_server.sh.jinja2')
fd.write(_template.render(py_v=py_v, **conf_shell))
fd.close()
'w', 'utf-8') as fd:
py_v = '${PY:-python}'
if six.PY3:
py_v = '${PY:-python3}'
_template = _jinja_env.get_template('develop_server.sh.jinja2')
fd.write(_template.render(py_v=py_v, **conf_shell))
fd.close()
# mode 0o755
os.chmod((os.path.join(CONF['basedir'],
# mode 0o755
os.chmod((os.path.join(CONF['basedir'],
'develop_server.sh')), 493)
except OSError as e:
print('Error: {0}'.format(e))
except OSError as e:
print('Error: {0}'.format(e))
print('Done. Your new project is available at %s' % CONF['basedir'])

View file

@ -0,0 +1,14 @@
SETLOCAL
set _PY={{py_v}}
set _PELICANOPTS={{pelicanopts}}
set _BASEDIR=%cd%
set _INPUTDIR=%_BASEDIR%/content
set _OUTPUTDIR=%_BASEDIR%/output
set _CONFFILE=%_BASEDIR%/pelicanconf.py
start pelican --debug --autoreload -r %_INPUTDIR% -o %_OUTPUTDIR% -s %_CONFFILE% %_PELICANOPTS%
pushd output
%_PY% -m pelican.server
popd