<commit_before>#!/usr/bin/python2
# 
# test-messages.py - This script publish a random MQTT messages every 2 s.
#
# Copyright (c) 2013-2015, <NAME> <<EMAIL>>
# Released under the MIT license. See LICENSE file for details.
#
import random
import time
import mosquitto

timestamp = int(time.time())

broker = '127.0.0.1'
port = 1883
element = 'home'
areas = ['front', 'back', 'kitchen', 'basement', 'living']
entrances = ['door', 'window']
states = ['true', 'false']

print 'Messages are published on topic %s/#... -> CTRL + C to shutdown' \
    % element

while True:
    area = random.choice(areas)
    if (area in ['basement', 'living']):
        topic = element + '/' + area + '/temp'
        message = random.randrange(0, 30, 1)
    else:
        topic = element + '/' + area + '/' + random.choice(entrances)
        message = random.choice(states)

    client = mosquitto.Mosquitto("mqtt-panel-test")
    client.connect(broker)
    client.publish(topic, message)
    time.sleep(2)
<commit_msg>Switch to paho-mqtt and make ready for py3<commit_after>#!/usr/bin/python3
# 
# test-messages.py - This script publish a random MQTT messages every 2 s.
#
# Copyright (c) 2013-2016, <NAME> <<EMAIL>>
# Released under the MIT license. See LICENSE file for details.
#
import random
import time
import paho.mqtt.client as mqtt

timestamp = int(time.time())

broker = '127.0.0.1'
port = 1883
element = 'home'
areas = ['front', 'back', 'kitchen', 'basement', 'living']
entrances = ['door', 'window']
states = ['true', 'false']

print('Messages are published on topic %s/#... -> CTRL + C to shutdown' \
    % element)

while True:
    area = random.choice(areas)
    if (area in ['basement', 'living']):
        topic = element + '/' + area + '/temp'
        message = random.randrange(0, 30, 1)
    else:
        topic = element + '/' + area + '/' + random.choice(entrances)
        message = random.choice(states)

    mqttclient = mqtt.Client("mqtt-panel-test")
    mqttclient.connect(broker, port=int(port))
    mqttclient.publish(topic, message)
    time.sleep(2)


{'fraction_non_alphanumeric': 0.15970873786407766, 'fraction_numerical': 0.02475728155339806, 'mean_word_length': 3.29375, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1408205', 'n_tokens_mistral': 742, 'n_tokens_neox': 694, 'n_words': 199}