|
5 | 5 | import os |
6 | 6 | import glob |
7 | 7 | from pathlib import Path |
8 | | -import time |
9 | 8 | import shutil |
10 | 9 |
|
11 | 10 |
|
12 | | -core.set_default_server_context(core.AvailableServerContexts.premium) |
13 | | - |
14 | | -if os.name == "posix": |
15 | | - LIB_TO_GENERATE = [ |
16 | | - "libAns.Dpf.Native.so", |
17 | | - "libAns.Dpf.FEMutils.so", |
18 | | - "libmapdlOperatorsCore.so", |
19 | | - "libmeshOperatorsCore.so", |
20 | | - "libAns.Dpf.Math.so", |
21 | | - "libAns.Dpf.Hdf5.so", |
22 | | - "libAns.Dpf.LSDYNAHGP.so", |
23 | | - "libAns.Dpf.LivePost.so", |
24 | | - "libans.dpf.pointcloudsearch.so", |
25 | | - "libAns.Dpf.Vtk.so", |
26 | | - "libAns.Dpf.MechanicalResults.so", |
27 | | - ] |
28 | | - LIB_OPTIONAL_TO_GENERATE = [ |
29 | | - "libAns.Dpf.SystemCouplingMapping.so", |
30 | | - ] |
31 | | -else: |
32 | | - LIB_TO_GENERATE = [ |
33 | | - "Ans.Dpf.Native.dll", |
34 | | - "Ans.Dpf.FEMutils.dll", |
35 | | - "meshOperatorsCore.dll", |
36 | | - "mapdlOperatorsCore.dll", |
37 | | - "Ans.Dpf.Math.dll", |
38 | | - "Ans.Dpf.PythonPluginWrapper.dll", |
39 | | - "Ans.Dpf.Hdf5.dll", |
40 | | - "Ans.Dpf.FlowDiagram.dll", |
41 | | - "Ans.Dpf.LSDYNAHGP.dll", |
42 | | - "Ans.Dpf.LivePost.dll", |
43 | | - "Ans.Dpf.PointCloudSearch.dll", |
44 | | - "Ans.Dpf.Vtk.dll", |
45 | | - "Ans.Dpf.MechanicalResults.dll", |
46 | | - ] |
47 | | - LIB_OPTIONAL_TO_GENERATE = [ |
48 | | - "Ans.Dpf.SystemCouplingMapping.dll", |
49 | | - ] |
50 | | - |
51 | 11 | local_dir = os.path.dirname(os.path.abspath(__file__)) |
52 | 12 | TARGET_PATH = os.path.join(local_dir, os.pardir, "src", "ansys", "dpf", "core", "operators") |
53 | 13 | files = glob.glob(os.path.join(TARGET_PATH, "*")) |
|
65 | 25 | os.remove(f) |
66 | 26 | except: |
67 | 27 | pass |
68 | | -core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer) |
69 | | -code_gen = core.Operator("python_generator") |
70 | | -code_gen.connect(1, TARGET_PATH) |
71 | | -for lib in LIB_TO_GENERATE: |
72 | | - try: |
73 | | - code_gen.connect(0, lib) |
74 | | - if lib != LIB_TO_GENERATE[0]: |
75 | | - code_gen.connect(2, False) |
76 | | - else: |
77 | | - code_gen.connect(2, True) |
78 | | - print(f"Generating {lib} operators for server {core.SERVER.version}...") |
79 | | - code_gen.run() |
80 | | - time.sleep(0.1) |
81 | | - except Exception as e: |
82 | | - print(f"Could not generate operators for library {lib}:\n{str(e)}") |
83 | | - raise e |
84 | 28 |
|
85 | | -for lib in LIB_OPTIONAL_TO_GENERATE: |
86 | | - try: |
87 | | - code_gen.connect(0, lib) |
88 | | - if lib != LIB_OPTIONAL_TO_GENERATE[0]: |
89 | | - code_gen.connect(2, False) |
90 | | - else: |
91 | | - code_gen.connect(2, True) |
92 | | - print(f"Generating optional {lib} operators for server {core.SERVER.version}...") |
93 | | - code_gen.run() |
94 | | - time.sleep(0.1) |
95 | | - except Exception as e: |
96 | | - print(f"Could not generate operators for optional library {lib}:\n{str(e)}") |
97 | | - |
98 | | -# Reorder imports alphabetically in __init__.py files to reduce changes raised |
99 | | -for init_file_path in glob.glob(os.path.join(TARGET_PATH, "**/__init__.py"), recursive=True): |
100 | | - with open(init_file_path, "r") as init_file: |
101 | | - lines = init_file.readlines() |
102 | | - with open(init_file_path, "w") as init_file: |
103 | | - init_file.writelines(sorted(lines)) |
| 29 | +core.set_default_server_context(core.AvailableServerContexts.premium) |
| 30 | +core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer) |
104 | 31 |
|
105 | 32 | build.build_operators() |
0 commit comments