Authenticator/gnome-twofactorauth.in
2016-06-21 04:45:49 +02:00

77 lines
2.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright © 2016 Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>
This file is part of Gnome-TwoFactorAuth.
TwoFactorAuth 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.
Gnome-TwoFactorAuth 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 Gnome-TwoFactorAuth. If not, see <http://www.gnu.org/licenses/>.
"""
from gi import require_version
require_version("Gtk", "3.0")
from gi.repository import Gtk
import sys
sys.path.insert(1, '@pyexecdir@')
sys.path.insert(1, '@pythondir@')
from gi.repository import Gio
from TwoFactorAuth import application
import logging
import locale
import gettext
_ = gettext.gettext
import argparse
import faulthandler
from os import path, environ as env
if __name__ == "__main__":
locale.bindtextdomain('TwoFactorAuth', "@localedir@")
locale.textdomain('TwoFactorAuth')
gettext.bindtextdomain('TwoFactorAuth', "@localedir@")
gettext.textdomain('TwoFactorAuth')
env["DATA_DIR"] = "@pkgdatadir@"
env["LOCALE_DIR"] = "@localedir@"
parser = argparse.ArgumentParser(prog="TwoFactorAuth")
parser.add_argument("--debug", "-d", action="store_true",
help=_("start in debug mode"))
parser.add_argument("--version", "-v", action="store_true",
help=_("Gnome-TwoFactorAuth version number"))
parser.add_argument("--about", action="store_true",
help=_("Show about dialog"))
args = parser.parse_args()
level = logging.ERROR
if args.debug:
level = logging.DEBUG
faulthandler.enable()
logging.basicConfig(level=level,
format='[%(levelname)s] - %(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
resource = Gio.resource_load(path.join('@pkgdatadir@',
'gnome-twofactorauth.gresource'))
Gio.Resource._register(resource)
if args.version:
sys.exit("Version : @VERSION@")
elif args.about:
about_dialog = application.Application.about_dialog()
about_dialog.run()
about_dialog.destroy()
sys.exit()
else:
app = application.Application()
exit_status = app.run(None)
sys.exit(exit_status)