#!/usr/bin/python3

# system76-driver: Universal driver for System76 computers
# Copyright (C) 2005-2016 System76, Inc.
#
# This file is part of `system76-driver`.
#
# `system76-driver` 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 2 of the License, or
# (at your option) any later version.
#
# `system76-driver` 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 `system76-driver`; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import argparse
import os
import time
import logging
import distro

import system76driver
from system76driver.model import determine_model_new
from system76driver.products import PRODUCTS
from system76driver.gtk import UI


parser = argparse.ArgumentParser()
parser.add_argument('--home', help='specify home directory')
parser.add_argument('--model', help='force model rather than detecting it')
parser.add_argument('--dry', action='store_true', default=False,
    help='print what would be done but without calling Action.perform()',
)
args = parser.parse_args()

logging.basicConfig(
    level=logging.DEBUG,
    style='{',
    format='{asctime}  {levelname}  {message}',
)
log = logging.getLogger()

if args.home is None:
    args.home = os.environ['HOME']
if args.model is None:
    args.model = determine_model_new()
product = PRODUCTS.get(args.model)

log.info('** Process start at monotonic time %r', time.monotonic())
log.info('system76driver.__version__: %r', system76driver.__version__)
log.info('OS: %r', distro.name())
log.info('kernel: %r', os.uname().release)
log.info('model: %r', args.model)

ui = UI(args.model, product, args)
ui.run()

