<commit_before># -*- coding: utf-8 -*-

import logging

import requests

from ..common.subject import Subject
from ..common.events import IP_UPDATE_SUCCESS, IP_UPDATE_ERROR

log = logging.getLogger(__name__)


class UpdateProtocol(Subject):
    """the base class for all update protocols"""

    _updateurl = None
    theip = None
    hostname = None  # this holds the desired dns hostname
    status = 0
    nochgcount = 0
    failcount = 0

    def __init__(self):
        self.updateurl = self._updateurl
        super(UpdateProtocol, self).__init__()

    def updateUrl(self):
        return self.updateurl

    def success(self):
        self.status = 0
        self.failcount = 0
        self.nochgcount = 0
        self.notify_observers(IP_UPDATE_SUCCESS, "Updated IP address of '%s' to %s" % (self.hostname, self.theip))

    def abuse(self):
        self.status = 1
        self.failcount = 0<commit_msg>adding basic code for future notification support<commit_after># -*- coding: utf-8 -*-

import logging

import requests

from ..common.subject import Subject
from ..common.events import IP_UPDATE_SUCCESS, IP_UPDATE_ERROR

log = logging.getLogger(__name__)


class UpdateProtocol(Subject):
    """the base class for all update protocols"""

    _updateurl = None
    theip = None
    hostname = None  # this holds the desired dns hostname
    status = 0
    nochgcount = 0
    failcount = 0

    def __init__(self):
        self.updateurl = self._updateurl
        super(UpdateProtocol, self).__init__()

        observers = []

        # TODO: auto detect all notifiers
        # TODO: make this configurable?
        #from ..notifications import osxnotificationcenter
        #if osxnotificationcenter.is_available():
        #    observers.append(osxnotificationcenter.create_notify_handler())

        for observer in observers:
            self.register_observer(observer, (IP_UPDATE_SUCCESS, IP_UPDATE_ERROR))

    def updateUrl(self):
        return self.updateurl

    def success(self):
        self.status = 0
        self.failcount = 0
        self.nochgcount = 0
        self.notify_observers(IP_UPDATE_SUCCESS, "Updated IP address of '%s' to %s" % (self.hostname, self.theip))

    def abuse(self):
        self.status = 1
        self.failcount = 0
{'fraction_non_alphanumeric': 0.0901495162708883, 'fraction_numerical': 0.0079155672823219, 'mean_word_length': 2.7295081967213113, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3271510', 'n_tokens_mistral': 676, 'n_tokens_neox': 649, 'n_words': 187}