<commit_before>'''
This class is responsible for going on Zabbix and get some data
'''

from pyzabbix import ZabbixAPI
from datetime import datetime
import time
import configs


class ZabbixData:
    def __init__(self):
        self.zapi = ZabbixAPI(configs.zabbixapiurl)
        self.zapi.login(configs.zabbixapilogin, configs.zabbixapipasswd)
        self.time_till = time.mktime(datetime.now().timetuple())
        self.time_from = self.time_till - 60 * 60 * 2  # 2 hours

    def gethistory(self, item):
        kind =  item['kind']

        if kind == 'Line':
            id = item['zid']
            history = self.zapi.history.get(itemids=id,
                                            time_from=self.time_from,
                                            time_till=self.time_till,
                                            output='extend',
                                            limit='120',)
            if not len(history):
                history = self.zapi.history.get(itemids=id,
                                                time_from=self.time_from,
                                                time_till=self.time_till,
                                                output='extend',
                                                limit='120',
                                                history=0,)

        if kind == 'Monitoring':
            httptestid = item['httptestid']
            history = self.zapi.webcheck.get(httptestids=httptestid,
                                            output='extend',
                                            limit='6',
                                            selectSteps='extend',
                                            webstepid=0,)

        return history

    def getunacktriggers(self, item):
        unack_triggers = self.zapi.trigger.get(only_true=1,
                                               skipDependent=1,
                                               monitored=1,
                                               active=1,
                                               output='extend',
                                               expandDescription=1,
                                               expandData='host',
                                               withLastEventUnacknowledged=1,
                                               sortfield='priority',sortorder='DESC'
                                               )
        print unack_triggers
        return unack_triggers<commit_msg>Identation beauty<commit_after>'''
This class is responsible for going on Zabbix and get some data
'''

from pyzabbix import ZabbixAPI
from datetime import datetime
import time
import configs


class ZabbixData:
    def __init__(self):
        self.zapi = ZabbixAPI(configs.zabbixapiurl)
        self.zapi.login(configs.zabbixapilogin, configs.zabbixapipasswd)
        self.time_till = time.mktime(datetime.now().timetuple())
        self.time_from = self.time_till - 60 * 60 * 2  # 2 hours

    def gethistory(self, item):
        kind =  item['kind']

        if kind == 'Line':
            id = item['zid']
            history = self.zapi.history.get(itemids=id,
                                            time_from=self.time_from,
                                            time_till=self.time_till,
                                            output='extend',
                                            limit='120',)
            if not len(history):
                history = self.zapi.history.get(itemids=id,
                                                time_from=self.time_from,
                                                time_till=self.time_till,
                                                output='extend',
                                                limit='120',
                                                history=0,)

        if kind == 'Monitoring':
            httptestid = item['httptestid']
            history = self.zapi.webcheck.get(httptestids=httptestid,
                                             output='extend',
                                             limit='6',
                                             selectSteps='extend',
                                             webstepid=0,)

        return history

    def getunacktriggers(self, item):
        unack_triggers = self.zapi.trigger.get(only_true=1,
                                               skipDependent=1,
                                               monitored=1,
                                               active=1,
                                               output='extend',
                                               expandDescription=1,
                                               expandData='host',
                                               withLastEventUnacknowledged=1,
                                               sortfield='priority',sortorder='DESC'
                                               )
        print unack_triggers
        return unack_triggers
{'fraction_non_alphanumeric': 0.07168458781362007, 'fraction_numerical': 0.008363201911589008, 'mean_word_length': 0.8631305637982196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 88, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '53849', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1008, 'n_words': 196}