main.cfg: use a REPOS configuration structure to provide different paths and dbnames

This commit is contained in:
Silvan Calarco 2022-10-02 19:40:02 +02:00
parent c9c45aa9ae
commit 52ffaab7e4
2 changed files with 9 additions and 6 deletions

View File

@ -31,9 +31,10 @@ def _cursorRowToDict(cursor, row):
def latest():
response = {}
for repo in app.config['SEARCH_REPOS']:
for repo in app.config['REPOS']:
response[repo] = []
REPO_SOURCES_DB = "file:" + app.config['REPO_BASEDIR'] + f"{repo}-sources.db?mode=ro"
REPO_SOURCES_DB = "file:" + app.config['REPOS'][repo]['path'] + f"{app.config['REPOS'][repo]['dbname']}-sources.db?mode=ro"
logger.info(REPO_SOURCES_DB)
conn = sqlite3.connect(REPO_SOURCES_DB, uri=True)
cursor = conn.cursor()
cursor.execute(
@ -48,9 +49,9 @@ def query(qs):
logger.info(f"Query of {qs}")
response = {}
for repo in app.config['SEARCH_REPOS']:
for repo in app.config['REPOS']:
response[repo] = []
REPO_SOURCES_DB = "file:" + app.config['REPO_BASEDIR'] + f"{repo}-sources.db?mode=ro"
REPO_SOURCES_DB = "file:" + app.config['REPOS'][repo]['path'] + f"{app.config['REPOS'][repo]['dbname']}-sources.db?mode=ro"
conn = sqlite3.connect(REPO_SOURCES_DB, uri=True)
cursor = conn.cursor()
cursor.execute(

View File

@ -1,5 +1,7 @@
#
# WebDist main configuration file
#
REPO_BASEDIR = "/var/webbuild/db/"
SEARCH_REPOS = [ 'devel', 'devel-makedist', 'devel-autodist' ]
REPOS = {
'openmamba-rolling': { 'dbname': 'devel', 'path': '/var/autodist/db/' },
'openmamba-testing': { 'dbname': 'devel-makedist', 'path': '/var/autodist/db/' },
}