/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: Björn Påhlsson
  • Date: 2010-09-02 18:53:38 UTC
  • mto: (237.4.3 mandos-release)
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: belorn@fukt.bsnet.se-20100902185338-d1022sv517txn3sb
early commit to ease todays coding

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
locale.setlocale(locale.LC_ALL, u'')
25
25
 
 
26
import logging
 
27
logging.getLogger('dbus.proxies').setLevel(logging.CRITICAL)
 
28
 
26
29
# Some useful constants
27
30
domain = 'se.bsnet.fukt'
28
31
server_interface = domain + '.Mandos'
29
32
client_interface = domain + '.Mandos.Client'
30
 
version = "1.0.14"
 
33
version = "1.0.15"
31
34
 
32
35
# Always run in monochrome mode
33
36
urwid.curses_display.curses.has_colors = lambda : False
50
53
                                     self.property_changed,
51
54
                                     client_interface,
52
55
                                     byte_arrays=True)
53
 
 
 
56
        
54
57
        self.properties.update(
55
58
            self.proxy.GetAll(client_interface,
56
59
                              dbus_interface = dbus.PROPERTIES_IFACE))
57
60
        super(MandosClientPropertyCache, self).__init__(
58
 
            proxy_object=proxy_object, *args, **kwargs)
 
61
            *args, **kwargs)
59
62
    
60
63
    def property_changed(self, property=None, value=None):
61
64
        """This is called whenever we get a PropertyChanged signal
101
104
                                     self.got_secret,
102
105
                                     client_interface,
103
106
                                     byte_arrays=True)
 
107
        self.proxy.connect_to_signal(u"NeedApproval",
 
108
                                     self.need_approval,
 
109
                                     client_interface,
 
110
                                     byte_arrays=True)
104
111
        self.proxy.connect_to_signal(u"Rejected",
105
112
                                     self.rejected,
106
113
                                     client_interface,
108
115
    
109
116
    def checker_completed(self, exitstatus, condition, command):
110
117
        if exitstatus == 0:
111
 
            self.logger(u'Checker for client %s (command "%s")'
112
 
                        u' was successful'
113
 
                        % (self.properties[u"name"], command))
 
118
            #self.logger(u'Checker for client %s (command "%s")'
 
119
            #            u' was successful'
 
120
            #            % (self.properties[u"name"], command))
114
121
            return
115
122
        if os.WIFEXITED(condition):
116
123
            self.logger(u'Checker for client %s (command "%s")'
131
138
        self.logger(u'Checker for client %s completed mysteriously')
132
139
    
133
140
    def checker_started(self, command):
134
 
        self.logger(u'Client %s started checker "%s"'
135
 
                    % (self.properties[u"name"], unicode(command)))
 
141
        #self.logger(u'Client %s started checker "%s"'
 
142
        #            % (self.properties[u"name"], unicode(command)))
 
143
        pass
136
144
    
137
145
    def got_secret(self):
138
146
        self.logger(u'Client %s received its secret'
139
147
                    % self.properties[u"name"])
140
148
    
141
 
    def rejected(self):
142
 
        self.logger(u'Client %s was rejected'
143
 
                    % self.properties[u"name"])
 
149
    def need_approval(self, timeout, default):
 
150
        if not default:
 
151
            message = u'Client %s needs approval within %s seconds'
 
152
        else:
 
153
            message = u'Client %s will get its secret in %s seconds'
 
154
        self.logger(message
 
155
                    % (self.properties[u"name"], timeout/1000))
 
156
    
 
157
    def rejected(self, reason):
 
158
        self.logger(u'Client %s was rejected; reason: %s'
 
159
                    % (self.properties[u"name"], reason))
144
160
    
145
161
    def selectable(self):
146
162
        """Make this a "selectable" widget.
225
241
#             self.proxy.unpause()
226
242
#         elif key == u"RET":
227
243
#             self.open()
 
244
        elif key == u"+":
 
245
            self.proxy.Approve(True)
 
246
        elif key == u"-":
 
247
            self.proxy.Approve(False)
228
248
        else:
229
249
            return key
230
250