From e2ea2ead3c3f74955102b341110279cf5865412c Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 19 Jul 2017 23:12:06 +0400 Subject: [PATCH 01/13] ufile: ajout de --force-cp --- ufile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ufile b/ufile index 2f67f1b..b87b156 100755 --- a/ufile +++ b/ufile @@ -44,6 +44,11 @@ OPTIONS défaut ~/etc/default/ufile --file Classer les fichiers spécifiés. C'est l'action par défaut + --force-cp + Spécifier le mode de classement des fichiers. Par défaut, le fichier est + déplacé dans la destination s'il s'agit d'un classement local, ou copié + s'il s'agit d'un classement distant. Avec --force-cp, le fichier est + systématiquement copié dans la destination. -S, --ssh SSH S'il faut classer sur un hôte distant avec scp, utiliser le programme spécifié pour la connexion par ssh @@ -108,6 +113,7 @@ args=(% --help '$exit_with display_help' -c:,--config: config= --file action=file + --force-cp force_cp=1 -S:,--ssh: SSH= --force-scp force_scp=1 -n,--fake fake=1 @@ -251,7 +257,7 @@ for file in "$@"; do } setx destdir=dirname -- "$dest" docmd mkdir -p "$destdir" || die "$destdir: impossible de créer le répertoire" - if [ $i -eq $mvi ]; then + if [ $i -eq $mvi -a -z "$force_cp" ]; then mvdesc="du déplacement" mvcmd=mv else From c541958828deb53c2a360347e09d05235252d145 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 19 Jul 2017 23:31:57 +0400 Subject: [PATCH 02/13] =?UTF-8?q?webpyapp:=20support=20du=20mode=20d=C3=A9?= =?UTF-8?q?veloppement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pyulib/src/ulib/web/pages.py | 25 +++++++++++++------ lib/ulib/templates/webpyapp/.devel | 0 .../templates/webpyapp/install-or-update.sh | 4 ++- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 lib/ulib/templates/webpyapp/.devel diff --git a/lib/pyulib/src/ulib/web/pages.py b/lib/pyulib/src/ulib/web/pages.py index 0c93c09..31d19e0 100644 --- a/lib/pyulib/src/ulib/web/pages.py +++ b/lib/pyulib/src/ulib/web/pages.py @@ -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 diff --git a/lib/ulib/templates/webpyapp/.devel b/lib/ulib/templates/webpyapp/.devel new file mode 100644 index 0000000..e69de29 diff --git a/lib/ulib/templates/webpyapp/install-or-update.sh b/lib/ulib/templates/webpyapp/install-or-update.sh index 3c3ce94..0bd2e51 100755 --- a/lib/ulib/templates/webpyapp/install-or-update.sh +++ b/lib/ulib/templates/webpyapp/install-or-update.sh @@ -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" From 46fbec7974c13b462a9a4e908c0c2d9b863fb0de Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 19 Jul 2017 23:45:26 +0400 Subject: [PATCH 03/13] =?UTF-8?q?webpyapp:=20bootstrap=20facilit=C3=A9=20d?= =?UTF-8?q?es=20sessions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/templates/webpyapp/server.py | 4 ++++ lib/ulib/templates/webpyapp/sessions/.gitignore | 2 ++ lib/ulib/templates/webpyapp/sessions/.keep | 0 3 files changed, 6 insertions(+) create mode 100644 lib/ulib/templates/webpyapp/sessions/.gitignore delete mode 100644 lib/ulib/templates/webpyapp/sessions/.keep diff --git a/lib/ulib/templates/webpyapp/server.py b/lib/ulib/templates/webpyapp/server.py index 38ff7ae..ea2c9d7 100755 --- a/lib/ulib/templates/webpyapp/server.py +++ b/lib/ulib/templates/webpyapp/server.py @@ -9,6 +9,10 @@ class Server(Application): def __init__(self, basedir=None, templatedir=None, host=None, port=None, debug=None): Application.__init__(self, basedir, templatedir, host, port, debug) + def _new_session(self): + pass # décommenter la ligne suivante pour activer les sessions + #return web.session.DiskStore('sessions'), {} + class index(Page): PREFIX = r'/' diff --git a/lib/ulib/templates/webpyapp/sessions/.gitignore b/lib/ulib/templates/webpyapp/sessions/.gitignore new file mode 100644 index 0000000..a68d087 --- /dev/null +++ b/lib/ulib/templates/webpyapp/sessions/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore diff --git a/lib/ulib/templates/webpyapp/sessions/.keep b/lib/ulib/templates/webpyapp/sessions/.keep deleted file mode 100644 index e69de29..0000000 From d1a1d4d664c6b10e635146b9c535822c41c0307b Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 20 Jul 2017 00:16:02 +0400 Subject: [PATCH 04/13] webpyapp: cosmetic --- lib/ulib/templates/webpyapp/lib/__init__.py | 4 ++++ lib/ulib/templates/webpyapp/server.py | 2 +- lib/ulib/templates/webpyapp/sessions/.gitignore | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 lib/ulib/templates/webpyapp/lib/__init__.py diff --git a/lib/ulib/templates/webpyapp/lib/__init__.py b/lib/ulib/templates/webpyapp/lib/__init__.py new file mode 100644 index 0000000..9d853e8 --- /dev/null +++ b/lib/ulib/templates/webpyapp/lib/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 mode: python -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 + +__all__ = () + diff --git a/lib/ulib/templates/webpyapp/server.py b/lib/ulib/templates/webpyapp/server.py index ea2c9d7..b661a11 100755 --- a/lib/ulib/templates/webpyapp/server.py +++ b/lib/ulib/templates/webpyapp/server.py @@ -7,7 +7,7 @@ from ulib.web import web, Application, Page, defaults class Server(Application): def __init__(self, basedir=None, templatedir=None, host=None, port=None, debug=None): - Application.__init__(self, basedir, templatedir, host, port, debug) + super(Server, self).__init__(basedir, templatedir, host, port, debug) def _new_session(self): pass # décommenter la ligne suivante pour activer les sessions diff --git a/lib/ulib/templates/webpyapp/sessions/.gitignore b/lib/ulib/templates/webpyapp/sessions/.gitignore index a68d087..479aeb7 100644 --- a/lib/ulib/templates/webpyapp/sessions/.gitignore +++ b/lib/ulib/templates/webpyapp/sessions/.gitignore @@ -1,2 +1,3 @@ /* +/*/ !/.gitignore From 0b39b2324bdc696bf6d27f7050292d3dddb3cca2 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 20 Jul 2017 01:30:56 +0400 Subject: [PATCH 05/13] webpyapp: les variables de server.conf sont configurables --- lib/pyulib/src/ulib/web/pages.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/pyulib/src/ulib/web/pages.py b/lib/pyulib/src/ulib/web/pages.py index 31d19e0..62a5746 100644 --- a/lib/pyulib/src/ulib/web/pages.py +++ b/lib/pyulib/src/ulib/web/pages.py @@ -13,7 +13,7 @@ from ulib.base.args import get_args from ulib.base.dates import rfc2822 from ulib.base.functions import apply_args from ulib.base.words import plural -from ulib.formats import unicodeF, booleanF, integerF, floatF +from ulib.formats import unicodeF, strF, booleanF, integerF, floatF from ulib.ext import web def checked(b): @@ -307,8 +307,13 @@ class Page(object): def index(self): return self.render() class ShConfig(dict): - def __init__(self, config, **defaults): - super(ShConfig, self).__init__(**defaults) + _formats = None + def __init__(self, config, formats): + super(ShConfig, self).__init__() + self._formats = formats + for name in formats.keys(): + self[name] = None + inf = open(config, 'rb') try: s = inf.read() finally: inf.close() @@ -321,7 +326,8 @@ class ShConfig(dict): mo = self.RE_NAMEVALUE.match(part) if mo is None: continue #XXX ignorer pour le moment name, value = mo.groups() - self[name] = value + format = self._formats.get(name, unicodeF) + self[name] = format.parse(value) class Application(object): # si ce fichier existe dans basedir, alors forcer le mode développement: la @@ -329,7 +335,8 @@ class Application(object): 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' + CONFIG_FILE = 'server.conf' + CONFIG_VARS = dict(HOST=strF, PORT=integerF, DEBUG=booleanF) # configuration par défaut HOST = '0.0.0.0' PORT = 12345 @@ -371,14 +378,14 @@ class Application(object): 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 self.CONFIG_FILE is not None: + config = path.join(self.basedir, self.CONFIG_FILE) 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 + c = ShConfig(config, self.CONFIG_VARS) + for name, value in c.items(): + if devel and name == 'HOST': continue + if devel and name == 'DEBUG' and value is None: value = True + if value is not None: setattr(self, name, value) if host is not None: self.HOST = host if port is not None: self.PORT = port From 65bd363a138b857d10c31141147ad4134c7adb7d Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 20 Jul 2017 09:13:51 +0400 Subject: [PATCH 06/13] =?UTF-8?q?webpyapp:=20r=C3=A9organiser=20les=20fich?= =?UTF-8?q?iers=20pour=20supporter=20des=20librairies=20locales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/templates/webpyapp/.gitignore | 1 + .../templates/webpyapp/lib/{ => python}/__init__.py | 0 .../webpyapp/lib/{ => python}/flup/__init__.py | 0 .../lib/{ => python}/flup/client/__init__.py | 0 .../lib/{ => python}/flup/client/fcgi_app.py | 0 .../lib/{ => python}/flup/client/scgi_app.py | 0 .../lib/{ => python}/flup/server/__init__.py | 0 .../webpyapp/lib/{ => python}/flup/server/ajp.py | 0 .../lib/{ => python}/flup/server/ajp_base.py | 0 .../lib/{ => python}/flup/server/ajp_fork.py | 0 .../webpyapp/lib/{ => python}/flup/server/cgi.py | 0 .../webpyapp/lib/{ => python}/flup/server/fcgi.py | 0 .../lib/{ => python}/flup/server/fcgi_base.py | 0 .../lib/{ => python}/flup/server/fcgi_fork.py | 0 .../lib/{ => python}/flup/server/fcgi_single.py | 0 .../lib/{ => python}/flup/server/paste_factory.py | 0 .../lib/{ => python}/flup/server/preforkserver.py | 0 .../webpyapp/lib/{ => python}/flup/server/scgi.py | 0 .../lib/{ => python}/flup/server/scgi_base.py | 0 .../lib/{ => python}/flup/server/scgi_fork.py | 0 .../lib/{ => python}/flup/server/singleserver.py | 0 .../lib/{ => python}/flup/server/threadedserver.py | 0 .../lib/{ => python}/flup/server/threadpool.py | 0 lib/ulib/templates/webpyapp/server.py | 13 +++++++------ 24 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 lib/ulib/templates/webpyapp/.gitignore rename lib/ulib/templates/webpyapp/lib/{ => python}/__init__.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/__init__.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/client/__init__.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/client/fcgi_app.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/client/scgi_app.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/__init__.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/ajp.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/ajp_base.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/ajp_fork.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/cgi.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/fcgi.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/fcgi_base.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/fcgi_fork.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/fcgi_single.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/paste_factory.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/preforkserver.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/scgi.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/scgi_base.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/scgi_fork.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/singleserver.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/threadedserver.py (100%) rename lib/ulib/templates/webpyapp/lib/{ => python}/flup/server/threadpool.py (100%) diff --git a/lib/ulib/templates/webpyapp/.gitignore b/lib/ulib/templates/webpyapp/.gitignore new file mode 100644 index 0000000..539da74 --- /dev/null +++ b/lib/ulib/templates/webpyapp/.gitignore @@ -0,0 +1 @@ +*.py[co] diff --git a/lib/ulib/templates/webpyapp/lib/__init__.py b/lib/ulib/templates/webpyapp/lib/python/__init__.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/__init__.py rename to lib/ulib/templates/webpyapp/lib/python/__init__.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/__init__.py b/lib/ulib/templates/webpyapp/lib/python/flup/__init__.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/__init__.py rename to lib/ulib/templates/webpyapp/lib/python/flup/__init__.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/client/__init__.py b/lib/ulib/templates/webpyapp/lib/python/flup/client/__init__.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/client/__init__.py rename to lib/ulib/templates/webpyapp/lib/python/flup/client/__init__.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/client/fcgi_app.py b/lib/ulib/templates/webpyapp/lib/python/flup/client/fcgi_app.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/client/fcgi_app.py rename to lib/ulib/templates/webpyapp/lib/python/flup/client/fcgi_app.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/client/scgi_app.py b/lib/ulib/templates/webpyapp/lib/python/flup/client/scgi_app.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/client/scgi_app.py rename to lib/ulib/templates/webpyapp/lib/python/flup/client/scgi_app.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/__init__.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/__init__.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/__init__.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/__init__.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/ajp.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/ajp.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/ajp.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/ajp.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/ajp_base.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/ajp_base.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/ajp_base.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/ajp_base.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/ajp_fork.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/ajp_fork.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/ajp_fork.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/ajp_fork.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/cgi.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/cgi.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/cgi.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/cgi.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/fcgi.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/fcgi.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/fcgi_base.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi_base.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/fcgi_base.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi_base.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/fcgi_fork.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi_fork.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/fcgi_fork.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi_fork.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/fcgi_single.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi_single.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/fcgi_single.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/fcgi_single.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/paste_factory.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/paste_factory.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/paste_factory.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/paste_factory.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/preforkserver.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/preforkserver.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/preforkserver.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/preforkserver.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/scgi.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/scgi.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/scgi.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/scgi.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/scgi_base.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/scgi_base.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/scgi_base.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/scgi_base.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/scgi_fork.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/scgi_fork.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/scgi_fork.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/scgi_fork.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/singleserver.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/singleserver.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/singleserver.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/singleserver.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/threadedserver.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/threadedserver.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/threadedserver.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/threadedserver.py diff --git a/lib/ulib/templates/webpyapp/lib/flup/server/threadpool.py b/lib/ulib/templates/webpyapp/lib/python/flup/server/threadpool.py similarity index 100% rename from lib/ulib/templates/webpyapp/lib/flup/server/threadpool.py rename to lib/ulib/templates/webpyapp/lib/python/flup/server/threadpool.py diff --git a/lib/ulib/templates/webpyapp/server.py b/lib/ulib/templates/webpyapp/server.py index b661a11..efb2b4c 100755 --- a/lib/ulib/templates/webpyapp/server.py +++ b/lib/ulib/templates/webpyapp/server.py @@ -3,6 +3,12 @@ __all__ = ('Server',) +import sys, os +from os import path + +SCRIPTDIR = path.abspath(path.split(__file__)[0]) +sys.path.insert(0, path.join(SCRIPTDIR, 'lib/python')) + from ulib.web import web, Application, Page, defaults class Server(Application): @@ -17,9 +23,4 @@ class index(Page): PREFIX = r'/' if __name__ == '__main__': - import sys - from os import path - - basedir = path.abspath(path.split(__file__)[0]) - sys.path.append(path.join(basedir, 'lib')) - Server(basedir).run(sys.argv[1:]) + Server(SCRIPTDIR).run(sys.argv[1:]) From 2cc24119b5c56ec40f304740ea74197d6747d60e Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 26 Jul 2017 11:44:17 +0400 Subject: [PATCH 07/13] bug potentiel --- lib/ulib/debian | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ulib/debian b/lib/ulib/debian index 8921acf..c53d020 100644 --- a/lib/ulib/debian +++ b/lib/ulib/debian @@ -14,7 +14,8 @@ function pkg_check() { # Vérifier que les packages sont installés sur le système local pkg status for pkg in "$@"; do - status="$(LANG=C dpkg -s "$pkg" 2>/dev/null | grep '^Status:')" || return 1 + LANG=C setx status=dpkg -s "$pkg" 2>/dev/null || return 1 + setx status=grep '^Status:' <<<"$status" [[ "$status" == *not-installed* ]] && return 1 [[ "$status" == *deinstall* ]] && return 1 done From 2f448d542d451999e6595bf641f0291f1048f437 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sat, 29 Jul 2017 23:02:39 +0400 Subject: [PATCH 08/13] =?UTF-8?q?ussh:=20probl=C3=A8mes=20de=20compatibili?= =?UTF-8?q?t=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ussh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ussh b/ussh index 104706f..de2b92c 100755 --- a/ussh +++ b/ussh @@ -343,15 +343,18 @@ function __update_sshopts_cm() { version="$(ssh -V 2>&1)" version="${version#OpenSSH_}"; major="${version%%.*}" minor="${version#$major.}"; minor="${minor:0:1}" - if [ $major -ge 6 ]; then + if [ -z "$major" ]; then + # ne devrait pas se produire... mais au cas où + persist= + elif [ "$major" -ge 6 ]; then persist="$DEFAULT_PERSIST" - elif [ $major -eq 5 ]; then + elif [ "$major" -eq 5 ]; then if [ "$minor" -ge 6 ]; then persist="$DEFAULT_PERSIST" else persist= fi - elif [ $major -le 4 ]; then + elif [ "$major" -le 4 ]; then persist= fi fi @@ -383,7 +386,10 @@ function show_vars() { function do_ssh() { local -a sshopts local onehost r - if [ "${#hosts[*]}" -gt 1 ]; then + if [ $# -eq 0 ]; then + ${exec:+exec} "$SSH" "${SSHOPTS[@]}" + return + elif [ "${#hosts[*]}" -gt 1 ]; then onehost= exec= else @@ -447,7 +453,7 @@ if [ -n "$remove" ]; then hosts=("$1"); shift fix_hosts remove_keys -else +elif [ -n "$1" ]; then hosts=("$1"); shift fix_hosts fi From 377ca5e82f1598cfa8d9ef55f4571847f6b9c6a4 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 24 Aug 2017 12:15:16 +0400 Subject: [PATCH 09/13] =?UTF-8?q?impl=C3=A9menter=20awkcsv2fsv.=20corriger?= =?UTF-8?q?=20un=20bug=20avec=20les=20outils=20qui=20utilisaient=20cawkrun?= =?UTF-8?q?=20=C3=A0=20l'int=C3=A9rieur=20d'une=20fonction=20l*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/awk | 75 +++++++++++++++++++++++++++++++++++++++++++--------- uawk | 16 +++++++++-- 2 files changed, 77 insertions(+), 14 deletions(-) diff --git a/lib/ulib/awk b/lib/ulib/awk index c242e6b..2a289b0 100644 --- a/lib/ulib/awk +++ b/lib/ulib/awk @@ -841,7 +841,7 @@ function lawkcsv() { reset_fields= fi - awkrun -f \ + lawkrun -f \ skip_lines:int="$skip" parse_headers:int="$parse_headers" \ autosep:int="$autosep" colsep="$colsep" qchar="$qchar" echar="$echar" \ show_headers:int="$show_headers" reset_fields:int="$reset_fields" \ @@ -978,7 +978,7 @@ function lgrepcsv() { headers=("$@") if [ -z "${headers[*]}" ]; then parse_headers=1 - array_from_lines headers "$(awkrun -f lskip:int="$skip" 'NR <= lskip { next } + array_from_lines headers "$(lawkrun -f lskip:int="$skip" 'NR <= lskip { next } { count = array_parsecsv(__fields, $0) for (i = 1; i <= count; i++) { @@ -1077,7 +1077,7 @@ function lawkfsv2csv() { done shift - awkrun -f \ + lawkrun -f \ skip_lines:int="$skip" trim_values:int="$rtrim" show_headers:int="$show_headers" \ headers[@] starts[@] sizes[@] \ "$__AWKCSV_FUNCTIONS"' @@ -1109,6 +1109,57 @@ function awkfsv2csv() { LANG=C lawkfsv2csv "$@"; } ################################################################################ +__AWKCSV2FSV_HELP="\ +Transformer un flux csv en fsv (colonnes à largeurs fixes) + +Chaque argument doit être de la forme field:size" + +function lawkcsv2fsv() { + local -a args fieldsizes + if parse_opts @ args -- "$@"; then + set -- "${args[@]}" + else + eerror "$args" + return 1 + fi + + local -a fields sizes + local fieldsize field size + while [ $# -gt 0 -a "$1" != "--" ]; do + fieldsize="$1" + shift + + splitpair "$fieldsize" field size + [ -n "$field" ] || { + eerror "field est requis" + return 1 + } + [ -n "$size" ] || size=1 + array_add fields "$field" + array_add sizes "$size" + done + shift + + lawkcsv -v fields[@] -v sizes[@] -a ' +{ + line = "" + for (i = 1; i <= fields_count; i++) { + size = sizes[i] + 0 + value = get(fields[i]) + while (length(value) < size) value = value " " + if (length(value) > size) value = substr(value, 1, size) + line = line value + } + print line +} +' -- "$@" +} + +function cawkcsv2fsv() { LANG=C lawkcsv2fsv "$@"; } +function awkcsv2fsv() { LANG=C lawkcsv2fsv "$@"; } + +################################################################################ + __MERGECSV_HELP="\ Fusionner deux fichiers csv en faisant la correspondance sur la valeur d'un champ, qui est la clé @@ -1264,14 +1315,14 @@ function lmergecsv() { [ "$parse_headers" == "auto" ] && parse_headers=1 if [ -n "$parse_headers" ]; then - [ -n "$lheaders" ] || lheaders="$(<"$lfile" awkrun lskip:int="$lskip" 'NR <= lskip { next } { print; exit }')" - [ -n "$rheaders" ] || rheaders="$(<"$rfile" awkrun lskip:int="$lskip" 'NR <= lskip { next } { print; exit }')" + [ -n "$lheaders" ] || lheaders="$(<"$lfile" lawkrun lskip:int="$lskip" 'NR <= lskip { next } { print; exit }')" + [ -n "$rheaders" ] || rheaders="$(<"$rfile" lawkrun lskip:int="$lskip" 'NR <= lskip { next } { print; exit }')" fi # faire le fichier de travail pour lfile local tmpleft ac_set_tmpfile tmpleft "" __mergecsv_left "" __MERGECSV_DEBUG - <"$lfile" awkrun -f \ + <"$lfile" lawkrun -f \ padding="$padding" padlen:int="$padlen" \ parse_headers:int="$parse_headers" ignore_case:int="$ignore_case" \ lskip:int="$lskip" lkey="$lkey" \ @@ -1295,7 +1346,7 @@ parse_headers && do_once("parse-headers") { # faire le fichier de travail pour rfile local tmpright ac_set_tmpfile tmpright "" __mergecsv_right "" __MERGECSV_DEBUG - <"$rfile" awkrun -f \ + <"$rfile" lawkrun -f \ padding="$padding" padlen:int="$padlen" \ parse_headers:int="$parse_headers" ignore_case:int="$ignore_case" \ rskip:int="$rskip" rkey="$rkey" \ @@ -1409,7 +1460,7 @@ parse_headers && do_once("parse-headers") { ac_set_tmpfile tmpmerged "" __mergecsv_merged "" __MERGECSV_DEBUG csort -s -k 1,$(($padlen + 1)) "$tmpleft" "$tmpright" >"$tmpmerged" - <"$tmpmerged" awkrun -f \ + <"$tmpmerged" lawkrun -f \ padlen:int="$padlen" \ parse_headers:int="$parse_headers" ignore_case:int="$ignore_case" \ lheaderscsv="$lheaders" lkey="$lkey" lprefix="$lprefix" \ @@ -1700,14 +1751,14 @@ function lsortcsv() { cat >"$tmpinput" input="$tmpinput" fi - headers="$(<"$input" awkrun skip:int="$skip" 'NR <= skip { next } { print; exit }')" + headers="$(<"$input" lawkrun skip:int="$skip" 'NR <= skip { next } { print; exit }')" fi # faire le fichier de travail local tmpinput ac_set_tmpfile tmpinput "" __sortcsv_input "" __SORTCSV_DEBUG array_add tmpfiles "$tmpinput" - <"$input" >"$tmpinput" awkrun -f \ + <"$input" >"$tmpinput" lawkrun -f \ padding="$padding" padlen:int="$padlen" \ skip:int="$skip" parse_headers:int="$parse_headers" \ key="$key" \ @@ -1740,7 +1791,7 @@ parse_headers && do_once("parse-headers") { # résultat [ -n "$output" ] || output=/dev/stdout - stdredir "$tmpsorted" "$output" "" awkrun -f \ + stdredir "$tmpsorted" "$output" "" lawkrun -f \ padlen:int="$padlen" \ headerscsv="$headers" show_headers:int="$show_headers" \ ' @@ -2060,7 +2111,7 @@ function lprintcsv() { [ -n "$output" ] || output=/dev/stdout values=("$@") - stdredir "" ">>$output" "" awkrun -f fields[@] show_headers:int="$show_headers" values[@] ' + stdredir "" ">>$output" "" lawkrun -f fields[@] show_headers:int="$show_headers" values[@] ' BEGIN { if (show_headers) array_printcsv(fields) if (fields_count > 0) count = fields_count diff --git a/uawk b/uawk index bd9716a..c59351a 100755 --- a/uawk +++ b/uawk @@ -1,7 +1,7 @@ #!/bin/bash # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 -TOOLS=(awkrun awkcsv grepcsv awkfsv2csv mergecsv sortcsv dumpcsv printcsv) +TOOLS=(awkrun awkcsv grepcsv awkfsv2csv awkcsv2fsv mergecsv sortcsv dumpcsv printcsv) if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then # créer les liens scriptname="$(basename "$0")" @@ -49,6 +49,7 @@ run) tool=awkrun;; csv) tool=awkcsv;; grep) tool=grepcsv;; fsv2csv|fsv) tool=awkfsv2csv;; +csv2fsv) tool=awkcsv2fsv;; merge) tool=mergecsv;; sort) tool=sortcsv;; dump) tool=dumpcsv;; @@ -95,12 +96,23 @@ elif [ "$tool" == "awkfsv2csv" ]; then ${Clang:+note: ce script ne tient pas compte de la locale: il travaille avec LANG=C } USAGE - $scriptname [options] -- [header:sizes...] [-- inputfiles...] + $scriptname [options] -- [header:size,...] [-- inputfiles...] $__AWKFSV2CSV_HELP" "${prefix}awkfsv2csv" "$@" +elif [ "$tool" == "awkcsv2fsv" ]; then + [ $# -eq 1 -a "$1" == --help ] && exit_with uecho "$scriptname: wrapper autour de awk pour transformer un fichier à colonnes fixes en fichier csv +${Clang:+note: ce script ne tient pas compte de la locale: il travaille avec LANG=C +} +USAGE + $scriptname [options] -- [field:size,...] [-- inputfiles...] + +$__AWKCSV2FSV_HELP" + + "${prefix}awkcsv2fsv" "$@" + elif [ "$tool" == "mergecsv" ]; then [ $# -eq 1 -a "$1" == --help ] && exit_with uecho "$scriptname: fusionner deux fichiers csv sur un champ commun ${Clang:+note: ce script ne tient pas compte de la locale: il travaille avec LANG=C From ef00e07b212de6a704c8b25b5aa93605a6b5e7c8 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 24 Aug 2017 13:39:49 +0400 Subject: [PATCH 10/13] bug --- ussh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ussh b/ussh index de2b92c..74abe6f 100755 --- a/ussh +++ b/ussh @@ -386,7 +386,7 @@ function show_vars() { function do_ssh() { local -a sshopts local onehost r - if [ $# -eq 0 ]; then + if [ ${#hosts[*]} -eq 0 -a $# -eq 0 ]; then ${exec:+exec} "$SSH" "${SSHOPTS[@]}" return elif [ "${#hosts[*]}" -gt 1 ]; then From e4f154efc62a410ac2eee538022a79598e03a655 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Fri, 25 Aug 2017 15:45:39 +0400 Subject: [PATCH 11/13] =?UTF-8?q?uawk:=20possibilit=C3=A9=20de=20lancer=20?= =?UTF-8?q?les=20versions=20locale-aware?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/awk | 8 +++----- uawk | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/ulib/awk b/lib/ulib/awk index 2a289b0..1de1465 100644 --- a/lib/ulib/awk +++ b/lib/ulib/awk @@ -1140,19 +1140,17 @@ function lawkcsv2fsv() { done shift - lawkcsv -v fields[@] -v sizes[@] -a ' -{ + lawkcsv -v fields[@] -v sizes[@] -a '{ line = "" for (i = 1; i <= fields_count; i++) { size = sizes[i] + 0 - value = get(fields[i]) + value = get(fields[i]) "" while (length(value) < size) value = value " " if (length(value) > size) value = substr(value, 1, size) line = line value } print line -} -' -- "$@" +}' -- "$@" } function cawkcsv2fsv() { LANG=C lawkcsv2fsv "$@"; } diff --git a/uawk b/uawk index c59351a..9b6d3ec 100755 --- a/uawk +++ b/uawk @@ -45,14 +45,22 @@ fi # Aliases pour les noms d'outils case "$tool" in -run) tool=awkrun;; -csv) tool=awkcsv;; -grep) tool=grepcsv;; -fsv2csv|fsv) tool=awkfsv2csv;; -csv2fsv) tool=awkcsv2fsv;; -merge) tool=mergecsv;; -sort) tool=sortcsv;; -dump) tool=dumpcsv;; +run) tool=awkrun; toolprefix=; prefix=c; Clang=1;; +lrun) tool=awkrun; toolprefix=l; prefix=l; Clang=;; +csv) tool=awkcsv; toolprefix=; prefix=c; Clang=1;; +lcsv) tool=awkcsv; toolprefix=l; prefix=l; Clang=;; +grep) tool=grepcsv; toolprefix=; prefix=c; Clang=1;; +lgrep) tool=grepcsv; toolprefix=l; prefix=l; Clang=;; +fsv2csv|fsv) tool=awkfsv2csv; toolprefix=; prefix=c; Clang=1;; +lfsv2csv|lfsv) tool=awkfsv2csv; toolprefix=l; prefix=l; Clang=;; +csv2fsv) tool=awkcsv2fsv; toolprefix=; prefix=c; Clang=1;; +lcsv2fsv) tool=awkcsv2fsv; toolprefix=l; prefix=l; Clang=;; +merge) tool=mergecsv; toolprefix=; prefix=c; Clang=1;; +lmerge) tool=mergecsv; toolprefix=l; prefix=l; Clang=;; +sort) tool=sortcsv; toolprefix=; prefix=c; Clang=1;; +lsort) tool=sortcsv; toolprefix=l; prefix=l; Clang=;; +dump) tool=dumpcsv; toolprefix=; prefix=c; Clang=1;; +ldump) tool=dumpcsv; toolprefix=l; prefix=l; Clang=;; esac scriptname="$toolprefix$tool" From 1ee4de04c46667c060f43d85502e5db9da2b1722 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Fri, 25 Aug 2017 15:53:53 +0400 Subject: [PATCH 12/13] Init changelog & version 7.0.0 --- CHANGES.md | 14 ++++++++++++++ VERSION.txt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7bcc43a..f37efd0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,17 @@ +## Version 7.0.0 du 25/08/2017-15:53 + +* `e4f154e` uawk: possibilité de lancer les versions locale-aware +* `ef00e07` bug +* `377ca5e` implémenter awkcsv2fsv. corriger un bug avec les outils qui utilisaient cawkrun à l'intérieur d'une fonction l* +* `2f448d5` ussh: problèmes de compatibilité +* `2cc2411` bug potentiel +* `65bd363` webpyapp: réorganiser les fichiers pour supporter des librairies locales +* `0b39b23` webpyapp: les variables de server.conf sont configurables +* `d1a1d4d` webpyapp: cosmetic +* `46fbec7` webpyapp: bootstrap facilité des sessions +* `c541958` webpyapp: support du mode développement +* `e2ea2ea` ufile: ajout de --force-cp + ## Version 6.7.0 du 19/07/2017-15:45 * `1b92275` apacheconfig: support d'un script post-update.sh diff --git a/VERSION.txt b/VERSION.txt index f0e13c5..66ce77b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -6.7.0 +7.0.0 From 747c056aece14568f09edcbd3fd1f3ef66e33f3c Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Fri, 25 Aug 2017 15:54:10 +0400 Subject: [PATCH 13/13] maj ulib --- lib/ulib/.ulibver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ulib/.ulibver b/lib/ulib/.ulibver index 4081a1a..651b787 100644 --- a/lib/ulib/.ulibver +++ b/lib/ulib/.ulibver @@ -1 +1 @@ -014003000 +015000000