2018-09-23 10:36:52 +00:00
|
|
|
#!@PYTHON@
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Copyright © 2017 Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>
|
|
|
|
|
|
|
|
This file is part of Authenticator.
|
|
|
|
|
|
|
|
Authenticator is free software: you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Authenticator is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Authenticator. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import gettext
|
|
|
|
import locale
|
|
|
|
import sys
|
|
|
|
from os import path
|
2018-12-30 14:50:37 +01:00
|
|
|
from gettext import gettext as _
|
2018-09-23 10:36:52 +00:00
|
|
|
from gi import require_version
|
|
|
|
|
|
|
|
require_version('GIRepository', '2.0')
|
|
|
|
from gi.repository import Gio, GIRepository
|
|
|
|
|
|
|
|
sys.path.insert(1, '@PYTHON_EXEC_DIR@')
|
|
|
|
sys.path.insert(1, '@PYTHON_DIR@')
|
|
|
|
|
2018-12-30 14:50:37 +01:00
|
|
|
def prepare_locale():
|
2018-09-23 10:36:52 +00:00
|
|
|
locale.bindtextdomain('Authenticator', '@LOCALE_DIR@')
|
|
|
|
locale.textdomain('Authenticator')
|
|
|
|
gettext.bindtextdomain('Authenticator', '@LOCALE_DIR@')
|
|
|
|
gettext.textdomain('Authenticator')
|
2018-12-30 14:50:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
def prepare_gir():
|
|
|
|
gir_repository_path = path.join('@LIB_DIR@', 'girepository-1.0')
|
|
|
|
GIRepository.Repository.prepend_search_path(gir_repository_path)
|
2018-09-23 10:36:52 +00:00
|
|
|
GIRepository.Repository.prepend_library_path('@LIB_DIR@')
|
|
|
|
|
2018-12-30 14:50:37 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
prepare_locale()
|
|
|
|
prepare_gir()
|
|
|
|
|
2018-09-23 10:36:52 +00:00
|
|
|
parser = argparse.ArgumentParser(prog="Authenticator")
|
|
|
|
parser.add_argument("--debug", "-d", action="store_true",
|
|
|
|
help=_("Start in debug mode"))
|
|
|
|
parser.add_argument("--version", "-v", action="store_true",
|
|
|
|
help=_("Authenticator version number"))
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2018-12-30 14:50:37 +01:00
|
|
|
resource = Gio.resource_load(path.join('@DATA_DIR@', '@APP_ID@.gresource'))
|
2018-09-23 10:36:52 +00:00
|
|
|
Gio.Resource._register(resource)
|
|
|
|
|
|
|
|
|
2018-12-30 14:50:37 +01:00
|
|
|
from Authenticator.models import Logger
|
2018-09-23 10:36:52 +00:00
|
|
|
level = Logger.ERROR
|
|
|
|
if args.debug:
|
|
|
|
level = Logger.DEBUG
|
|
|
|
import faulthandler
|
|
|
|
faulthandler.enable()
|
|
|
|
|
|
|
|
Logger.set_level(level)
|
|
|
|
if args.version:
|
2018-12-30 14:50:37 +01:00
|
|
|
sys.exit("Version : @VERSION@")
|
2018-09-23 10:36:52 +00:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
from Authenticator import Application
|
|
|
|
app = Application.get_default()
|
2018-10-19 15:23:01 -04:00
|
|
|
Application.IS_DEVEL = "@PROFILE@" == 'Devel'
|
2018-09-23 10:36:52 +00:00
|
|
|
exit_status = app.run(None)
|
|
|
|
sys.exit(exit_status)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
exit()
|