# Path: controllers/web.py
# def login():
# def logout():
# def groceries():
# def api_groceries_list():
# def api_groceries_edit(barcode, quantity):
# def products():
# def api_products_list():
# def api_products_edit(barcode, name):
# def api_products_delete(barcode):
# def api_lang():


import logging
import argparse
import os
import controllers
import utils
from controllers.web import webapp # Gunicorn hook for Flask

    # If no "do" argument
    if not arguments or not hasattr(arguments, 'do') or not arguments.do:
        message = "Jean-Pierre understands:\n"
        message += "--do config : launch the configuration assistant"
        message += "--do scanner : launch the scanner process"
        message += "--do webdebug : launch the DEBUG web server"
        print(message)
        return

    # If invalid "do" argument
    if arguments.do not in ['config', 'scanner', 'webdebug']:
        message = 'Invalid option --do "{}"'.format(arguments.do)
        print(message)
        return

    # Check that the program has been configured
    if arguments.do != 'config' and not os.path.isfile('database.db'):
        message = "Jean-Pierre is not configured. Please launch jeanpierre.py --do config"
        print(message)
        return

    # Launch controller : Config
    if arguments.do == 'config':
        controllers.Config.execute(str(arguments.lang))
    # Launch controller : Scanner
    elif arguments.do == 'scanner':
        controllers.Scanner.execute()
    # Launch controller : Web debug
    elif arguments.do == 'webdebug':

# Path: controllers/web.py
# def login():
# def logout():
# def groceries():
# def api_groceries_list():
# def api_groceries_edit(barcode, quantity):
# def products():
# def api_products_list():
# def api_products_edit(barcode, name):
# def api_products_delete(barcode):
# def api_lang():


# Path: jeanpierre.py
import logging
import argparse
import os
import controllers
import utils
from controllers.web import webapp # Gunicorn hook for Flask


    # If no "do" argument
    if not arguments or not hasattr(arguments, 'do') or not arguments.do:
        message = "Jean-Pierre understands:\n"
        message += "--do config : launch the configuration assistant"
        message += "--do scanner : launch the scanner process"
        message += "--do webdebug : launch the DEBUG web server"
        print(message)
        return

    # If invalid "do" argument
    if arguments.do not in ['config', 'scanner', 'webdebug']:
        message = 'Invalid option --do "{}"'.format(arguments.do)
        print(message)
        return

    # Check that the program has been configured
    if arguments.do != 'config' and not os.path.isfile('database.db'):
        message = "Jean-Pierre is not configured. Please launch jeanpierre.py --do config"
        print(message)
        return

    # Launch controller : Config
    if arguments.do == 'config':
        controllers.Config.execute(str(arguments.lang))
    # Launch controller : Scanner
    elif arguments.do == 'scanner':
        controllers.Scanner.execute()
    # Launch controller : Web debug
    elif arguments.do == 'webdebug':

        webapp.run(debug=True, host='0.0.0.0')