forked from github/pelican
make pelican-quickstart and the Makefile it generates support py3k.
This commit is contained in:
parent
5dbb8c3041
commit
5e4622b229
3 changed files with 21 additions and 5 deletions
|
|
@ -37,6 +37,7 @@ def _input_compat(prompt):
|
|||
if six.PY3:
|
||||
r = input(prompt)
|
||||
else:
|
||||
# FIXME: why use this with @decoding_strings?
|
||||
r = raw_input(prompt).decode('utf-8')
|
||||
return r
|
||||
|
||||
|
|
@ -50,7 +51,10 @@ def decoding_strings(f):
|
|||
out = f(*args, **kwargs)
|
||||
if isinstance(out, six.string_types) and not six.PY3:
|
||||
# todo: make encoding configurable?
|
||||
return out.decode(sys.stdin.encoding)
|
||||
if six.PY3:
|
||||
return out
|
||||
else:
|
||||
return out.decode(sys.stdin.encoding)
|
||||
return out
|
||||
return wrapper
|
||||
|
||||
|
|
@ -243,7 +247,14 @@ needed by Pelican.
|
|||
if mkfile:
|
||||
try:
|
||||
with codecs.open(os.path.join(CONF['basedir'], 'Makefile'), 'w', 'utf-8') as fd:
|
||||
for line in get_template('Makefile'):
|
||||
mkfile_template_name = 'Makefile'
|
||||
py_v = 'PY=python'
|
||||
if six.PY3:
|
||||
py_v = 'PY=python3'
|
||||
template = string.Template(py_v)
|
||||
fd.write(template.safe_substitute(CONF))
|
||||
fd.write('\n')
|
||||
for line in get_template(mkfile_template_name):
|
||||
template = string.Template(line)
|
||||
fd.write(template.safe_substitute(CONF))
|
||||
fd.close()
|
||||
|
|
@ -258,7 +269,12 @@ needed by Pelican.
|
|||
conf_shell[key] = value
|
||||
try:
|
||||
with codecs.open(os.path.join(CONF['basedir'], 'develop_server.sh'), 'w', 'utf-8') as fd:
|
||||
for line in get_template('develop_server.sh'):
|
||||
lines = list(get_template('develop_server.sh'))
|
||||
py_v = 'PY=python\n'
|
||||
if six.PY3:
|
||||
py_v = 'PY=python3\n'
|
||||
lines = lines[:4] + [py_v] + lines[4:]
|
||||
for line in lines:
|
||||
template = string.Template(line)
|
||||
fd.write(template.safe_substitute(conf_shell))
|
||||
fd.close()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ regenerate: clean
|
|||
$$(PELICAN) -r $$(INPUTDIR) -o $$(OUTPUTDIR) -s $$(CONFFILE) $$(PELICANOPTS)
|
||||
|
||||
serve:
|
||||
cd $$(OUTPUTDIR) && python -m pelican.server
|
||||
cd $$(OUTPUTDIR) && $(PY) -m pelican.server
|
||||
|
||||
devserver:
|
||||
$$(BASEDIR)/develop_server.sh restart
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function start_up(){
|
|||
pelican_pid=$$!
|
||||
echo $$pelican_pid > $$PELICAN_PID
|
||||
cd $$OUTPUTDIR
|
||||
python -m pelican.server &
|
||||
$PY -m pelican.server &
|
||||
srv_pid=$$!
|
||||
echo $$srv_pid > $$SRV_PID
|
||||
cd $$BASEDIR
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue