]> git.llucax.com Git - software/pymin.git/commitdiff
Add a timer handler to ppp to monitor ppp connections state.
authorLeandro Lucarella <llucax@gmail.com>
Sat, 27 Oct 2007 20:50:29 +0000 (17:50 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Sat, 27 Oct 2007 20:50:29 +0000 (17:50 -0300)
pymin/services/ppp/__init__.py

index c251e5025a25f00c12f4106d7d970f52296bfa10..2115d65de3ec08a0b08b95d6917a0ed4dd246b07 100644 (file)
@@ -1,6 +1,7 @@
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
 import os
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
 import os
+import subprocess
 from os import path
 from signal import SIGTERM
 
 from os import path
 from signal import SIGTERM
 
@@ -162,6 +163,16 @@ class PppHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler):
         else:
             raise ConnectionNotFoundError(name)
 
         else:
             raise ConnectionNotFoundError(name)
 
+    def handle_timer(self):
+        for c in self.conns.values():
+            p = subprocess.Popen(('pgrep', '-f', 'pppd call ' + c.name),
+                                    stdout=subprocess.PIPE)
+            pid = p.communicate()[0]
+            if p.wait() == 0 and len(pid) > 0:
+                c._running = True
+            else:
+                c._running = False
+
     def _write_config(self):
         r"_write_config() -> None :: Generate all the configuration files."
         #guardo los pass que van el pap-secrets
     def _write_config(self):
         r"_write_config() -> None :: Generate all the configuration files."
         #guardo los pass que van el pap-secrets