This repository has been archived by the owner on May 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathauthenticator.py.in
executable file
·79 lines (62 loc) · 2.57 KB
/
authenticator.py.in
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright © 2017 Bilal Elmoussaoui <[email protected]>
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
from gi import require_version
require_version('GIRepository', '2.0')
from gi.repository import Gio, GIRepository
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@')
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()
resource = Gio.resource_load(path.join('@DATA_DIR@',
'com.github.bilelmoussaoui.Authenticator.gresource'))
Gio.Resource._register(resource)
from Authenticator.models import Logger
level = Logger.ERROR
if args.debug:
level = Logger.DEBUG
import faulthandler
faulthandler.enable()
Logger.set_level(level)
if args.version:
sys.exit("Version : " + str(VERSION))
else:
try:
from Authenticator import Application
app = Application.get_default()
app.set_use_qrscanner(bool("@ENABLE_QRSCANNER@"))
exit_status = app.run(None)
sys.exit(exit_status)
except KeyboardInterrupt:
exit()