debut restructuration scripts upgrade

This commit is contained in:
Emmanuel Viennet 2021-08-02 09:41:11 +03:00
parent 6cd868b7a3
commit 2c4ff46a3a
3 changed files with 8 additions and 26 deletions

1
tools/__init__.py Normal file
View File

@ -0,0 +1 @@
# tools package: en cours de restructuration

View File

@ -1,4 +1,4 @@
#!/opt/zope213/bin/python #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
@ -15,7 +15,7 @@ existing scodoc instances).
E. Viennet, june 2008, sept 2013 E. Viennet, june 2008, sept 2013
""" """
from scodocutils import * from tools.scodocutils import *
for dept in get_depts(): for dept in get_depts():
log("\nChecking database for dept %s" % dept) log("\nChecking database for dept %s" % dept)
@ -30,6 +30,8 @@ for dept in get_depts():
continue continue
cnx.set_session(autocommit=False) cnx.set_session(autocommit=False)
cursor = cnx.cursor() cursor = cnx.cursor()
print "passing !"
continue
# Apply upgrades: # Apply upgrades:
# SVN 564 -> 565 # SVN 564 -> 565

View File

@ -10,7 +10,7 @@ import os
import sys import sys
import traceback import traceback
sys.path.append("..") from config import Config
def log(msg): def log(msg):
@ -20,21 +20,9 @@ def log(msg):
sys.stderr.flush() 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): def get_dept_cnx_str(dept):
"db cnx string for 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: try:
return open(f).readline().strip() return open(f).readline().strip()
except: except:
@ -43,18 +31,9 @@ def get_dept_cnx_str(dept):
raise 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(): def get_depts():
"list of defined 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] return [os.path.splitext(os.path.split(f)[1])[0] for f in files]