#!@PYTHON@
# coding=utf-8

import os
import sys
import logging

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if 'BLUEMAN_SOURCE' in os.environ:
    sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
    os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

from blueman.Functions import set_proc_title, setup_icon_path, create_logger, create_parser
from blueman.main.Services import BluemanServices

if __name__ == '__main__':
    parser = create_parser()
    args = parser.parse_args()

    if args.LEVEL.upper() == "DEBUG":
        log_level = logging.DEBUG
    elif args.LEVEL.upper() == "INFO":
        log_level = logging.INFO
    elif args.LEVEL.upper() == "WARNING":
        log_level = logging.WARNING
    elif args.LEVEL.upper() == "ERROR":
        log_level = logging.ERROR
    elif args.LEVEL.upper() == "CRITICAL":
        log_level = logging.CRITICAL
    else:
        log_level = logging.WARNING

    create_logger(log_level, "blueman-services", syslog=args.syslog)

    setup_icon_path()
    services = BluemanServices()
    set_proc_title()
    Gtk.main()
