~doctormo/lab-session-manager/stable

« back to all changes in this revision

Viewing changes to lib/labsession/manager.py

  • Committer: Martin Owens
  • Date: 2012-08-01 22:29:42 UTC
  • Revision ID: doctormo@gmail.com-20120801222942-shd432s7if0ww1dw
Fix error with notifiers

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
 
111
111
    def start(self):
112
112
        """Start logging the session."""
113
 
        self.session_manager_watch()
 
113
        try:
 
114
            self.session_manager_watch()
 
115
        except ValueError:
 
116
            sys.stderr.write("Connection to session manager failed (might cause problems).\n")
 
117
 
114
118
        self.log = SessionLog(hostname=self.hostname, username=self.username)
115
119
        self.log.event('login', tag='started', data={'session-pid':self.pid})
116
120
 
134
138
        addr = "org.gnome.SessionManager"
135
139
        path = "/" + addr.replace('.', '/')
136
140
 
137
 
        session = conn.get_object(addr, path, addr)
 
141
        try:
 
142
            session = conn.get_object(addr, path, addr)
 
143
            sys.stderr.write("Client registered with session manager: %s\n" % self.cpath)
 
144
        except:
 
145
            # This should be made more precise
 
146
            raise ValueError("Session Manager Failed")
 
147
 
138
148
        self.gnome_session = session
 
149
        self.cpath = session.RegisterClient(client, uid, dbus_interface=addr)
139
150
        self.gnome_address = addr
140
 
        self.cpath = session.RegisterClient(client, uid, dbus_interface=addr)
141
151
  
142
 
        sys.stderr.write("Client registered with session manager: %s\n" % self.cpath)
143
152
        client = conn.get_object(addr, self.cpath, addr+".ClientPrivate")
144
153
        self.gnome_client = client
145
154
  
193
202
 
194
203
    def quit(self):
195
204
        """Logout from user."""
196
 
        self.gnome_session.Logout(TESTING and 0 or 2,
197
 
            dbus_interface=self.gnome_address)
 
205
        if self.gnome_session:
 
206
            self.gnome_session.Logout(TESTING and 0 or 2,
 
207
                dbus_interface=self.gnome_address)
198
208
 
199
209
    def event(self, t, icon):
200
210
        """Log any event, internal methiod."""
253
263
            desc = warning.get('description', '') % jar
254
264
            icon = warning.get('icon', 'gtk-info')
255
265
            # Send a notification to the system notifier.
256
 
            Notify.Notification.new(mesg, desc, icon).show()
 
266
            Notify.Notification.new(mesg, desc, icon, None).show()
257
267
 
258
268
    def end_clicked(self, widget=None):
259
269
        """User clicked quit in the menu."""
270
280
        # create a menu
271
281
        self.menu = Gtk.Menu()
272
282
        if TESTING:
273
 
            title = Gtk.MenuItem("Testing Session...")
 
283
            title = Gtk.MenuItem()
 
284
            title.set_label("Testing Session...")
274
285
            self.menu.append(title)
275
286
            title.show()
276
287
            separator = Gtk.MenuItem()