forked from Telraam/Telraam-RPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
telraam_deactivate_monitoring.py
51 lines (36 loc) · 1.68 KB
/
telraam_deactivate_monitoring.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
40
41
42
43
44
45
46
47
48
49
50
51
import socket
import subprocess
import signal
import os
import time
# sleep timeintervals
SERVICE_WAIT_TIME = 3
def is_camera_stream_service_running():
p = subprocess.Popen(["sudo", "systemctl", "status", "telraam_camera_stream"], stdout=subprocess.PIPE)
out, err = p.communicate()
return 'Active: active (running)' in str(out)
def activate_camera_stream_service():
p = subprocess.call(["sudo", "systemctl", "enable", "telraam_camera_stream"])
p = subprocess.call(["sudo", "systemctl", "start", "telraam_camera_stream"])
time.sleep(SERVICE_WAIT_TIME)
print("Camera stream service activated.");
def deactivate_camera_stream_service():
p = subprocess.call(["sudo", "systemctl", "stop", "telraam_camera_stream"])
p = subprocess.call(["sudo", "systemctl", "disable", "telraam_camera_stream"])
time.sleep(SERVICE_WAIT_TIME)
print("Camera stream service deactivated.");
def is_monitoring_service_running():
p = subprocess.Popen(["sudo", "systemctl", "status", "telraam_monitoring"], stdout=subprocess.PIPE)
out, err = p.communicate()
return 'Active: active (running)' in str(out)
def activate_monitoring_service():
p = subprocess.call(["sudo", "systemctl", "enable", "telraam_monitoring"])
p = subprocess.call(["sudo", "systemctl", "start", "telraam_monitoring"])
time.sleep(SERVICE_WAIT_TIME)
print("Monitoring service activated.");
def deactivate_monitoring_service():
p = subprocess.call(["sudo", "systemctl", "stop", "telraam_monitoring"])
p = subprocess.call(["sudo", "systemctl", "disable", "telraam_monitoring"])
time.sleep(SERVICE_WAIT_TIME)
print("Monitoring service deactivated.");
deactivate_monitoring_service()