"""
Launches an interactive shell with an instance of HFSS

omitting the .py in the name of this file hides it from the Electronics Desktop Toolkit menu.
It should be hidden from this menu because the scripts in that menu are meant to be executed using IronPython
cpython_console.py should be run instead of this script.

This file can also serve as a template to modify PyAEDT scripts to take advantage of the command line arguments
provided by the launcher
"""
import sys
import atexit
from pyaedt import *
import pyaedt
pyaedt.settings.use_grpc_api=False

aedt_process_id = sys.argv[1]
version = sys.argv[2]
print("Loading the PyAEDT Console.")

def release(d):
    d.logger.info("Exiting the PyAEDT Console.")

    d.release_desktop(False,False)


desktop = Desktop(
		specified_version= version,
		aedt_process_id = aedt_process_id,
		new_desktop_session=False,
		non_graphical=False,
		close_on_exit=False,
	)
print(" ")

print("\033[92m****************************************************************")
print("*  ElectronicsDesktop {} Process ID {}".format(version, aedt_process_id))
print("*  CPython {}".format(sys.version.split(" ")[0]))
print("*---------------------------------------------------------------")
print("*  Example: \033[94m hfss = Hfss() \033[92m")
print("*  Example: \033[94m m2d = Maxwell2d() \033[92m")
print("*  \033[31mType exit() to close the console and release the desktop.  \033[92m ")
print("*  desktop object is initialized and available. Example: ")
print("*  \033[94mdesktop.logger.info('Hello world')\033[92m")
print("****************************************************************\033[0m")
print(" ")
print(" ")
print(" ")
atexit.register(release, desktop)

