erste Compare Rumpf Routine impl.

This commit is contained in:
2023-10-19 17:28:47 +02:00
parent a1d8102774
commit 4efff81666
5 changed files with 60 additions and 47 deletions
+31 -25
View File
@@ -11,12 +11,39 @@ Dieses Programm holt sich aus
- Sivas eine Liste der gewünschten Teile
"""
def get_rd_database(inPath, outDir, outFileName):
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")
def get_sivas_databse(exePath, sivasId, outFilePath):
if os.path.isfile(exePath):
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")
if os.path.isfile(outFilePath):
print("done")
else:
print("failure - did not get .json file")
else:
print(f"no such file ${exePath} of environment variable SIVAS_DATABASE_QUERY. have a look at cremig_setenv.bat")
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')
parser.add_argument('-r', '--rd', action='store_true', help='fetch list of existing parts from network drive')
args = parser.parse_args()
@@ -24,32 +51,11 @@ if __name__ == '__main__':
if args.rd:
inPath = os.environ.get('RD_DATABASE_SOURCE')
outFileName = "RD_Bestandspool.csv"
if os.path.isfile(inPath):
get_rd_database(inPath, outDir, outFileName)
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")
outFilePath = os.path.join(outDir, sivasId + ".json")
get_sivas_databse(exePath, sivasId, outFilePath)