blackliste wird geholt und geschrieben
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user