webpyapp: support du mode développement

This commit is contained in:
Jephté Clain 2017-07-19 23:31:57 +04:00
parent e2ea2ead3c
commit c541958828
3 changed files with 21 additions and 8 deletions

View File

@ -8,7 +8,7 @@ from os import path
from ulib.base.base import isstr, isbool, isnum, isflt, seqof, make_prop
from ulib.base.uio import _u, Utf8IO
from ulib.base.output import set_verbosity, enote, edebug
from ulib.base.output import set_verbosity, einfo, enote, edebug
from ulib.base.args import get_args
from ulib.base.dates import rfc2822
from ulib.base.functions import apply_args
@ -324,7 +324,13 @@ class ShConfig(dict):
self[name] = value
class Application(object):
# si ce fichier existe dans basedir, alors forcer le mode développement: la
# variable HOST est ignorée et DEBUG vaut par défaut True
DEVEL_SF = '.devel'
# nom du fichier de configuration à charger automatiquement à partir de
# basedir. pour désactiver cette fonctionnalité, utiliser la valeur None
CONFIG = 'server.conf'
# configuration par défaut
HOST = '0.0.0.0'
PORT = 12345
DEBUG = False
@ -362,12 +368,17 @@ class Application(object):
templatedir = path.join(self.basedir, 'templates')
self.templatedir = templatedir
config = path.join(self.basedir, self.CONFIG)
if path.exists(config):
c = ShConfig(config, HOST=None, PORT=None, DEBUG=None)
if host is None: host = c['HOST']
if port is None: port = integerF.parse((c['PORT']))
if debug is None: debug = booleanF.parse(c['DEBUG'])
devel = path.exists(path.join(self.basedir, self.DEVEL_SF))
if devel: einfo("Mode developpement activé")
if self.CONFIG is not None:
config = path.join(self.basedir, self.CONFIG)
if path.exists(config):
c = ShConfig(config, HOST=None, PORT=None, DEBUG=None)
if host is None and not devel: host = c['HOST']
if port is None: port = integerF.parse((c['PORT']))
if debug is None: debug = booleanF.parse(c['DEBUG'])
if debug is None and devel: debug = True
if host is not None: self.HOST = host
if port is not None: self.PORT = port

View File

View File

@ -57,7 +57,9 @@ fi
etitle "Copie des fichiers"
destdir="$destdir/$name"
mkdir -p "$destdir" || die
rsync -a --exclude /server.conf --exclude /install-or-update.sh "$scriptdir/" "$destdir"
rsync -a \
--exclude /server.conf --exclude /install-or-update.sh --exclude /.devel \
"$scriptdir/" "$destdir"
eend
etitle "Vérification de la configuration"