1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-30 00:00:11 +01:00
VILLASnode/python/villas/node/node.py

26 lines
604 B
Python

import json
import tempfile
import subprocess
import logging
LOGGER = logging.getLogger('villas.node')
class Node(object):
def __init__(self, cfg):
self.config = cfg
def start(self):
self.config_file = tempfile.NamedTemporaryFile(mode='w+', suffix='.json')
json.dump(self.config, self.config_file)
self.config_file.flush()
LOGGER.info("Starting VILLASnode with config: %s", self.config_file.name)
self.child = subprocess.Popen(['villas-node', self.config_file.name])
def stop(self):
self.child.kill()
self.child.wait()