Skip to content

Commit

Permalink
Create node_software.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 14, 2024
1 parent 89f8938 commit 9dc1194
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions projects/PiNetAI/node/node_software.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import subprocess

class NodeSoftware:
def __init__(self, software_id, version, dependencies):
self.software_id = software_id
self.version = version
self.dependencies = dependencies

def start(self):
self.install_dependencies()
self.run_software()

def stop(self):
self.stop_software()

def install_dependencies(self):
for dependency in self.dependencies:
subprocess.run(['pip', 'install', dependency])

def run_software(self):
os.system(f'python -m {self.software_id}=={self.version}')

def stop_software(self):
os.system(f'pkill -f {self.software_id}')

0 comments on commit 9dc1194

Please sign in to comment.