blackliste wird geholt und geschrieben

This commit is contained in:
2023-12-11 16:09:55 +01:00
parent 5ee52211e0
commit e34ebd1d53
4 changed files with 35 additions and 4 deletions
+2 -2
View File
@@ -37,14 +37,14 @@
],
}
{
"name": "Python: TOS string to file",
"name": "fetch blacklist from server",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"--outfile=blubb.txt"
"--blacklist"
],
}
+1 -2
View File
@@ -2,6 +2,5 @@
CALL cremig_setenv.bat
IF NOT EXIST %CREMIG%\.venv CALL %CREMIG_BIN%\install_py.bat
CALL %CREMIG%\.venv\Scripts\activate.bat
IF "%1" == "-s" (set SIVAS_ID=%2) else (set /p SIVAS_ID=Enter Sivas ID:)
python %CREMIG_LIB%\update_database.py --sivas=%SIVAS_ID%
python %CREMIG_LIB%\update_database.py --blacklist
deactivate
+2
View File
@@ -16,6 +16,8 @@ set PATH=%CREMIG%\bin;%PATH%
set RD_DATABASE_SOURCE=\\ssg.local\freigaben\SIVAS_CAD_EDM\Migration\07_RD_Teilenummern
set RD_DATABASE_NAME=RD_Teilenummern.csv
set BLACKLIST_DATABASE_SOURCE=\\ruledesigner\RDF_Daten\Konfigurator\CustomVaulting
set BLACKLIST_DATABASE_NAME=ERP_BOM.ini
set VBA_MACRO_NAME=vba_format_excel.xlsm
set SIVAS_DATABASE_QUERY=Y:\jit\programme\Sivas2json.exe
REM set SIVAS_TEILESTAMM=\\195.243.223.3\sivas\NetEnv\Sivas4.exe
+30
View File
@@ -2,6 +2,7 @@ import argparse
import os
import shutil
import subprocess
import configparser
"""
Dieses Programm:
@@ -9,6 +10,31 @@ Dieses Programm:
- Fragt Sivas ab und generiert dabei eine json-Datei, in der alle Teilenummern aufgelistet sind,
die in Verbindung mit einer angegebenen Teilenummer migriert werden müssen.
"""
def get_blacklist(outdir):
"""read out list of sivas Ids which are not allowed from network drive
'//ruledesigner//DF_Daten//onfigurator//ustomVaulting//RP_BOM.ini'
within the section 'Settings'
in the key 'PartNumbersToDrop'
"""
blacklist_net_share = os.environ.get("BLACKLIST_DATABASE_SOURCE")
blacklist_ini_filename = os.environ.get("BLACKLIST_DATABASE_NAME")
blacklist_source_path = os.path.join(blacklist_net_share, blacklist_ini_filename)
config = configparser.RawConfigParser()
try:
config.read(blacklist_source_path)
except configparser.DuplicateOptionError:
pass
content = config.get('Settings','PartNumbersToDrop')
blacklist_str = content[0] # warum das als Liste erkannt wird wissen die Götter...
if len(blacklist_str) == 0 or len(content) == 0:
print(f"import of '{blacklist_ini_filename}' from '{blacklist_net_share}' failed")
exit
blacklist = blacklist_str.split(';')
outfile = os.path.join(outdir, 'blacklist.txt')
with open(outfile, 'w', encoding='utf-8') as fh:
fh.write('\n'.join(blacklist))
def get_rd_dbase(out_dir):
@@ -53,6 +79,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='fetches data from sivas or ruledesigner fusion', prog='update_database')
parser.add_argument('-s', '--sivas', action='store', help='fetch data of this id from sivas fo local database folder', metavar='id')
parser.add_argument('-r', '--rd', action='store_true', help='fetch list of existing parts from network drive')
parser.add_argument('-b', '--blacklist', action='store_true', help='fetch list of not allowed parts from network drive')
args = parser.parse_args()
@@ -64,5 +91,8 @@ if __name__ == '__main__':
elif args.sivas:
get_sivas_dbase(args.sivas, out_dir)
elif args.blacklist:
get_blacklist(out_dir)
else:
parser.print_help()