Datei redundant, da die Erstellung der Metadaten-CSV des Teilestamms bereits über die Funktion 'get_teilestamm.py' in 'update_database.py' erfolgt.
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
"""
|
||||
Dieses Programm:
|
||||
- Holt sich alle notwendigen Einzelteil-Informationen aus SIVAS in Tabellenform
|
||||
"""
|
||||
|
||||
|
||||
def get_sivas_teilestamm(sivas_id, out_dir):
|
||||
sivas_id = sivas_id.strip()
|
||||
sivas_teilestamm_exe = os.environ.get('SIVAS_TEILESTAMM')
|
||||
|
||||
if os.path.isfile(sivas_teilestamm_exe):
|
||||
|
||||
if os.path.isdir(out_dir):
|
||||
print(f"Attempting to generate a json-file of all parts to be migrated in relation with '{sivas_id}'")
|
||||
source_path = os.path.join(os.path.expandvars("%USERPROFILE%"), "AppData", "Local", "Temp", "from_siv.csv")
|
||||
to_path = os.path.join(out_dir, sivas_id + ".csv")
|
||||
if os.path.isfile(os.path.join(to_path)):
|
||||
print("file already there. done")
|
||||
exit()
|
||||
|
||||
subprocess.run(f"{sivas_teilestamm_exe} userid=sivas password=forte database=sivas program=ExcelUeb LFDNR=500 EINSTIEG=SQL PARAMETER1={sivas_id}")
|
||||
if os.path.isfile(os.path.join(source_path)):
|
||||
shutil.move(source_path, to_path)
|
||||
print("done")
|
||||
else:
|
||||
print(f"Failure - Couldn't generate {sivas_id}.json. Check for any spelling/typing errors. Otherwise given number is a part without a BOM.")
|
||||
exit()
|
||||
else:
|
||||
print(f"'Output directory for .json-file {out_dir}' doesn't exist.")
|
||||
else:
|
||||
print(f"Can't execute SIVAS-database query. Check if you have established a VPN connection to the company's network and check the path of %SIVAS_DATABASE_QUERY% in cremig_setenv.bat")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='fetches data from sivas or ruledesigner fusion', prog='update_database')
|
||||
parser.add_argument('-s', '--sivasid', action='store', help='fetch data of this id from sivas fo local database folder', metavar='id')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
out_dir = os.environ.get('CREMIG_DATA')
|
||||
|
||||
if args.sivasid:
|
||||
get_sivas_teilestamm(args.sivasid, out_dir)
|
||||
|
||||
else:
|
||||
parser.print_help()
|
||||
Reference in New Issue
Block a user