Failed Conditions
Pull Request — master (#2076)
by Abdeali
02:11
created

coalib/coala_dbus.py (1 issue)

1
#!/usr/bin/env python3
2
3
# This program is free software: you can redistribute it and/or modify it
4
# under the terms of the GNU Affero General Public License as published by the
5
# Free Software Foundation, either version 3 of the License, or (at your
6
# option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful, but WITHOUT
9
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License
11
# for more details.
12
#
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16
import sys
17
18
import dbus
19
import dbus.mainloop.glib
20
from coalib.misc import Constants
21
from coalib.output.dbus.DbusServer import DbusServer
22
from gi.repository import GLib
23
24
25
def sys_clean_exit():
26
    sys.exit(0)
27
28
29
def on_disconnected():
30
    return GLib.idle_add(sys_clean_exit)
31
32
33
def main():
34
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
35
36
    session_bus = dbus.SessionBus()
37
    # The BusName needs to be saved to a variable, if it is not saved - the
38
    # Bus will be closed.
39
    dbus_name = dbus.service.BusName(  # pylint: disable=unused-variable
40
        Constants.BUS_NAME,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Constants does not seem to be defined.
Loading history...
41
        session_bus)
42
    DbusServer(session_bus,
43
               '/org/coala_analyzer/v1',
44
               on_disconnected=on_disconnected)
45
46
    mainloop = GLib.MainLoop()
47
    mainloop.run()
48