update Database dazu
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
# import configparser
|
||||
# import json
|
||||
|
||||
"""
|
||||
Dieses Programm holt sich aus
|
||||
- RD Fusion eine aktuellen Stand der exisitierenden IDS
|
||||
- Sivas eine Liste der gewünschten Teile
|
||||
|
||||
"""
|
||||
|
||||
|
||||
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')
|
||||
parser.add_argument('-r', '--rd', action='store_true', help='fetch list of existing parts from RD Fusion')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
outDir = os.environ.get('CREMIG_DATA')
|
||||
if args.rd:
|
||||
inPath = os.environ.get('RD_DATABASE_SOURCE')
|
||||
outFileName = "RD_Bestandspool.csv"
|
||||
if os.path.isfile(inPath):
|
||||
|
||||
outFilePath = os.path.join(outDir, outFileName)
|
||||
if os.path.isdir(outDir):
|
||||
shutil.copyfile(inPath, outFilePath)
|
||||
else:
|
||||
print(f"no such directory ${outDir} of env CREMIG_DATA")
|
||||
print("done")
|
||||
else:
|
||||
print(f"no such file ${inPath} of environment variable RD_DATABASE_SOURCE. have a look at cremig_setenv.bat")
|
||||
|
||||
if args.sivas:
|
||||
exePath = os.environ.get('SIVAS_DATABASE_QUERY')
|
||||
sivasId = str(args.sivas)
|
||||
if os.path.isfile(exePath):
|
||||
outFilePath = os.path.join(outDir, sivasId + ".json")
|
||||
if os.path.isdir(outDir):
|
||||
#subprocess.Popen([exePath, "-o", outDir, "--format json", "-number", sivasId ])
|
||||
cmd = ' '.join([exePath, "-o", outDir, "--format json", "-number", sivasId ])
|
||||
os.system(cmd)
|
||||
else:
|
||||
print(f"no such executable ${outDir} of env CREMIG_DATA")
|
||||
print("done")
|
||||
else:
|
||||
print(f"no such file ${exePath} of environment variable SIVAS_DATABASE_QUERY. have a look at cremig_setenv.bat")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user