Skip to content

Commit

Permalink
Use subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
domschl committed Aug 17, 2023
1 parent 7de2136 commit f93c264
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions selftest/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import time
import queue
import subprocess

from urllib.parse import quote
from urllib.parse import urlencode
Expand Down Expand Up @@ -163,7 +164,8 @@ def create_device(fhi, name, readings):
"fhem_file": "./fhem/fhem-6.0/fhem.pl",
"config_file": "./fhem/fhem-6.0/fhem.cfg",
"fhem_dir": "./fhem/fhem-6.0/",
"exec": "cd fhem/fhem-6.0/ && perl fhem.pl fhem.cfg &",
"exec": "cd fhem/fhem-6.0/ && perl fhem.pl fhem.cfg",
"cmds": ["perl", "fhem.pl", "fhem.cfg"],
"testhost": "localhost",
}

Expand Down Expand Up @@ -199,6 +201,7 @@ def create_device(fhi, name, readings):

os.system("cat fhem-config-addon.cfg >> {}".format(config["config_file"]))


certs_dir = os.path.join(config["fhem_dir"], "certs")
os.system("mkdir {}".format(certs_dir))
os.system(
Expand All @@ -213,8 +216,9 @@ def create_device(fhi, name, readings):
log.error("Failed to create certificate files!")
sys.exit(-2)

ret = os.system(config["exec"])
log.info("Fhem startup at {} returned: {}".format(config['exec'], ret))
# os.system(config["exec"])
subprocess.Popen(config["cmds"], cwd=config['fhem_dir'], close_fds=True)
log.info("Fhem startup at {}".format(config['exec']))
time.sleep(1)

if st.is_running(fhem_url=config["testhost"], protocol="http", port=8083) is None:
Expand Down

0 comments on commit f93c264

Please sign in to comment.