]> git.llucax.com Git - software/pymin.git/commitdiff
Merge jack2@192.168.7.8:src/pymin
authorLeandro Lucarella <llucax@gmail.com>
Sat, 27 Oct 2007 20:52:07 +0000 (17:52 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Sat, 27 Oct 2007 20:52:07 +0000 (17:52 -0300)
1  2 
pymin/services/ip/__init__.py
pymin/services/ppp/__init__.py

index 7b5eafe698583518dc3c457948417ce7cffe549b,560e2f58747af7b498231ca132c5cc72aff726f6..a6a0e676debb17b3aecb149e236181c2792daf72
@@@ -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')
index 2115d65de3ec08a0b08b95d6917a0ed4dd246b07,caf8f4ed1cd308f3b23525c81a75105dec6ef790..a58e212da387d6b0b1687963b6752b947a5b02ba
@@@ -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
  
  
  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')