pyedb 0.54.0__py3-none-any.whl → 0.56.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyedb might be problematic. Click here for more details.
- pyedb/__init__.py +1 -8
- pyedb/configuration/cfg_boundaries.py +69 -151
- pyedb/configuration/cfg_components.py +201 -460
- pyedb/configuration/cfg_data.py +4 -2
- pyedb/configuration/cfg_general.py +13 -36
- pyedb/configuration/cfg_modeler.py +2 -1
- pyedb/configuration/cfg_nets.py +21 -35
- pyedb/configuration/cfg_operations.py +22 -151
- pyedb/configuration/cfg_package_definition.py +56 -112
- pyedb/configuration/cfg_padstacks.py +292 -688
- pyedb/configuration/cfg_pin_groups.py +32 -79
- pyedb/configuration/cfg_ports_sources.py +19 -6
- pyedb/configuration/cfg_s_parameter_models.py +67 -172
- pyedb/configuration/cfg_setup.py +102 -295
- pyedb/configuration/configuration.py +64 -5
- pyedb/dotnet/database/Variables.py +26 -19
- pyedb/dotnet/database/cell/connectable.py +38 -9
- pyedb/dotnet/database/cell/hierarchy/component.py +28 -28
- pyedb/dotnet/database/cell/hierarchy/model.py +1 -1
- pyedb/dotnet/database/cell/layout.py +63 -2
- pyedb/dotnet/database/cell/layout_obj.py +2 -2
- pyedb/dotnet/database/cell/primitive/path.py +6 -8
- pyedb/dotnet/database/cell/primitive/primitive.py +3 -24
- pyedb/dotnet/database/cell/terminal/edge_terminal.py +2 -2
- pyedb/dotnet/database/cell/terminal/padstack_instance_terminal.py +1 -1
- pyedb/dotnet/database/cell/terminal/pingroup_terminal.py +1 -1
- pyedb/dotnet/database/cell/terminal/point_terminal.py +1 -1
- pyedb/dotnet/database/cell/terminal/terminal.py +24 -24
- pyedb/dotnet/database/cell/voltage_regulator.py +0 -21
- pyedb/dotnet/database/components.py +137 -124
- pyedb/dotnet/database/definition/component_def.py +4 -4
- pyedb/dotnet/database/definition/component_model.py +1 -1
- pyedb/dotnet/database/definition/package_def.py +2 -3
- pyedb/dotnet/database/dotnet/database.py +3 -199
- pyedb/dotnet/database/dotnet/primitive.py +3 -3
- pyedb/dotnet/database/edb_data/control_file.py +5 -5
- pyedb/dotnet/database/edb_data/hfss_extent_info.py +6 -6
- pyedb/dotnet/database/edb_data/layer_data.py +23 -23
- pyedb/dotnet/database/edb_data/padstacks_data.py +63 -88
- pyedb/dotnet/database/edb_data/primitives_data.py +5 -5
- pyedb/dotnet/database/edb_data/sources.py +6 -6
- pyedb/dotnet/database/edb_data/variables.py +1 -1
- pyedb/dotnet/database/geometry/point_data.py +14 -10
- pyedb/dotnet/database/geometry/polygon_data.py +3 -3
- pyedb/dotnet/database/hfss.py +46 -48
- pyedb/dotnet/database/layout_validation.py +14 -11
- pyedb/dotnet/database/materials.py +10 -11
- pyedb/dotnet/database/modeler.py +97 -91
- pyedb/dotnet/database/nets.py +19 -22
- pyedb/dotnet/database/padstack.py +171 -83
- pyedb/dotnet/database/siwave.py +42 -42
- pyedb/dotnet/database/stackup.py +140 -72
- pyedb/dotnet/database/utilities/heatsink.py +4 -4
- pyedb/dotnet/database/utilities/obj_base.py +2 -2
- pyedb/dotnet/database/utilities/simulation_setup.py +2 -2
- pyedb/dotnet/database/utilities/value.py +16 -16
- pyedb/dotnet/edb.py +230 -152
- pyedb/edb_logger.py +12 -27
- pyedb/extensions/create_cell_array.py +394 -0
- pyedb/extensions/via_design_backend.py +6 -3
- pyedb/generic/data_handlers.py +6 -7
- pyedb/generic/design_types.py +81 -30
- pyedb/generic/filesystem.py +5 -2
- pyedb/generic/general_methods.py +2 -122
- pyedb/generic/process.py +44 -108
- pyedb/generic/settings.py +79 -19
- pyedb/grpc/database/components.py +26 -4
- pyedb/grpc/database/control_file.py +5 -5
- pyedb/grpc/database/definition/materials.py +1 -1
- pyedb/grpc/database/definition/package_def.py +3 -3
- pyedb/grpc/database/definition/padstack_def.py +53 -0
- pyedb/grpc/database/geometry/polygon_data.py +1 -1
- pyedb/grpc/database/layout/layout.py +81 -5
- pyedb/grpc/database/layout_validation.py +5 -5
- pyedb/grpc/database/modeler.py +24 -16
- pyedb/grpc/database/net/net.py +15 -14
- pyedb/grpc/database/nets.py +70 -0
- pyedb/grpc/database/padstacks.py +122 -17
- pyedb/grpc/database/primitive/padstack_instance.py +175 -7
- pyedb/grpc/database/primitive/polygon.py +2 -2
- pyedb/grpc/database/simulation_setup/siwave_cpa_simulation_setup.py +3 -2
- pyedb/grpc/database/siwave.py +1 -1
- pyedb/grpc/database/source_excitations.py +12 -5
- pyedb/grpc/database/stackup.py +1 -1
- pyedb/grpc/database/terminal/bundle_terminal.py +1 -1
- pyedb/grpc/database/terminal/padstack_instance_terminal.py +1 -1
- pyedb/grpc/database/terminal/pingroup_terminal.py +1 -1
- pyedb/grpc/database/utility/value.py +1 -0
- pyedb/grpc/database/utility/xml_control_file.py +5 -5
- pyedb/grpc/edb.py +80 -30
- pyedb/grpc/edb_init.py +3 -3
- pyedb/grpc/rpc_session.py +14 -13
- pyedb/libraries/common.py +366 -0
- pyedb/libraries/rf_libraries/base_functions.py +1358 -0
- pyedb/libraries/rf_libraries/planar_antennas.py +628 -0
- pyedb/misc/decorators.py +61 -0
- pyedb/misc/misc.py +0 -13
- pyedb/modeler/geometry_operators.py +6 -6
- pyedb/siwave.py +6 -8
- pyedb/siwave_core/__init__.py +0 -0
- pyedb/siwave_core/cpa/__init__.py +0 -0
- {pyedb-0.54.0.dist-info → pyedb-0.56.0.dist-info}/METADATA +1 -2
- {pyedb-0.54.0.dist-info → pyedb-0.56.0.dist-info}/RECORD +105 -98
- {pyedb-0.54.0.dist-info → pyedb-0.56.0.dist-info}/WHEEL +0 -0
- {pyedb-0.54.0.dist-info → pyedb-0.56.0.dist-info}/licenses/LICENSE +0 -0
pyedb/grpc/edb.py
CHANGED
|
@@ -65,7 +65,7 @@ import sys
|
|
|
65
65
|
import tempfile
|
|
66
66
|
import time
|
|
67
67
|
import traceback
|
|
68
|
-
from typing import Union
|
|
68
|
+
from typing import Dict, List, Union
|
|
69
69
|
import warnings
|
|
70
70
|
from zipfile import ZipFile as zpf
|
|
71
71
|
|
|
@@ -99,8 +99,7 @@ from pyedb.grpc.database.layout_validation import LayoutValidation
|
|
|
99
99
|
from pyedb.grpc.database.modeler import Modeler
|
|
100
100
|
from pyedb.grpc.database.net.differential_pair import DifferentialPairs
|
|
101
101
|
from pyedb.grpc.database.net.extended_net import ExtendedNets
|
|
102
|
-
from pyedb.grpc.database.
|
|
103
|
-
from pyedb.grpc.database.nets import Nets
|
|
102
|
+
from pyedb.grpc.database.nets import NetClasses, Nets
|
|
104
103
|
from pyedb.grpc.database.padstacks import Padstacks
|
|
105
104
|
from pyedb.grpc.database.ports.ports import BundleWavePort, CoaxPort, GapPort, WavePort
|
|
106
105
|
from pyedb.grpc.database.primitive.circle import Circle
|
|
@@ -137,6 +136,8 @@ from pyedb.ipc2581.ipc2581 import Ipc2581
|
|
|
137
136
|
from pyedb.modeler.geometry_operators import GeometryOperators
|
|
138
137
|
from pyedb.workflow import Workflow
|
|
139
138
|
|
|
139
|
+
os.environ["no_proxy"] = "localhost,127.0.0.1"
|
|
140
|
+
|
|
140
141
|
|
|
141
142
|
class Edb(EdbInit):
|
|
142
143
|
"""Main class for interacting with Ansys Electronics Desktop Database (EDB).
|
|
@@ -209,7 +210,6 @@ class Edb(EdbInit):
|
|
|
209
210
|
technology_file: str = None,
|
|
210
211
|
layer_filter: str = None,
|
|
211
212
|
restart_rpc_server=False,
|
|
212
|
-
**kwargs,
|
|
213
213
|
):
|
|
214
214
|
edbversion = get_string_version(edbversion)
|
|
215
215
|
self._clean_variables()
|
|
@@ -371,6 +371,10 @@ class Edb(EdbInit):
|
|
|
371
371
|
"""Ansys Edb Core module."""
|
|
372
372
|
return ansys.edb.core
|
|
373
373
|
|
|
374
|
+
@property
|
|
375
|
+
def ansys_em_path(self):
|
|
376
|
+
return self.base_path
|
|
377
|
+
|
|
374
378
|
def _check_remove_project_files(self, edbpath: str, remove_existing_aedt: bool) -> None:
|
|
375
379
|
aedt_file = os.path.splitext(edbpath)[0] + ".aedt"
|
|
376
380
|
files = [aedt_file, aedt_file + ".lock"]
|
|
@@ -402,7 +406,7 @@ class Edb(EdbInit):
|
|
|
402
406
|
self._differential_pairs = DifferentialPairs(self)
|
|
403
407
|
self._extended_nets = ExtendedNets(self)
|
|
404
408
|
|
|
405
|
-
def value(self, val):
|
|
409
|
+
def value(self, val) -> float:
|
|
406
410
|
"""Convert a value into a pyedb value."""
|
|
407
411
|
if isinstance(val, GrpcValue):
|
|
408
412
|
return Value(val)
|
|
@@ -411,7 +415,7 @@ class Edb(EdbInit):
|
|
|
411
415
|
return Value(GrpcValue(val, context), context)
|
|
412
416
|
|
|
413
417
|
@property
|
|
414
|
-
def cell_names(self) -> [str]:
|
|
418
|
+
def cell_names(self) -> List[str]:
|
|
415
419
|
"""List of all cell names in the database.
|
|
416
420
|
|
|
417
421
|
Returns
|
|
@@ -422,7 +426,7 @@ class Edb(EdbInit):
|
|
|
422
426
|
return [cell.name for cell in self.active_db.top_circuit_cells]
|
|
423
427
|
|
|
424
428
|
@property
|
|
425
|
-
def design_variables(self) ->
|
|
429
|
+
def design_variables(self) -> Dict[str, float]:
|
|
426
430
|
"""All design variables in active cell.
|
|
427
431
|
|
|
428
432
|
Returns
|
|
@@ -433,7 +437,7 @@ class Edb(EdbInit):
|
|
|
433
437
|
return {i: Value(self.active_cell.get_variable_value(i)) for i in self.active_cell.get_all_variable_names()}
|
|
434
438
|
|
|
435
439
|
@property
|
|
436
|
-
def project_variables(self) ->
|
|
440
|
+
def project_variables(self) -> Dict[str, float]:
|
|
437
441
|
"""All project variables in database.
|
|
438
442
|
|
|
439
443
|
Returns
|
|
@@ -455,7 +459,7 @@ class Edb(EdbInit):
|
|
|
455
459
|
return LayoutValidation(self)
|
|
456
460
|
|
|
457
461
|
@property
|
|
458
|
-
def variables(self) ->
|
|
462
|
+
def variables(self) -> Dict[str, float]:
|
|
459
463
|
"""All variables (project + design) in database.
|
|
460
464
|
|
|
461
465
|
Returns
|
|
@@ -471,7 +475,7 @@ class Edb(EdbInit):
|
|
|
471
475
|
return all_vars
|
|
472
476
|
|
|
473
477
|
@property
|
|
474
|
-
def terminals(self) ->
|
|
478
|
+
def terminals(self) -> Dict[str, Terminal]:
|
|
475
479
|
"""Terminals in active layout.
|
|
476
480
|
|
|
477
481
|
Returns
|
|
@@ -482,7 +486,7 @@ class Edb(EdbInit):
|
|
|
482
486
|
return {i.name: i for i in self.layout.terminals}
|
|
483
487
|
|
|
484
488
|
@property
|
|
485
|
-
def excitations(self) ->
|
|
489
|
+
def excitations(self) -> Dict[str, GapPort]:
|
|
486
490
|
"""All layout excitations.
|
|
487
491
|
|
|
488
492
|
Returns
|
|
@@ -500,7 +504,7 @@ class Edb(EdbInit):
|
|
|
500
504
|
return temp
|
|
501
505
|
|
|
502
506
|
@property
|
|
503
|
-
def ports(self) ->
|
|
507
|
+
def ports(self) -> Dict[str, GapPort]:
|
|
504
508
|
"""All ports in design.
|
|
505
509
|
|
|
506
510
|
Returns
|
|
@@ -533,7 +537,7 @@ class Edb(EdbInit):
|
|
|
533
537
|
return ports
|
|
534
538
|
|
|
535
539
|
@property
|
|
536
|
-
def excitations_nets(self) -> [str]:
|
|
540
|
+
def excitations_nets(self) -> List[str]:
|
|
537
541
|
"""Nets with excitations defined.
|
|
538
542
|
|
|
539
543
|
Returns
|
|
@@ -544,7 +548,7 @@ class Edb(EdbInit):
|
|
|
544
548
|
return list(set([i.net.name for i in self.layout.terminals if not i.is_reference_terminal]))
|
|
545
549
|
|
|
546
550
|
@property
|
|
547
|
-
def sources(self) ->
|
|
551
|
+
def sources(self) -> Dict[str, Terminal]:
|
|
548
552
|
"""All layout sources.
|
|
549
553
|
|
|
550
554
|
Returns
|
|
@@ -574,7 +578,7 @@ class Edb(EdbInit):
|
|
|
574
578
|
return _vrms
|
|
575
579
|
|
|
576
580
|
@property
|
|
577
|
-
def probes(self) ->
|
|
581
|
+
def probes(self) -> Dict[str, Terminal]:
|
|
578
582
|
"""All layout probes.
|
|
579
583
|
|
|
580
584
|
Returns
|
|
@@ -941,6 +945,7 @@ class Edb(EdbInit):
|
|
|
941
945
|
ValueError
|
|
942
946
|
If cell not found in database.
|
|
943
947
|
"""
|
|
948
|
+
self._layout = None
|
|
944
949
|
if isinstance(value, str):
|
|
945
950
|
_cell = [cell for cell in self.circuit_cells if cell.name == value]
|
|
946
951
|
if _cell:
|
|
@@ -1060,16 +1065,16 @@ class Edb(EdbInit):
|
|
|
1060
1065
|
return self._nets
|
|
1061
1066
|
|
|
1062
1067
|
@property
|
|
1063
|
-
def net_classes(self) ->
|
|
1068
|
+
def net_classes(self) -> NetClasses:
|
|
1064
1069
|
"""Net class management.
|
|
1065
1070
|
|
|
1066
1071
|
Returns
|
|
1067
1072
|
-------
|
|
1068
|
-
|
|
1069
|
-
Net
|
|
1073
|
+
:class:`NetClass <pyedb.grpc.database.nets.NetClasses>`
|
|
1074
|
+
Net classes objects.
|
|
1070
1075
|
"""
|
|
1071
1076
|
if self.active_db:
|
|
1072
|
-
return
|
|
1077
|
+
return NetClasses(self)
|
|
1073
1078
|
|
|
1074
1079
|
@property
|
|
1075
1080
|
def extended_nets(self) -> ExtendedNets:
|
|
@@ -1119,7 +1124,10 @@ class Edb(EdbInit):
|
|
|
1119
1124
|
:class:`Layout <pyedb.grpc.database.layout.layout.Layout>`
|
|
1120
1125
|
Layout manipulation tools.
|
|
1121
1126
|
"""
|
|
1122
|
-
|
|
1127
|
+
if self._layout:
|
|
1128
|
+
return self._layout
|
|
1129
|
+
self._layout = Layout(self)
|
|
1130
|
+
return self._layout
|
|
1123
1131
|
|
|
1124
1132
|
@property
|
|
1125
1133
|
def active_layout(self) -> Layout:
|
|
@@ -1401,7 +1409,7 @@ class Edb(EdbInit):
|
|
|
1401
1409
|
print(command)
|
|
1402
1410
|
temp_inputGDS = inputGDS.split(".gds")[0]
|
|
1403
1411
|
self.edbpath = temp_inputGDS + ".aedb"
|
|
1404
|
-
return self.
|
|
1412
|
+
return self.open()
|
|
1405
1413
|
|
|
1406
1414
|
def _create_extent(
|
|
1407
1415
|
self,
|
|
@@ -1420,6 +1428,7 @@ class Edb(EdbInit):
|
|
|
1420
1428
|
|
|
1421
1429
|
if extent_type in [
|
|
1422
1430
|
"Conforming",
|
|
1431
|
+
"Conformal",
|
|
1423
1432
|
GrpcExtentType.CONFORMING,
|
|
1424
1433
|
1,
|
|
1425
1434
|
]:
|
|
@@ -1521,13 +1530,26 @@ class Edb(EdbInit):
|
|
|
1521
1530
|
unite_polys = []
|
|
1522
1531
|
for i in _polys:
|
|
1523
1532
|
if "PolygonData" not in str(i):
|
|
1524
|
-
obj_data = i.polygon_data.expand(
|
|
1533
|
+
obj_data = i.polygon_data.expand(
|
|
1534
|
+
expansion_size,
|
|
1535
|
+
round_corner,
|
|
1536
|
+
round_extension,
|
|
1537
|
+
tolerance,
|
|
1538
|
+
)
|
|
1525
1539
|
else:
|
|
1526
|
-
obj_data = i.expand(
|
|
1540
|
+
obj_data = i.expand(
|
|
1541
|
+
expansion_size,
|
|
1542
|
+
round_corner,
|
|
1543
|
+
round_extension,
|
|
1544
|
+
tolerance,
|
|
1545
|
+
)
|
|
1527
1546
|
if inlcude_voids_in_extents and "PolygonData" not in str(i) and i.has_voids and obj_data:
|
|
1528
1547
|
for void in i.voids:
|
|
1529
1548
|
void_data = void.polygon_data.expand(
|
|
1530
|
-
-1 * expansion_size,
|
|
1549
|
+
-1 * expansion_size,
|
|
1550
|
+
round_corner,
|
|
1551
|
+
round_extension,
|
|
1552
|
+
tolerance,
|
|
1531
1553
|
)
|
|
1532
1554
|
if void_data:
|
|
1533
1555
|
for v in list(void_data):
|
|
@@ -1992,11 +2014,15 @@ class Edb(EdbInit):
|
|
|
1992
2014
|
if isinstance(term, PadstackInstanceTerminal):
|
|
1993
2015
|
if term.net.name in reference_list:
|
|
1994
2016
|
pins_to_preserve.append(term.edb_uid)
|
|
2017
|
+
delete_list = []
|
|
1995
2018
|
|
|
1996
2019
|
for i in self.nets.nets.values():
|
|
1997
2020
|
name = i.name
|
|
1998
2021
|
if name not in all_list and name not in nets_to_preserve:
|
|
1999
|
-
|
|
2022
|
+
delete_list.append(i)
|
|
2023
|
+
# i.delete()
|
|
2024
|
+
for i in delete_list:
|
|
2025
|
+
i.delete()
|
|
2000
2026
|
reference_pinsts = []
|
|
2001
2027
|
reference_prims = []
|
|
2002
2028
|
reference_paths = []
|
|
@@ -2468,7 +2494,7 @@ class Edb(EdbInit):
|
|
|
2468
2494
|
>>> # Export to HFSS project:
|
|
2469
2495
|
>>> edb.export_hfss(r"C:/output", net_list=["SignalNet"])
|
|
2470
2496
|
"""
|
|
2471
|
-
siwave_s = SiwaveSolve(self
|
|
2497
|
+
siwave_s = SiwaveSolve(self)
|
|
2472
2498
|
return siwave_s.export_3d_cad("HFSS", path_to_output, net_list, num_cores, aedt_file_name, hidden=hidden)
|
|
2473
2499
|
|
|
2474
2500
|
def export_q3d(
|
|
@@ -2504,7 +2530,7 @@ class Edb(EdbInit):
|
|
|
2504
2530
|
>>> # Export to Q3D project:
|
|
2505
2531
|
>>> edb.export_q3d(r"C:/output")
|
|
2506
2532
|
"""
|
|
2507
|
-
siwave_s = SiwaveSolve(self
|
|
2533
|
+
siwave_s = SiwaveSolve(self)
|
|
2508
2534
|
return siwave_s.export_3d_cad(
|
|
2509
2535
|
"Q3D",
|
|
2510
2536
|
path_to_output,
|
|
@@ -2547,7 +2573,7 @@ class Edb(EdbInit):
|
|
|
2547
2573
|
>>> # Export to Maxwell project:
|
|
2548
2574
|
>>> edb.export_maxwell(r"C:/output")
|
|
2549
2575
|
"""
|
|
2550
|
-
siwave_s = SiwaveSolve(self
|
|
2576
|
+
siwave_s = SiwaveSolve(self)
|
|
2551
2577
|
return siwave_s.export_3d_cad(
|
|
2552
2578
|
"Maxwell",
|
|
2553
2579
|
path_to_output,
|
|
@@ -2570,7 +2596,7 @@ class Edb(EdbInit):
|
|
|
2570
2596
|
>>> # Solve with SIwave:
|
|
2571
2597
|
>>> edb.solve_siwave()
|
|
2572
2598
|
"""
|
|
2573
|
-
process = SiwaveSolve(self
|
|
2599
|
+
process = SiwaveSolve(self)
|
|
2574
2600
|
try:
|
|
2575
2601
|
self.close()
|
|
2576
2602
|
except:
|
|
@@ -2621,7 +2647,7 @@ class Edb(EdbInit):
|
|
|
2621
2647
|
list[str]
|
|
2622
2648
|
Generated report files.
|
|
2623
2649
|
"""
|
|
2624
|
-
process = SiwaveSolve(self
|
|
2650
|
+
process = SiwaveSolve(self)
|
|
2625
2651
|
try:
|
|
2626
2652
|
self.close()
|
|
2627
2653
|
except:
|
|
@@ -2687,6 +2713,30 @@ class Edb(EdbInit):
|
|
|
2687
2713
|
self.logger.info(f"Variable {variable_name} doesn't exists.")
|
|
2688
2714
|
return False
|
|
2689
2715
|
|
|
2716
|
+
def get_variable_value(self, variable_name):
|
|
2717
|
+
"""
|
|
2718
|
+
Deprecated method to get the value of a variable.
|
|
2719
|
+
|
|
2720
|
+
.. deprecated:: pyedb 0.55.0
|
|
2721
|
+
Use :func:`get_variable` instead.
|
|
2722
|
+
"""
|
|
2723
|
+
warnings.warn(
|
|
2724
|
+
"`get_variable_value` is deprecated use `get_variable` instead.",
|
|
2725
|
+
DeprecationWarning,
|
|
2726
|
+
)
|
|
2727
|
+
return self.get_variable(variable_name)
|
|
2728
|
+
|
|
2729
|
+
def get_all_variable_names(self) -> List[str]:
|
|
2730
|
+
"""Method added for compatibility with grpc.
|
|
2731
|
+
|
|
2732
|
+
Returns
|
|
2733
|
+
-------
|
|
2734
|
+
List[str]
|
|
2735
|
+
List of variable names.
|
|
2736
|
+
|
|
2737
|
+
"""
|
|
2738
|
+
return list(self.active_cell.get_all_variable_names())
|
|
2739
|
+
|
|
2690
2740
|
def add_project_variable(self, variable_name, variable_value, description=None) -> bool:
|
|
2691
2741
|
"""Add project variable.
|
|
2692
2742
|
|
pyedb/grpc/edb_init.py
CHANGED
|
@@ -31,8 +31,8 @@ import time
|
|
|
31
31
|
import ansys.edb.core.database as database
|
|
32
32
|
|
|
33
33
|
from pyedb import __version__
|
|
34
|
-
from pyedb.edb_logger import pyedb_logger
|
|
35
34
|
from pyedb.generic.general_methods import env_path, env_value, is_linux
|
|
35
|
+
from pyedb.generic.settings import settings
|
|
36
36
|
from pyedb.grpc.rpc_session import RpcSession
|
|
37
37
|
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ class EdbInit(object):
|
|
|
40
40
|
"""Edb Dot Net Class."""
|
|
41
41
|
|
|
42
42
|
def __init__(self, edbversion):
|
|
43
|
-
self.logger =
|
|
43
|
+
self.logger = settings.logger
|
|
44
44
|
self._db = None
|
|
45
45
|
self.edbversion = edbversion
|
|
46
46
|
self.logger.info("Logger is initialized in EDB.")
|
|
@@ -72,7 +72,7 @@ class EdbInit(object):
|
|
|
72
72
|
|
|
73
73
|
@staticmethod
|
|
74
74
|
def _signal_handler(signum=None, frame=None):
|
|
75
|
-
RpcSession.
|
|
75
|
+
RpcSession.kill_all_instances()
|
|
76
76
|
|
|
77
77
|
@property
|
|
78
78
|
def db(self):
|
pyedb/grpc/rpc_session.py
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
import os
|
|
24
|
-
|
|
24
|
+
import secrets
|
|
25
25
|
import sys
|
|
26
26
|
import time
|
|
27
27
|
|
|
@@ -34,8 +34,8 @@ from ansys.edb.core.utility.io_manager import (
|
|
|
34
34
|
import psutil
|
|
35
35
|
|
|
36
36
|
from pyedb import __version__
|
|
37
|
-
from pyedb.edb_logger import pyedb_logger
|
|
38
37
|
from pyedb.generic.general_methods import env_path, env_value, is_linux
|
|
38
|
+
from pyedb.generic.settings import settings
|
|
39
39
|
from pyedb.misc.misc import list_installed_ansysem
|
|
40
40
|
|
|
41
41
|
latency_delay = 0.1
|
|
@@ -80,12 +80,12 @@ class RpcSession:
|
|
|
80
80
|
if not edb_version: # pragma: no cover
|
|
81
81
|
try:
|
|
82
82
|
edb_version = "20{}.{}".format(list_installed_ansysem()[0][-3:-1], list_installed_ansysem()[0][-1:])
|
|
83
|
-
|
|
83
|
+
settings.logger.info("Edb version " + edb_version)
|
|
84
84
|
except IndexError:
|
|
85
85
|
raise Exception("No ANSYSEM_ROOTxxx is found.")
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
settings.logger.info("Logger is initialized in EDB.")
|
|
87
|
+
settings.logger.info("legacy v%s", __version__)
|
|
88
|
+
settings.logger.info("Python version %s", sys.version)
|
|
89
89
|
if is_linux:
|
|
90
90
|
if env_value(edb_version) in os.environ:
|
|
91
91
|
RpcSession.base_path = env_path(edb_version)
|
|
@@ -106,18 +106,18 @@ class RpcSession:
|
|
|
106
106
|
|
|
107
107
|
if RpcSession.pid:
|
|
108
108
|
if restart_server:
|
|
109
|
-
|
|
109
|
+
settings.logger.logger.info("Restarting RPC server")
|
|
110
110
|
RpcSession.kill()
|
|
111
111
|
RpcSession.__start_rpc_server()
|
|
112
112
|
else:
|
|
113
|
-
|
|
113
|
+
settings.logger.info(f"Server already running on port {RpcSession.port}")
|
|
114
114
|
else:
|
|
115
115
|
RpcSession.__start_rpc_server()
|
|
116
116
|
if RpcSession.rpc_session:
|
|
117
117
|
RpcSession.server_pid = RpcSession.rpc_session.local_server_proc.pid
|
|
118
|
-
|
|
118
|
+
settings.logger.info(f"Grpc session started: pid={RpcSession.server_pid}")
|
|
119
119
|
else:
|
|
120
|
-
|
|
120
|
+
settings.logger.error("Failed to start EDB_RPC_server process")
|
|
121
121
|
|
|
122
122
|
@staticmethod
|
|
123
123
|
def __get_process_id():
|
|
@@ -135,7 +135,7 @@ class RpcSession:
|
|
|
135
135
|
time.sleep(latency_delay)
|
|
136
136
|
if RpcSession.rpc_session:
|
|
137
137
|
RpcSession.pid = RpcSession.rpc_session.local_server_proc.pid
|
|
138
|
-
|
|
138
|
+
settings.logger.logger.info("Grpc session started")
|
|
139
139
|
|
|
140
140
|
@staticmethod
|
|
141
141
|
def kill():
|
|
@@ -170,11 +170,12 @@ class RpcSession:
|
|
|
170
170
|
@staticmethod
|
|
171
171
|
def __get_random_free_port():
|
|
172
172
|
""""""
|
|
173
|
-
|
|
173
|
+
secure_random = secrets.SystemRandom()
|
|
174
|
+
port = secure_random.randint(49152, 65535)
|
|
174
175
|
while True:
|
|
175
176
|
used_ports = [conn.laddr[1] for conn in psutil.net_connections()]
|
|
176
177
|
if port in used_ports:
|
|
177
|
-
port = randint(49152, 65535)
|
|
178
|
+
port = secure_random.randint(49152, 65535)
|
|
178
179
|
else:
|
|
179
180
|
break
|
|
180
181
|
return port
|