def check_all_haap():
    Origin_from_engine, Info_from_engine = haap.data_for_db()
    try:
        Info_from_DB = db.haap_last_record()
        if Info_from_DB:
            for engine in lst_haap_alias:
                lstRT = haap_info_for_judge(Info_from_engine)[engine]
                lstDB = haap_info_for_judge(Info_from_DB.info)[engine]
                haap_judge(lstRT, lstDB, engine).all_judge()
    finally:
        db.haap_insert(datetime.datetime.now(), Origin_from_engine,
                       Info_from_engine)
def haap_rt_info_to_show():
    """
    @note: HAAP网页展示即时数据(status)
    """
    dicALL = haap.data_for_db()[1]
    lstHAAPToShow = []
    if dicALL:
        for engine_alias in dicALL.keys():
            info_status = dicALL[engine_alias]['status']
            info_status.insert(0, engine_alias)
            info_status.append(dicALL[engine_alias]['level'])
            lstHAAPToShow.append(info_status)
        return lstHAAPToShow
Exemple #3
0
def test_data_for_db():
    data = haap.data_for_db()
    assert data[0].keys() == ['engine0']
    assert data[1].keys() == ['engine0']
Exemple #4
0
import pytest
import DB
import datetime
import HAAP as haap
import SANSW as sw
try:
    import configparser as cp
except Exception:
    import ConfigParser as cp

cfg = cp.ConfigParser(allow_no_value=True)
cfg.read('config.ini')
time = datetime.datetime.now()
time_ago = time - datetime.timedelta(minutes=1)
timeshow = time.strftime('%Y-%m-%d %H:%M:%S')
Origin, Info = haap.data_for_db()
origin, total, dic = sw.get_info_for_DB()
ip = str(cfg.get('Engines', 'engine0'))
device = 'engine0'
level = 2
warn = 'Engine AH'
confirm = 0


@pytest.mark.mnt
def test_haap_insert():
    assert DB.haap_insert(time, Origin, Info) == None


@pytest.mark.mnt
def test_haap_last_record():