From 2c4ff46a3ad91f72ecfe0f92f69770b1f1eb1022 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 2 Aug 2021 09:41:11 +0300 Subject: [PATCH] debut restructuration scripts upgrade --- tools/__init__.py | 1 + tools/postupgrade-db.py | 6 ++++-- tools/scodocutils.py | 27 +++------------------------ 3 files changed, 8 insertions(+), 26 deletions(-) create mode 100644 tools/__init__.py diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100644 index 000000000..b2501688f --- /dev/null +++ b/tools/__init__.py @@ -0,0 +1 @@ +# tools package: en cours de restructuration diff --git a/tools/postupgrade-db.py b/tools/postupgrade-db.py index bec3038ee..e4a4f50bb 100755 --- a/tools/postupgrade-db.py +++ b/tools/postupgrade-db.py @@ -1,4 +1,4 @@ -#!/opt/zope213/bin/python +#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ @@ -15,7 +15,7 @@ existing scodoc instances). E. Viennet, june 2008, sept 2013 """ -from scodocutils import * +from tools.scodocutils import * for dept in get_depts(): log("\nChecking database for dept %s" % dept) @@ -30,6 +30,8 @@ for dept in get_depts(): continue cnx.set_session(autocommit=False) cursor = cnx.cursor() + print "passing !" + continue # Apply upgrades: # SVN 564 -> 565 diff --git a/tools/scodocutils.py b/tools/scodocutils.py index f5cb036d6..9c378992a 100755 --- a/tools/scodocutils.py +++ b/tools/scodocutils.py @@ -10,7 +10,7 @@ import os import sys import traceback -sys.path.append("..") +from config import Config def log(msg): @@ -20,21 +20,9 @@ def log(msg): sys.stderr.flush() -SCODOC_DIR = os.environ.get("SCODOC_DIR", "") -if not SCODOC_DIR: - log("Error: environment variable SCODOC_DIR is not defined") - sys.exit(1) -SCODOC_VAR_DIR = os.environ.get("SCODOC_VAR_DIR", "") -if not SCODOC_VAR_DIR: - log("Error: environment variable SCODOC_VAR_DIR is not defined") - sys.exit(1) -SCO_TMPDIR = os.path.join(SCODOC_VAR_DIR, "tmp") -SCODOC_LOGOS_DIR = os.environ.get("SCODOC_LOGOS_DIR", "") - - def get_dept_cnx_str(dept): "db cnx string for dept" - f = os.path.join(SCODOC_VAR_DIR, "config", "depts", dept + ".cfg") + f = os.path.join(Config.SCODOC_VAR_DIR, "config", "depts", dept + ".cfg") try: return open(f).readline().strip() except: @@ -43,18 +31,9 @@ def get_dept_cnx_str(dept): raise -def get_users_cnx_str(): - "db cnx string for users database (used only during upgrades to modify db schema)" - # uses default in sco_utils - # For customized installs, define the value here (used only during upgrades) - from app.scodoc import sco_utils - - return sco_utils.SCO_DEFAULT_SQL_USERS_CNX - - def get_depts(): "list of defined depts" - files = glob.glob(SCODOC_VAR_DIR + "/config/depts/*.cfg") + files = glob.glob(Config.SCODOC_VAR_DIR + "/config/depts/*.cfg") return [os.path.splitext(os.path.split(f)[1])[0] for f in files]