Source code for fortrace.utility.applications.console.terminal_factory

#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <https://www.gnu.org/licenses/>.
from fortrace.core.qemu_monitor import QEMUMonitorSession
from fortrace.utility.applications.application import ParentNotifier
from fortrace.utility.applications.console.linux_terminal import GenericLinuxTerminal
from fortrace.utility.applications.console.powershell import PowerShell
from fortrace.utility.distribution_constants import ShellType


[docs] def get_terminal( name: str, qs: QEMUMonitorSession, parent_notifier: ParentNotifier, **kwargs ): match name: case "PowerShell" | "Windows PowerShell": return PowerShell( qs, parent_notifier, kwargs.get("run_as_administrator", False) ) case "Windows Terminal": raise NotImplementedError case "cmd" | "CMD" | "Cmd": raise NotImplementedError case "Terminal" | "GNOME Terminal": return GenericLinuxTerminal( name, qs, parent_notifier, kwargs.get("shell_type", ShellType.BASH), kwargs.get("sudo_timeout", 300), ) case _: raise ValueError(f"'{name}' is not known to be any supported shell")