<commit_before>#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-

__author__ = "<NAME>"
__copyright__ = "Copyright (C) <NAME>"

import mosquitto
import os
import logging
import signal
import socket

import mosquitto
import ConfigParser

# Read the config file
config = ConfigParser.RawConfigParser()
config.read("/etc/mqtt-readmeter/mqtt-readmeter.cfg")

# Use ConfigParser to pick out the settings
DEBUG = config.getboolean("global", "debug")
LOGFILE = config.get("global", "logfile")
METERSOURCE = config.get("global", "metersource")
MQTT_HOST = config.get("global", "mqtt_host")
MQTT_PORT = config.get("global", "mqtt_host")

MQTT_TOPIC="/raw/" + socket.getfqdn() + config.get("global", "MQTT_SUBTOPIC")

client_id = "Readmeter_%d" % os.getpid()
mqttc = mosquitto.Mosquitto(client_id)

oldwatts = "0"

if DEBUG:
    logging.basicConfig(filename=LOGFILE, level=logging.INFO)
else:
    logging.basicConfig(filename=LOGFILE, level=logging.DEBUG)

logging.info('Starting mqtt-readmeter')
logging.info('INFO MODE')
logging.debug('DEBUG MODE')

def cleanup(signum, frame):
     """
     Signal handler to ensure we disconnect cleanly 
     in the event of a SIGTERM or SIGINT.
     """
     logging.info("Disconnecting from broker")
     mqttc.publish("/status/" + socket.getfqdn(), "Offline")
     mqttc.disconnect()
     logging.info("Exiting on signal %d", signum)<commit_msg>The port is an int, not a str<commit_after>#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-

__author__ = "<NAME>"
__copyright__ = "Copyright (C) <NAME>"

import mosquitto
import os
import logging
import signal
import socket

import mosquitto
import ConfigParser

# Read the config file
config = ConfigParser.RawConfigParser()
config.read("/etc/mqtt-readmeter/mqtt-readmeter.cfg")

# Use ConfigParser to pick out the settings
DEBUG = config.getboolean("global", "debug")
LOGFILE = config.get("global", "logfile")
METERSOURCE = config.get("global", "metersource")
MQTT_HOST = config.get("global", "mqtt_host")
MQTT_PORT = config.getint("global", "mqtt_port")

MQTT_TOPIC="/raw/" + socket.getfqdn() + config.get("global", "MQTT_SUBTOPIC")

client_id = "Readmeter_%d" % os.getpid()
mqttc = mosquitto.Mosquitto(client_id)

oldwatts = "0"

if DEBUG:
    logging.basicConfig(filename=LOGFILE, level=logging.INFO)
else:
    logging.basicConfig(filename=LOGFILE, level=logging.DEBUG)

logging.info('Starting mqtt-readmeter')
logging.info('INFO MODE')
logging.debug('DEBUG MODE')

def cleanup(signum, frame):
     """
     Signal handler to ensure we disconnect cleanly 
     in the event of a SIGTERM or SIGINT.
     """
     logging.info("Disconnecting from broker")
     mqttc.publish("/status/" + socket.getfqdn(), "Offline")
     mqttc.disconnect()
     logging.info("Exiting on signal %d", signum)
{'fraction_non_alphanumeric': 0.142445005409304, 'fraction_numerical': 0.00432744320230797, 'mean_word_length': 4.877118644067797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '64165', 'n_tokens_mistral': 976, 'n_tokens_neox': 934, 'n_words': 220}