/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: Teddy Hogeborn
  • Date: 2014-07-25 23:39:49 UTC
  • mto: This revision was merged to the branch mainline in revision 724.
  • Revision ID: teddy@recompile.se-20140725233949-rcg0bbj7q3uweh6p
Use the new .total_seconds() method on datetime.timedelta objects.

* mandos (timedelta_to_milliseconds): Removed.  All callers changed to
                                      use ".total_seconds() * 1000".
  (Client.timeout_milliseconds): - '' -
  (Client.extended_timeout_milliseconds): - '' -
  (Client.interval_milliseconds): - '' -
  (Client.approval_delay_milliseconds): - '' -
* mandos-ctl (timedelta_to_milliseconds): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
import locale
50
50
 
51
 
if sys.version_info.major == 2:
 
51
if sys.version_info[0] == 2:
52
52
    str = unicode
53
53
 
54
54
locale.setlocale(locale.LC_ALL, '')
60
60
domain = 'se.recompile'
61
61
server_interface = domain + '.Mandos'
62
62
client_interface = domain + '.Mandos.Client'
63
 
version = "1.6.9"
 
63
version = "1.6.7"
64
64
 
65
65
def isoformat_to_datetime(iso):
66
66
    "Parse an ISO 8601 date string to a datetime.datetime()"
87
87
        self.proxy = proxy_object # Mandos Client proxy object
88
88
        self.properties = dict() if properties is None else properties
89
89
        self.property_changed_match = (
90
 
            self.proxy.connect_to_signal("PropertiesChanged",
91
 
                                         self.properties_changed,
92
 
                                         dbus.PROPERTIES_IFACE,
 
90
            self.proxy.connect_to_signal("PropertyChanged",
 
91
                                         self._property_changed,
 
92
                                         client_interface,
93
93
                                         byte_arrays=True))
94
94
        
95
95
        if properties is None:
100
100
        
101
101
        super(MandosClientPropertyCache, self).__init__(**kwargs)
102
102
    
103
 
    def properties_changed(self, interface, properties, invalidated):
104
 
        """This is called whenever we get a PropertiesChanged signal
105
 
        It updates the changed properties in the "properties" dict.
 
103
    def _property_changed(self, property, value):
 
104
        """Helper which takes positional arguments"""
 
105
        return self.property_changed(property=property, value=value)
 
106
    
 
107
    def property_changed(self, property=None, value=None):
 
108
        """This is called whenever we get a PropertyChanged signal
 
109
        It updates the changed property in the "properties" dict.
106
110
        """
107
111
        # Update properties dict with new value
108
 
        self.properties.update(properties)
 
112
        self.properties[property] = value
109
113
    
110
114
    def delete(self):
111
115
        self.property_changed_match.remove()
373
377
        else:
374
378
            return key
375
379
    
376
 
    def properties_changed(self, interface, properties, invalidated):
377
 
        """Call self.update() if any properties changed.
 
380
    def property_changed(self, property=None, **kwargs):
 
381
        """Call self.update() if old value is not new value.
378
382
        This overrides the method from MandosClientPropertyCache"""
379
 
        old_values = { key: self.properties.get(key)
380
 
                       for key in properties.keys() }
381
 
        super(MandosClientWidget, self).properties_changed(
382
 
            interface, properties, invalidated)
383
 
        if any(old_values[key] != self.properties.get(key)
384
 
               for key in old_values):
 
383
        property_name = str(property)
 
384
        old_value = self.properties.get(property_name)
 
385
        super(MandosClientWidget, self).property_changed(
 
386
            property=property, **kwargs)
 
387
        if self.properties.get(property_name) != old_value:
385
388
            self.update()
386
389
 
387
390