File: main.py

package info (click to toggle)
libcharon 5.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 576 kB
  • sloc: python: 1,575; sh: 388; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

import os
import logging

import dbus.service
import dbus.mainloop.glib
from typing import Dict, Any
from gi.repository import GLib

import Charon.Service

# Very basic service main loop built with GLib.

GLib.threads_init()
dbus.mainloop.glib.threads_init()

config = {} # type: Dict[str, Any]
if os.environ.get("CHARON_DEBUG", "0") == "1":
    config["level"] = logging.DEBUG
else:
    config["level"] = logging.WARNING
config["format"] = "%(asctime)s | %(levelname)s | %(name)s:%(lineno)d@%(funcName)s | %(message)s"
logging.basicConfig(**config)

_loop = GLib.MainLoop()

# Use a single bus object for all dbus communication.
if os.environ.get("CHARON_USE_SESSION_BUS", "1") == "1":
    _bus = dbus.SessionBus(private=True, mainloop=dbus.mainloop.glib.DBusGMainLoop())
else:
    _bus = dbus.SystemBus(private=True, mainloop=dbus.mainloop.glib.DBusGMainLoop())

_service = Charon.Service.FileService(_bus)

_loop.run()