From ee3b63b79291de930496b2becef1b93af8fefd9a Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sun, 5 May 2019 23:15:09 -0700 Subject: [PATCH] fixed create missing folders, thanks Paolo --- gluon/fileutils.py | 26 +++++++++++++++----------- gluon/widget.py | 3 +-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/gluon/fileutils.py b/gluon/fileutils.py index 54c22a7c..82eefa4d 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -254,12 +254,23 @@ def w2p_pack(filename, path, compiled=False, filenames=None): os.unlink(tarname) +def create_missing_folders(path): + for subfolder in ('models', 'views', 'controllers', 'databases', + 'modules', 'cron', 'errors', 'sessions', + 'languages', 'static', 'private', 'uploads'): + subpath = os.path.join(path, subfolder) + if not os.path.exists(subpath): + os.mkdir(subpath) + + def create_welcome_w2p(): is_newinstall = os.path.exists('NEWINSTALL') if not os.path.exists('welcome.w2p') or is_newinstall: logger = logging.getLogger("web2py") try: - w2p_pack('welcome.w2p', 'applications/welcome') + app_path = 'applications/welcome' + create_missing_folders(app_path) + w2p_pack('welcome.w2p', app_path) logger.info("New installation: created welcome.w2p file") except: logger.exception("New installation error: unable to create welcome.w2p file") @@ -291,17 +302,10 @@ def w2p_unpack(filename, path, delete_tar=True): if delete_tar: os.unlink(tarname) -def create_missing_folders(path): - for subfolder in ('models', 'views', 'controllers', 'databases', - 'modules', 'cron', 'errors', 'sessions', - 'languages', 'static', 'private', 'uploads'): - subpath = os.path.join(path, subfolder) - if not os.path.exists(subpath): - os.mkdir(subpath) def create_app(path): w2p_unpack('welcome.w2p', path) - create_missing_folders(path) + def w2p_pack_plugin(filename, path, plugin_name): """Packs the given plugin into a w2p file. @@ -424,6 +428,7 @@ def fix_newlines(path): write_file(filename, wdata, 'w') +# FIXME: do we really need this ? def copystream( src, dest, @@ -460,9 +465,8 @@ def abspath(*relpath, **base): applications_parent """ path = os.path.join(*relpath) - gluon = base.get('gluon', False) if os.path.isabs(path): return path - if gluon: + if base.get('gluon', False): return os.path.join(global_settings.gluon_parent, path) return os.path.join(global_settings.applications_parent, path) diff --git a/gluon/widget.py b/gluon/widget.py index cac55d88..a70a40e0 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -23,7 +23,7 @@ import logging import getpass from gluon import main, newcron -from gluon.fileutils import read_file, create_welcome_w2p, create_missing_folders +from gluon.fileutils import read_file, create_welcome_w2p from gluon.console import console from gluon.settings import global_settings from gluon.shell import die, run, test @@ -368,7 +368,6 @@ class web2pyDialog(object): def try_start_scheduler(self, app): if app not in self.scheduler_processes: - create_missing_folders(os.path.join(self.options.folder, 'applications', app)) t = threading.Thread(target=self.start_schedulers, args=(app,)) t.start()