grpc: added args to execute script to reflect prior gui functionality, updated new and old gui to use the same exact logic for executing scripts for consistency
This commit is contained in:
parent
f98594e927
commit
9da64af79b
7 changed files with 30 additions and 22 deletions
|
@ -15,6 +15,7 @@ import random
|
|||
import shlex
|
||||
import shutil
|
||||
import sys
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from subprocess import PIPE, STDOUT, Popen
|
||||
from typing import (
|
||||
|
@ -39,6 +40,7 @@ from core.errors import CoreCommandError, CoreError
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.session import Session
|
||||
from core.nodes.base import CoreNode
|
||||
T = TypeVar("T")
|
||||
|
@ -47,6 +49,24 @@ DEVNULL = open(os.devnull, "wb")
|
|||
IFACE_CONFIG_FACTOR: int = 1000
|
||||
|
||||
|
||||
def execute_script(coreemu: "CoreEmu", file_path: Path, args: str) -> None:
|
||||
"""
|
||||
Provides utility function to execute a python script in context of the
|
||||
provide coreemu instance.
|
||||
|
||||
:param coreemu: coreemu to provide to script
|
||||
:param file_path: python script to execute
|
||||
:param args: args to provide script
|
||||
:return: nothing
|
||||
"""
|
||||
sys.argv = shlex.split(args)
|
||||
thread = threading.Thread(
|
||||
target=execute_file, args=(file_path, {"coreemu": coreemu}), daemon=True
|
||||
)
|
||||
thread.start()
|
||||
thread.join()
|
||||
|
||||
|
||||
def execute_file(
|
||||
path: Path, exec_globals: Dict[str, str] = None, exec_locals: Dict[str, str] = None
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue