2023-05-04 15:06:55 +02:00
|
|
|
# Copyright (c) 2023 Thomas Tuerk (kontakt@thomas-tuerk.de)
|
|
|
|
#
|
|
|
|
# This file is part of PyAPplus64 (see https://www.thomas-tuerk.de/de/pyapplus64).
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by an MIT-style
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
# https://opensource.org/licenses/MIT.
|
|
|
|
|
|
|
|
import pathlib
|
|
|
|
import PyAPplus64
|
|
|
|
import applus_configs
|
|
|
|
|
2023-05-06 19:23:20 +02:00
|
|
|
def main(confFile : pathlib.Path, updateDB:bool, docDir:str|None = None) -> None:
|
2023-05-04 15:06:55 +02:00
|
|
|
server = PyAPplus64.applus.applusFromConfigFile(confFile)
|
|
|
|
|
2023-05-06 19:23:20 +02:00
|
|
|
if docDir is None:
|
|
|
|
docDir = str(server.scripttool.getInstallPathWebServer().joinpath("DocLib"))
|
|
|
|
|
2023-05-04 15:06:55 +02:00
|
|
|
sql = PyAPplus64.sql_utils.SqlStatementSelect("ARTIKEL");
|
|
|
|
sql.addFields("ID", "ARTIKEL", "DOCUMENTS");
|
|
|
|
sql.where.addConditionFieldStringNotEmpty("DOCUMENTS");
|
|
|
|
|
|
|
|
for row in server.dbQueryAll(sql):
|
|
|
|
doc = pathlib.Path(docDir + row.DOCUMENTS);
|
|
|
|
if not doc.exists():
|
|
|
|
print("Bild '{}' für Artikel '{}' nicht gefunden".format(doc, row.ARTIKEL))
|
|
|
|
|
|
|
|
if updateDB:
|
|
|
|
upd = server.mkUseXMLRowUpdate("ARTIKEL", row.ID);
|
|
|
|
upd.addField("DOCUMENTS", None);
|
|
|
|
upd.update();
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-05-06 19:23:20 +02:00
|
|
|
main(applus_configs.serverConfYamlTest, False)
|