added python reference implementation

This commit is contained in:
2025-01-02 01:27:07 +00:00
parent 9d9c484d07
commit 9692fce5b2
6 changed files with 184 additions and 0 deletions

43
python/test.py Normal file
View File

@@ -0,0 +1,43 @@
from library import *
if __name__ == "__main__":
P2PRCNodes = ListNodes()
# Create sample process
sample_process = Process(
ID="",
TaskName="TestServer",
InternalPortNo="8084",
NodeInfo=IPAddress(P2PRCNodes.ip_address[2]),
CommandToRunScript="sh SamplePythonTestServer/server.sh &",
CommandToKillScript="sh SamplePythonTestServer/killserver.sh",
DomainName="",
Status=False,
ExternalAddress=""
)
print("------------ Starting process -------------")
# Spin process
sample_process = SpinProcess(sample_process)
print("------------ Process Public address -------------")
# Prints status of the current process
print(sample_process.ExternalAddress)
print("------------ Process kept waiting for 20 seconds -------------")
# Runs the process for 20 seconds
time.sleep(20)
print("------------ Process getting killed -------------")
# Kills the process
KillProcess(sample_process)
print("------------ Process current process -------------")
# Prints process status
print(sample_process.Status)