# Path: alignak_app/backend/backend.py
# class BackendClient(object):
#     def __init__(self):
#     def login(self, username=None, password=None, proxies=None, check=False):
#     def get(self, endpoint, params=None, projection=None, all_items=False):
#     def post(self, endpoint, data, headers=None):  # pragma: no cover - Post already test by client
#     def patch(self, endpoint, data, headers):
#     def acknowledge(self, item, sticky, notify, comment):  # pragma: no cover
#     def downtime(self, item, fixed, duration, start_stamp, end_stamp, comment):  # pragma: no cover
#     def query_realms(self):
#     def query_timeperiods(self):
#     def query_user(self):
#     def query_hosts(self):
#     def query_services(self, host_id=None):
#     def query_services_problems(self, state):
#     def query_alignakdaemons(self):
#     def query_livesynthesis(self):
#     def query_history(self, hostname=None, host_id=None):
#     def query_notifications(self):  # pragma: no cover, notifications can be empty
#     def get_backend_status_icon(self):
#     def get_ws_status_icon(self):
# 
# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):
# 
# Path: alignak_app/locales/locales.py
# def init_localization():  # pragma: no cover
#     """
#     Application localization
# 
#     :return: gettext translator method
#     :rtype: method
#     """
#     try:
#         # Language message file
#         lang_filename = os.path.join(
#             os.path.abspath(os.path.dirname(__file__)),
#             "LC_MESSAGES/%s.mo" % settings.get_config('Alignak-app', 'locale')
#         )
#         logger.info(
#             "Opening message file %s for locale %s",
#             lang_filename, settings.get_config('Alignak-app', 'locale')
#         )
#         translation = GNUTranslations(open(lang_filename, "rb"))
#         translation.install()
#         _ = translation.gettext
#     except IOError:
#         logger.warning("Locale not found. Using default language messages (English)")
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
#     except Exception as e:  # pragma: no cover - should not happen
#         logger.error("Locale not found. Exception: %s", str(e))
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
# 
#     return _
# 
# Path: alignak_app/qobjects/threads/thread.py
# class BackendQThread(QThread):  # pylint: disable=too-few-public-methods
#     """
#         Class who create a QThread to trigger requests
#     """
# 
#     problem_states = ['CRITICAL', 'WARNING', 'UNKNOWN']
# 
#     def __init__(self, name, data=None):
#         super(BackendQThread, self).__init__()
#         self.name = name
#         self.data = data
# 
#     def run(self):  # pragma: no cover
#         """
#         Run the QThread. Trigger actions depending on the selected name
# 
#         """
# 
#         if app_backend.connected:
#             logger.debug('Launch a new thread request for backend: %s', self.name)
#             if 'user' in self.name:
#                 app_backend.query_user()
#             elif 'host' in self.name:
#                 app_backend.query_hosts()
#             elif 'service' in self.name:
#                 app_backend.query_services(self.data)
#             elif self.name in self.problem_states:
#                 app_backend.query_services_problems(self.name)
#             elif 'alignakdaemon' in self.name:
#                 app_backend.query_alignakdaemons()
#             elif 'livesynthesis' in self.name:
#                 app_backend.query_livesynthesis()
#             elif 'realm' in self.name:
#                 app_backend.query_realms()
#             elif 'timeperiod' in self.name:
#                 app_backend.query_timeperiods()
#             elif self.name == 'history':
#                 if self.data:
#                     app_backend.query_history(self.data['hostname'], self.data['host_id'])
#                 else:
#                     app_backend.query_history()
#             elif 'notifications' in self.name:
#                 app_backend.query_notifications()
#             else:
#                 logger.error("Thread is unknown: %s", self.name)
#         else:
#             logger.warning('The app is offline, the threads can not be launched !')
#             self.quit()


import unittest2
from alignak_app.backend.backend import app_backend
from alignak_app.utils.config import settings
from alignak_app.locales.locales import init_localization
from alignak_app.qobjects.threads.thread import BackendQThread
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2015-2018:
#   Matthieu Estrada, ttamalfor@gmail.com
#
# This file is part of (AlignakApp).
#
# (AlignakApp) is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# (AlignakApp) 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with (AlignakApp).  If not, see <http://www.gnu.org/licenses/>.




settings.init_config()
init_localization()
app_backend.login()



# Path: alignak_app/backend/backend.py
# class BackendClient(object):
#     def __init__(self):
#     def login(self, username=None, password=None, proxies=None, check=False):
#     def get(self, endpoint, params=None, projection=None, all_items=False):
#     def post(self, endpoint, data, headers=None):  # pragma: no cover - Post already test by client
#     def patch(self, endpoint, data, headers):
#     def acknowledge(self, item, sticky, notify, comment):  # pragma: no cover
#     def downtime(self, item, fixed, duration, start_stamp, end_stamp, comment):  # pragma: no cover
#     def query_realms(self):
#     def query_timeperiods(self):
#     def query_user(self):
#     def query_hosts(self):
#     def query_services(self, host_id=None):
#     def query_services_problems(self, state):
#     def query_alignakdaemons(self):
#     def query_livesynthesis(self):
#     def query_history(self, hostname=None, host_id=None):
#     def query_notifications(self):  # pragma: no cover, notifications can be empty
#     def get_backend_status_icon(self):
#     def get_ws_status_icon(self):
# 
# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):
# 
# Path: alignak_app/locales/locales.py
# def init_localization():  # pragma: no cover
#     """
#     Application localization
# 
#     :return: gettext translator method
#     :rtype: method
#     """
#     try:
#         # Language message file
#         lang_filename = os.path.join(
#             os.path.abspath(os.path.dirname(__file__)),
#             "LC_MESSAGES/%s.mo" % settings.get_config('Alignak-app', 'locale')
#         )
#         logger.info(
#             "Opening message file %s for locale %s",
#             lang_filename, settings.get_config('Alignak-app', 'locale')
#         )
#         translation = GNUTranslations(open(lang_filename, "rb"))
#         translation.install()
#         _ = translation.gettext
#     except IOError:
#         logger.warning("Locale not found. Using default language messages (English)")
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
#     except Exception as e:  # pragma: no cover - should not happen
#         logger.error("Locale not found. Exception: %s", str(e))
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
# 
#     return _
# 
# Path: alignak_app/qobjects/threads/thread.py
# class BackendQThread(QThread):  # pylint: disable=too-few-public-methods
#     """
#         Class who create a QThread to trigger requests
#     """
# 
#     problem_states = ['CRITICAL', 'WARNING', 'UNKNOWN']
# 
#     def __init__(self, name, data=None):
#         super(BackendQThread, self).__init__()
#         self.name = name
#         self.data = data
# 
#     def run(self):  # pragma: no cover
#         """
#         Run the QThread. Trigger actions depending on the selected name
# 
#         """
# 
#         if app_backend.connected:
#             logger.debug('Launch a new thread request for backend: %s', self.name)
#             if 'user' in self.name:
#                 app_backend.query_user()
#             elif 'host' in self.name:
#                 app_backend.query_hosts()
#             elif 'service' in self.name:
#                 app_backend.query_services(self.data)
#             elif self.name in self.problem_states:
#                 app_backend.query_services_problems(self.name)
#             elif 'alignakdaemon' in self.name:
#                 app_backend.query_alignakdaemons()
#             elif 'livesynthesis' in self.name:
#                 app_backend.query_livesynthesis()
#             elif 'realm' in self.name:
#                 app_backend.query_realms()
#             elif 'timeperiod' in self.name:
#                 app_backend.query_timeperiods()
#             elif self.name == 'history':
#                 if self.data:
#                     app_backend.query_history(self.data['hostname'], self.data['host_id'])
#                 else:
#                     app_backend.query_history()
#             elif 'notifications' in self.name:
#                 app_backend.query_notifications()
#             else:
#                 logger.error("Thread is unknown: %s", self.name)
#         else:
#             logger.warning('The app is offline, the threads can not be launched !')
#             self.quit()


# Path: test/test_thread.py
import unittest2
from alignak_app.backend.backend import app_backend
from alignak_app.utils.config import settings
from alignak_app.locales.locales import init_localization
from alignak_app.qobjects.threads.thread import BackendQThread

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2015-2018:
#   Matthieu Estrada, ttamalfor@gmail.com
#
# This file is part of (AlignakApp).
#
# (AlignakApp) is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# (AlignakApp) 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with (AlignakApp).  If not, see <http://www.gnu.org/licenses/>.




settings.init_config()
init_localization()
app_backend.login()



class TestBackendQThread(unittest2.TestCase):