<commit_before>from threading import Timer
import time
import socket
import sys

import ConfigParser

from termcolor import colored
from rolit.protocol import Protocol

class Helpers(object):

    class WhatsApp(object):

        __shared_state = {}
        def __init__(self):
            self.__dict__ = self.__shared_state

            if not hasattr(self, 'whatsapp'):
                config = ConfigParser.ConfigParser()
                config.read('config')
                if not config.has_option('whatsapp', 'phone'):
                    self.whatsapp = None
                    return

                self.config = config

                sys.path.append('./lib/python_whatsapp')
                import whatsappy
                from base64 import b64decode

                self.whatsapp = whatsappy.Client(number=config.get('whatsapp', 'phone'), secret=b64decode(config.get('whatsapp', 'secret')))
                self.whatsapp.login()

                self.timer = Timer(self.whatsapp.PING_INTERVAL, self._ping, ())
                self.timer.daemon = True
                self.timer.start()

                Helpers.error_and_whatsapp("WhatsApp connection established for `%s`" % socket.gethostname())

        def _ping(self):
            try:
                self.whatsapp._ping()
            except IOError:
                del self.whatsapp
                self.timer.cancel()
                Helpers.error_and_whatsapp("Connection lost to WhatsApp while pinging!")

        def send(self, message):
            if self.whatsapp:
                try:
                    self.whatsapp.group_message(self.config.get('whatsapp', 'group_id'), message)
                except IOError:<commit_msg>Remove WhatApp pinging to keep connection alive<commit_after>from threading import Timer
import time
import socket
import sys

import ConfigParser

from termcolor import colored
from rolit.protocol import Protocol

class Helpers(object):

    class WhatsApp(object):

        __shared_state = {}
        def __init__(self):
            self.__dict__ = self.__shared_state

            if not hasattr(self, 'whatsapp'):
                config = ConfigParser.ConfigParser()
                config.read('config')
                if not config.has_option('whatsapp', 'phone'):
                    self.whatsapp = None
                    return

                self.config = config

                sys.path.append('./lib/python_whatsapp')
                import whatsappy
                from base64 import b64decode

                self.whatsapp = whatsappy.Client(number=config.get('whatsapp', 'phone'), secret=b64decode(config.get('whatsapp', 'secret')))
                self.whatsapp.login()

                Helpers.error_and_whatsapp("WhatsApp connection established for `%s`" % socket.gethostname())

        def send(self, message):
            if self.whatsapp:
                try:
                    self.whatsapp.group_message(self.config.get('whatsapp', 'group_id'), message)
                except IOError:
{'fraction_non_alphanumeric': 0.09171890465193006, 'fraction_numerical': 0.00395908940943583, 'mean_word_length': 1.8576814326107445, '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': '607264', 'n_tokens_mistral': 841, 'n_tokens_neox': 772, 'n_words': 176}