Authenticator/authenticator.py.in

78 lines
2.6 KiB
Python
Raw Normal View History

2017-09-17 10:14:13 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright © 2017 Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>
2018-03-16 04:12:49 +01:00
This file is part of Authenticator.
2017-09-17 10:14:13 +02:00
2018-03-16 04:12:49 +01:00
Authenticator is free software: you can redistribute it and/or
2017-09-17 10:14:13 +02:00
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.
2018-03-16 04:12:49 +01:00
Authenticator is distributed in the hope that it will be useful,
2017-09-17 10:14:13 +02:00
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
2018-03-16 04:12:49 +01:00
along with Authenticator. If not, see <http://www.gnu.org/licenses/>.
2017-09-17 10:14:13 +02:00
"""
import argparse
import gettext
import locale
import sys
from os import path
from gi import require_version
require_version('GIRepository', '2.0')
from gi.repository import Gio, GIRepository
2017-09-17 10:14:13 +02:00
sys.path.insert(1, '@PYTHON_DIR@')
_ = gettext.gettext
if __name__ == "__main__":
locale.bindtextdomain('Authenticator', '@LOCALE_DIR@')
locale.textdomain('Authenticator')
gettext.bindtextdomain('Authenticator', '@LOCALE_DIR@')
gettext.textdomain('Authenticator')
VERSION = "@VERSION@"
GIRepository.Repository.prepend_search_path(
path.join('@LIB_DIR@', 'girepository-1.0'))
GIRepository.Repository.prepend_library_path('@LIB_DIR@')
2017-09-17 10:14:13 +02:00
2018-03-16 04:12:49 +01:00
parser = argparse.ArgumentParser(prog="Authenticator")
2017-09-17 10:14:13 +02:00
parser.add_argument("--debug", "-d", action="store_true",
help=_("Start in debug mode"))
parser.add_argument("--version", "-v", action="store_true",
2018-03-16 04:12:49 +01:00
help=_("Authenticator version number"))
2017-09-17 10:14:13 +02:00
args = parser.parse_args()
resource = Gio.resource_load(path.join('@DATA_DIR@',
'com.github.bilelmoussaoui.Authenticator.gresource'))
Gio.Resource._register(resource)
from Authenticator.models import Logger
2017-09-17 10:14:13 +02:00
level = Logger.ERROR
if args.debug:
level = Logger.DEBUG
2018-09-09 01:20:21 +02:00
import faulthandler
2017-09-17 10:14:13 +02:00
faulthandler.enable()
Logger.set_level(level)
2017-09-17 10:14:13 +02:00
if args.version:
sys.exit("Version : " + str(VERSION))
else:
try:
from Authenticator import Application
app = Application.get_default()
2018-09-02 15:05:51 +02:00
app.set_use_qrscanner(bool("@ENABLE_QRSCANNER@"))
2017-09-17 10:14:13 +02:00
exit_status = app.run(None)
sys.exit(exit_status)
except KeyboardInterrupt:
exit()