Login | ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/alarming/trunk/Server/daemon.py
(Generate patch)

Comparing trunk/Server/daemon.py (file contents):
Revision 5 by daniel-marschall, Wed May 8 23:02:47 2019 UTC vs.
Revision 6 by daniel-marschall, Mon Jun 10 17:40:51 2019 UTC

# Line 10 | Line 10 | import requests
10   import subprocess
11   import config
12   import threading
13 + import subprocess as sp
14  
15   g_subscribed = []
16 + g_bellListenerProc = None
17  
18   class S(BaseHTTPRequestHandler):
19      def _output(self, code, content):
# Line 126 | Line 128 | function onload() {
128          # ---
129  
130          global g_subscribed
131 +        global g_bellListenerProc
132  
133          if pvget(postvars, "action")[0] == "client_subscribe": # 1.3.6.1.4.1.37476.2.4.1.1
134                  client_ip      = self.client_address[0]
# Line 184 | Line 187 | function onload() {
187  
188          if pvget(postvars, "action")[0] == "motion_on": # 1.3.6.1.4.1.37476.2.4.1.100
189                  print "Motion start"
190 <                os.system(os.path.dirname(os.path.abspath(__file__)) + "/motion/motion_start_safe")
191 <
190 >                if config.enable_motion_detect:
191 >                        os.system(os.path.dirname(os.path.abspath(__file__)) + "/motion/motion_start_safe")
192 >                if config.enable_doorbell_listener:
193 >                        g_bellListenerProc = sp.Popen(['python3',os.path.dirname(os.path.abspath(__file__)) + "/doorbell/bell_listener.py"])
194          if pvget(postvars, "action")[0] == "motion_off": # 1.3.6.1.4.1.37476.2.4.1.101
195                  print "Motion stop"
196 <                os.system(os.path.dirname(os.path.abspath(__file__)) + "/motion/motion_stop_safe")
196 >                if config.enable_motion_detect:
197 >                        os.system(os.path.dirname(os.path.abspath(__file__)) + "/motion/motion_stop_safe")
198 >                if config.enable_doorbell_listener:
199 >                        sp.Popen.terminate(g_bellListenerProc)
200  
201          self._output(200, '')
202  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines