X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/71a35239852c629c02006219427db45b75bc24da..91cc87ccd8910e4bbeecf2981d6c07b8578b28c0:/pymin/services/ppp/__init__.py?ds=sidebyside diff --git a/pymin/services/ppp/__init__.py b/pymin/services/ppp/__init__.py index c251e50..db2a535 100644 --- a/pymin/services/ppp/__init__.py +++ b/pymin/services/ppp/__init__.py @@ -1,6 +1,7 @@ # vim: set encoding=utf-8 et sw=4 sts=4 : import os +import subprocess from os import path from signal import SIGTERM @@ -120,7 +121,6 @@ class PppHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler): for name in names: if name in self.conns: if self.conns[name]._running: - call(('poff', name)) if path.exists('/var/run/ppp-' + name + '.pid'): pid = file('/var/run/ppp-' + name + '.pid').readline() try: @@ -162,6 +162,16 @@ class PppHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler): 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 @@ -186,6 +196,7 @@ class PppHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler): if __name__ == '__main__': + p = PppHandler() p.conn.add('ppp_c','nico','nico',type='PPP',device='tty0') p.conn.add('pppoe_c','fede','fede',type='OE',device='tty1')