You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Executes a shell command in a specified working directory and returns its output, error, and exit code.
12
10
13
11
Parameters:
14
12
command (str): The shell command to execute.
13
+
max_run_time (int): Maximum allowed runtime in seconds before timeout.
15
14
cwd (str, optional): The working directory in which to execute the command. Defaults to None.
16
15
17
16
Returns:
18
-
tuple: A tuple containing the standard output ('stdout'), standard error ('stderr'), exit code ('exit_code'), and the time of the executed command ('command_start_time').
17
+
tuple: A tuple containing the standard output ('stdout'), standard error ('stderr'), exit code ('exit_code'),
18
+
and the time of the executed command ('command_start_time').
19
19
"""
20
-
# Get the current time before running the test command, in milliseconds
21
-
command_start_time=int(round(time.time() *1000))
20
+
command_start_time=int(
21
+
time.time() *1000
22
+
) # Get the current time in milliseconds
22
23
23
-
max_allowed_runtime_seconds=get_settings().get(
24
-
"tests.max_allowed_runtime_seconds", 3600
25
-
)
26
-
# Ensure the command is executed with shell=True for string commands
27
24
try:
28
25
result=subprocess.run(
29
26
command,
30
27
shell=True,
31
28
cwd=cwd,
32
29
text=True,
33
30
capture_output=True,
34
-
timeout=max_allowed_runtime_seconds,
31
+
timeout=max_run_time,
35
32
)
36
-
37
-
# Return a dictionary with the desired information
0 commit comments