| ... |
... |
@@ -94,17 +94,24 @@ def _inhibit_sleep(self, connection): |
|
94
|
94
|
log.warning('Trying to obtain a sleep inhibitor '
|
|
95
|
95
|
'while already holding one.')
|
|
96
|
96
|
|
|
97
|
|
- ret, ret_fdlist = connection.call_with_unix_fd_list_sync(
|
|
98
|
|
- 'org.freedesktop.login1',
|
|
99
|
|
- '/org/freedesktop/login1',
|
|
100
|
|
- 'org.freedesktop.login1.Manager',
|
|
101
|
|
- 'Inhibit',
|
|
102
|
|
- GLib.Variant('(ssss)', (
|
|
103
|
|
- 'sleep', 'org.gajim.Gajim', _('Disconnect from the network'),
|
|
104
|
|
- 'delay' # Inhibitor will delay but not block sleep
|
|
105
|
|
- )),
|
|
106
|
|
- GLib.VariantType.new('(h)'),
|
|
107
|
|
- Gio.DBusCallFlags.NONE, -1, None, None)
|
|
|
97
|
+ try:
|
|
|
98
|
+ ret, ret_fdlist = connection.call_with_unix_fd_list_sync(
|
|
|
99
|
+ 'org.freedesktop.login1',
|
|
|
100
|
+ '/org/freedesktop/login1',
|
|
|
101
|
+ 'org.freedesktop.login1.Manager',
|
|
|
102
|
+ 'Inhibit',
|
|
|
103
|
+ GLib.Variant('(ssss)', (
|
|
|
104
|
+ 'sleep',
|
|
|
105
|
+ 'org.gajim.Gajim',
|
|
|
106
|
+ _('Disconnect from the network'),
|
|
|
107
|
+ 'delay' # Inhibitor will delay but not block sleep
|
|
|
108
|
+ )),
|
|
|
109
|
+ GLib.VariantType.new('(h)'),
|
|
|
110
|
+ Gio.DBusCallFlags.NONE, -1, None, None)
|
|
|
111
|
+ except GLib.Error as error:
|
|
|
112
|
+ log.warning(
|
|
|
113
|
+ 'Cannot obtain a sleep delay inhibitor from logind: %s', error)
|
|
|
114
|
+ return
|
|
108
|
115
|
|
|
109
|
116
|
log.info('Inhibit sleep')
|
|
110
|
117
|
self._inhibit_fd = ret_fdlist.get(ret.unpack()[0])
|