@@ -342,6 +342,9 @@ def __init__(
342
342
self ._main .isoutsideDesktop = True
343
343
self .release_on_exit = True
344
344
self .logfile = None
345
+ self ._logger = aedt_logger .AedtLogger (filename = self .logfile , level = logging .DEBUG )
346
+ self ._logger .info ("Logger Started" )
347
+ self ._main .aedt_logger = self ._logger
345
348
if "oDesktop" in dir (): # pragma: no cover
346
349
self .release_on_exit = False
347
350
self ._main .oDesktop = oDesktop
@@ -361,11 +364,11 @@ def __init__(
361
364
del self ._main .oDesktop
362
365
self ._main .student_version , version_key , version = self ._set_version (specified_version , student_version )
363
366
if _com == "ironpython" : # pragma: no cover
364
- print ("Launching PyAEDT outside AEDT with IronPython." )
367
+ self . _logger . info ("Launching PyAEDT outside AEDT with IronPython." )
365
368
self ._init_ironpython (non_graphical , new_desktop_session , version )
366
369
elif _com == "pythonnet_v3" :
367
370
if version_key < "2022.2" or not settings .use_grpc_api :
368
- print ("Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet" )
371
+ self . _logger . info ("Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet" )
369
372
self ._init_cpython (
370
373
non_graphical ,
371
374
new_desktop_session ,
@@ -376,9 +379,6 @@ def __init__(
376
379
)
377
380
else :
378
381
self ._init_cpython_new (non_graphical , new_desktop_session , version , self ._main .student_version )
379
- # print("Launching PyAEDT outside AEDT with CPython and Pythonnet.")
380
- # self._init_cpython(non_graphical, new_desktop_session, version,
381
- # self._main.student_version, version_key)
382
382
else :
383
383
oAnsoftApp = win32com .client .Dispatch (version )
384
384
self ._main .oDesktop = oAnsoftApp .GetAppDesktop ()
@@ -465,11 +465,11 @@ def current_version_student(self):
465
465
def _init_desktop (self ):
466
466
self ._main .AEDTVersion = self ._main .oDesktop .GetVersion ()[0 :6 ]
467
467
self ._main .oDesktop .RestoreWindow ()
468
- self ._logger = aedt_logger .AedtLogger (filename = self .logfile , level = logging .DEBUG )
469
- self ._logger .info ("Logger Started on %s" , self .logfile )
470
- self ._main .aedt_logger = self ._logger
471
468
self ._main .sDesktopinstallDirectory = self ._main .oDesktop .GetExeDir ()
472
469
self ._main .pyaedt_initialized = True
470
+ self ._logger = aedt_logger .AedtLogger (filename = self .logfile , level = logging .DEBUG )
471
+ self ._logger .info ("Logger file %s in use." )
472
+ self ._main .aedt_logger = self ._logger
473
473
474
474
def _set_version (self , specified_version , student_version ):
475
475
student_version_flag = False
@@ -569,14 +569,13 @@ def _init_cpython(
569
569
sys .path .append (base_path )
570
570
sys .path .append (os .path .join (base_path , "PythonFiles" , "DesktopPlugin" ))
571
571
launch_msg = "AEDT installation Path {}." .format (base_path )
572
- print (launch_msg )
573
- print ("===================================================================================" )
572
+ self .logger .info (launch_msg )
574
573
clr .AddReference ("Ansys.Ansoft.CoreCOMScripting" )
575
574
AnsoftCOMUtil = __import__ ("Ansys.Ansoft.CoreCOMScripting" )
576
575
self .COMUtil = AnsoftCOMUtil .Ansoft .CoreCOMScripting .Util .COMUtil
577
576
self ._main .COMUtil = self .COMUtil
578
577
StandalonePyScriptWrapper = AnsoftCOMUtil .Ansoft .CoreCOMScripting .COM .StandalonePyScriptWrapper
579
- print ( "pyaedt info: Launching AEDT with module Pythonnet." )
578
+ self . logger . info ( " Launching AEDT with module Pythonnet." )
580
579
processID = []
581
580
if IsWindows :
582
581
processID = self ._get_tasks_list_windows (student_version )
@@ -603,9 +602,9 @@ def _init_cpython(
603
602
self ._dispatch_win32 (version )
604
603
elif version_key >= "2021.2" :
605
604
if student_version :
606
- print ( "pyaedt info: {} Student version started with process ID {}." .format (version , proc [0 ]))
605
+ self . logger . info ( " {} Student version started with process ID {}." .format (version , proc [0 ]))
607
606
else :
608
- print ( "pyaedt info: {} Started with process ID {}." .format (version , proc [0 ]))
607
+ self . logger . info ( " {} Started with process ID {}." .format (version , proc [0 ]))
609
608
context = pythoncom .CreateBindCtx (0 )
610
609
running_coms = pythoncom .GetRunningObjectTable ()
611
610
monikiers = running_coms .EnumRunning ()
@@ -617,7 +616,7 @@ def _init_cpython(
617
616
self ._main .oDesktop = win32com .client .Dispatch (obj .QueryInterface (pythoncom .IID_IDispatch ))
618
617
break
619
618
else :
620
- warnings . warn (
619
+ self . logger . warning (
621
620
"PyAEDT is not supported in AEDT versions older than 2021.2. Trying to launch PyAEDT with PyWin32."
622
621
)
623
622
self ._dispatch_win32 (version )
@@ -629,9 +628,8 @@ def _init_cpython_new(self, non_graphical, new_aedt_session, version, student_ve
629
628
import ScriptEnv
630
629
631
630
launch_msg = "AEDT installation Path {}" .format (base_path )
632
- print (launch_msg )
633
- print ("===================================================================================" )
634
- print ("pyaedt info: Launching AEDT with PyDesktopPlugin." )
631
+ self .logger .info (launch_msg )
632
+ self .logger .info ("Launching AEDT with PyDesktopPlugin." )
635
633
if new_aedt_session or not self .port :
636
634
self .port = _find_free_port ()
637
635
self .machine = ""
@@ -662,12 +660,12 @@ def _init_cpython_new(self, non_graphical, new_aedt_session, version, student_ve
662
660
if non_graphical :
663
661
settings .enable_desktop_logs = False
664
662
if student_version :
665
- print ( "pyaedt info: {} Student version started with process ID {}." .format (version , _proc ))
663
+ self . logger . info ( " {} Student version started with process ID {}." .format (version , _proc ))
666
664
else :
667
- print ( "pyaedt info: {} Started with process ID {}." .format (version , _proc ))
665
+ self . logger . info ( " {} Started with process ID {}." .format (version , _proc ))
668
666
669
667
else :
670
- warnings . warn ("PyDesktopPlugin is not supported in AEDT versions older than 2022.2." )
668
+ self . logger . warning ("PyDesktopPlugin is not supported in AEDT versions older than 2022.2." )
671
669
672
670
def _set_logger_file (self ):
673
671
# Set up the log file in the AEDT project directory
0 commit comments