-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexecute_script.py
39 lines (32 loc) · 1.41 KB
/
execute_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import subprocess
import os
import asyncio
async def get_result_value():
try:
# Run player_client.py
current_dir = os.getcwd()
target_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'nillion-python-starter/quickstart/client_code'))
# Determine the command to run based on the current directory
if current_dir != target_dir:
command = f"cd {target_dir} && python3 player_client.py"
else:
command = "python3 player_client.py"
# Run the command
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
# Extract the value of compute_event.result.value from the output
for line in result.stdout.split('\n'):
if "🖥️ THE UNIFIED SYSTEM IDENTIFIER FOR HARDWARE BAN" in line:
value = line.split()[-1]
if value.endswith('}'):
value = value[:-1]
return value
# If value doesn't get returned, use this defaultr instead
result_value= "Jinesh123"
return result_value
except subprocess.CalledProcessError as e:
print(f"Command failed with exit status {e.returncode}")
print(f"Error output: {e.stderr}")
return "Jinesh123"
if __name__ == "__main__":
result_value = asyncio.run(get_result_value())
print(f"Result Value: {result_value}")