chiark / gitweb /
(Python): Use more modern `raise' syntax.
[tripe] / svc / conntrack.in
index 6ada45d73950e68f6ca1d1c4419c08c6718de579..3368295a46ec8d743dee349a503243dcca6b55ac 100644 (file)
 ###
 ### This file is part of Trivial IP Encryption (TrIPE).
 ###
-### TrIPE is free software; you can redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation; either version 2 of the License, or
-### (at your option) any later version.
+### TrIPE is free software: you can redistribute it and/or modify it under
+### the terms of the GNU General Public License as published by the Free
+### Software Foundation; either version 3 of the License, or (at your
+### option) any later version.
 ###
-### TrIPE is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
+### TrIPE is distributed in the hope that it will be useful, but WITHOUT
+### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+### FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+### for more details.
 ###
 ### You should have received a copy of the GNU General Public License
-### along with TrIPE; if not, write to the Free Software Foundation,
-### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+### along with TrIPE.  If not, see <https://www.gnu.org/licenses/>.
 
 VERSION = '@VERSION@'
 
@@ -212,7 +211,7 @@ def cmd_showgroup(g):
       pats = p
       break
   else:
-    raise T.TripeJobError, 'unknown-group', g
+    raise T.TripeJobError('unknown-group', g)
   for t, p, a, m in pats:
     T.svcinfo('peer', t,
               'target', p or '(default)',
@@ -322,7 +321,7 @@ def kickpeers():
       if want is not None and not found:
         def _(want = want):
           try:
-            SM.svcsubmit('connect', 'active', want)
+            list(SM.svcsubmit('connect', 'active', want))
           except T.TripeError, exc:
             SM.warn('conntrack', 'connect-failed', want, *exc.args)
         if T._debug: print '#   peer %s: bring up' % want
@@ -345,6 +344,8 @@ def netupdown(upness, reason):
 ###--------------------------------------------------------------------------
 ### NetworkManager monitor.
 
+DBPROPS_IFACE = 'org.freedesktop.DBus.Properties'
+
 NM_NAME = 'org.freedesktop.NetworkManager'
 NM_PATH = '/org/freedesktop/NetworkManager'
 NM_IFACE = NM_NAME
@@ -376,13 +377,13 @@ class NetworkManagerMonitor (object):
   def attach(me, bus):
     try:
       nm = bus.get_object(NM_NAME, NM_PATH)
-      state = nm.Get(NM_IFACE, 'State')
+      state = nm.Get(NM_IFACE, 'State', dbus_interface = DBPROPS_IFACE)
       if state in NM_CONNSTATES:
         netupdown(True, ['nm', 'initially-connected'])
       else:
         netupdown(False, ['nm', 'initially-disconnected'])
-    except D.DBusException:
-      pass
+    except D.DBusException, e:
+      if T._debug: print '# exception attaching to network-manager: %s' % e
     bus.add_signal_receiver(me._nm_state, 'StateChanged',
                             NM_IFACE, NM_NAME, NM_PATH)
     bus.add_signal_receiver(me._nm_connchange, 'PropertiesChanged',
@@ -421,8 +422,8 @@ class ConnManMonitor (object):
       props = cm.GetProperties(dbus_interface = CM_IFACE)
       state = props['State']
       netupdown(state == 'online', ['connman', 'initially-%s' % state])
-    except D.DBusException:
-      pass
+    except D.DBusException, e:
+      if T._debug: print '# exception attaching to connman: %s' % e
     bus.add_signal_receiver(me._cm_state, 'PropertyChanged',
                             CM_IFACE, CM_NAME, CM_PATH)
 
@@ -460,7 +461,8 @@ class MaemoICdMonitor (object):
       except D.DBusException:
         me._iap = None
         netupdown(False, ['icd', 'initially-disconnected'])
-    except D.DBusException:
+    except D.DBusException, e:
+      if T._debug: print '# exception attaching to icd: %s' % e
       me._iap = None
     bus.add_signal_receiver(me._icd_state, 'status_changed', ICD_IFACE,
                             ICD_NAME, ICD_PATH)