From: Leandro Lucarella Date: Sat, 27 Oct 2007 20:52:07 +0000 (-0300) Subject: Merge jack2@192.168.7.8:src/pymin X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/28ba753ea84e470b67de6601b15ebeb39ba0b97f?ds=inline;hp=-c Merge jack2@192.168.7.8:src/pymin --- 28ba753ea84e470b67de6601b15ebeb39ba0b97f diff --combined pymin/services/ip/__init__.py index 7b5eafe,560e2f5..a6a0e67 --- a/pymin/services/ip/__init__.py +++ b/pymin/services/ip/__init__.py @@@ -110,6 -110,9 +110,6 @@@ class Address(Sequence) self.ip = ip self.netmask = netmask self.broadcast = broadcast - def update(self, netmask=None, broadcast=None): - if netmask is not None: self.netmask = netmask - if broadcast is not None: self.broadcast = broadcast def as_tuple(self): return (self.ip, self.netmask, self.broadcast) @@@ -223,9 -226,26 +223,26 @@@ class IpHandler(Restorable, ConfigWrite ), shell=True) + def handle_timer(self): + self.refresh_devices() + + + def refresh_devices(self): + devices = get_network_devices() + #add not registered devices + for k,v in devices.items(): + if k not in self.devices: + self.devices[k] = Device(k,v) + #delete dead devices + for k in self.devices.keys(): + if k not in devices: + del self.devices[k] + + + if __name__ == '__main__': - ip = IpHandler() + ip = IpHanlder() print '----------------------' ip.hop.add('201.21.32.53','eth0') ip.hop.add('205.65.65.25','eth1') diff --combined pymin/services/ppp/__init__.py index 2115d65,caf8f4e..a58e212 --- a/pymin/services/ppp/__init__.py +++ b/pymin/services/ppp/__init__.py @@@ -1,7 -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 @@@ -163,16 -162,6 +163,16 @@@ class PppHandler(Restorable, ConfigWrit 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 @@@ -197,6 -186,7 +197,7 @@@ 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')