<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import zmq
import json
import uuid
import logging

logger = logging.getLogger("zmq");
logger.setLevel(logging.DEBUG)


def main():
    logger.debug("main");
    context = zmq.Context()

    reqs = context.socket(zmq.REQ)
    reqs.connect("tcp://localhost:5555")

    subs = context.socket(zmq.SUB)
    subs.connect("tcp://localhost:5556")
    subs.setsockopt(zmq.SUBSCRIBE, "")

    uid = gen_uuid()
    logger.info("uid:%s" % uid)

    request = {}
    request['type'] = "REG"
    request['uuid'] = uid
    reqs.send(json.dumps(request))

    response = reqs.recv()
    logger.debug("response:%s" % response);

    #poller = zmq.Poller()
    #poller.register(reqs, zmq.POLLIN)
    #poller.register(subs, zmq.POLLIN)

    while True:
        handle(subs.recv())

    reqs.close()
    subs.close()

def handle(message):
    logger.debug("handle message:%s" % message);
    pass

def gen_uuid():
    if os.path.isfile('rasp.conf'):
        with open('rasp.conf', 'r') as f:
            cache = json.load(f)
            uid = cache['uuid']
    else:
        uid = uuid.uuid1()
        cache = {}
        cache['uuid'] = str(uid)
        with open('rasp.conf', 'w') as f:<commit_msg>Fix first run rasp will try send the UUID object, not strinize it correctly<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import zmq
import json
import uuid
import logging

logger = logging.getLogger("zmq");
logger.setLevel(logging.DEBUG)


def main():
    logger.debug("main");
    context = zmq.Context()

    reqs = context.socket(zmq.REQ)
    reqs.connect("tcp://localhost:5555")

    subs = context.socket(zmq.SUB)
    subs.connect("tcp://localhost:5556")
    subs.setsockopt(zmq.SUBSCRIBE, "")

    uid = gen_uuid()
    logger.info("uid:%s" % uid)

    request = {}
    request['type'] = "REG"
    request['uuid'] = uid
    reqs.send(json.dumps(request))

    response = reqs.recv()
    logger.debug("response:%s" % response);

    #poller = zmq.Poller()
    #poller.register(reqs, zmq.POLLIN)
    #poller.register(subs, zmq.POLLIN)

    while True:
        handle(subs.recv())

    reqs.close()
    subs.close()

def handle(message):
    logger.debug("handle message:%s" % message);
    pass

def gen_uuid():
    if os.path.isfile('rasp.conf'):
        with open('rasp.conf', 'r') as f:
            cache = json.load(f)
            uid = cache['uuid']
    else:
        uid = str(uuid.uuid1())
        cache = {}
        cache['uuid'] = uid
        with open('rasp.conf', 'w') as f:
{'fraction_non_alphanumeric': 0.16718386346004654, 'fraction_numerical': 0.007757951900698216, 'mean_word_length': 2.7161383285302594, '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': '7270103', 'n_tokens_mistral': 924, 'n_tokens_neox': 906, 'n_words': 182}