#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) Branson Stephens (2015)
#
# This file is part of lvalert-overseer
#
# lvalert-overseer 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.
#
# It 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 LIGO.ORG.  If not, see <http://www.gnu.org/licenses/>.

from datetime import datetime
from ligo.overseer.client import send_to_overseer
import logging, time
from twisted.internet import reactor
from multiprocessing import Process, Manager

logger = logging.getLogger('overseer_test_client')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())

manager = Manager()

while True:
    time.sleep(1)
    mdict = {
        'message': 'Hi, this is a test. %s ' % datetime.now().isoformat(),
        'node_name' : 'branson_test2',
        'action': 'push'
    }
    rdict = manager.dict()
    p = Process(target=send_to_overseer, args=(mdict, rdict, logger))
    p.start()
    p.join()
