<commit_before>#!/usr/bin/env python3


import json, collections
import sys
import datetime
import uuid


class Publisher:

    def __init__(self, session=None):
        """
        """
        print(datetime.datetime.now(),' - labware_publisher.__init__:')
        print('\targs:',locals())
        
        self.topic = {
            'frontend' : 'com.opentrons.frontend',
            'driver' : 'com.opentrons.driver',
            'labware' : 'com.opentrons.labware',
            'bootstrapper' : 'com.opentrons.bootstrapper'
        }

        self.clients = {
            # uuid : 'com.opentrons.[uuid]'
        }
        self.max_clients = 4

        self.id = str(uuid.uuid4())

        self.caller = None

        if session is not None:
            self.caller = session


    def handshake(self, data):
        print(datetime.datetime.now(),' - labware_publisher.handshake:')
        print('\tdata: ',data)
    
        data_dict = json.loads(data)
        if isinstance(data_dict, dict):
            if 'from' in data:
                print('* data has "from"')
                client_id = data_dict['from']
                print('client_id: ',client_id)
                if client_id in self.clients:
                    print('* from is a client')
                    if 'data' in data_dict:
                        if 'message' in data_dict['data']:
                            if 'extend' in data_dict['data']['message']:
                                print('handshake called again on client ',client_id,'. We could have done something here to repopulate data')
                                self.publish( client_id , client_id , client_id ,'handshake','labware','result','already_connected')
                            if 'shake' in data_dict['data']['message']:
                                self.publish_client_ids(client_id)<commit_msg>data flow from_,session_id<commit_after>#!/usr/bin/env python3


import json, collections
import sys
import datetime
import uuid


class Publisher:

    def __init__(self, session=None):
        """
        """
        print(datetime.datetime.now(),' - labware_publisher.__init__:')
        print('\targs:',locals())
        
        self.topic = {
            'frontend' : 'com.opentrons.frontend',
            'driver' : 'com.opentrons.driver',
            'labware' : 'com.opentrons.labware',
            'bootstrapper' : 'com.opentrons.bootstrapper'
        }

        self.clients = {
            # uuid : 'com.opentrons.[uuid]'
        }
        self.max_clients = 4

        self.id = str(uuid.uuid4())

        self.caller = None

        if session is not None:
            self.caller = session


    def handshake(self, data):
        print(datetime.datetime.now(),' - labware_publisher.handshake:')
        print('\tdata: ',data)
    
        data_dict = json.loads(data)
        if isinstance(data_dict, dict):
            if 'from' in data:
                print('* data has "from"')
                client_id = data_dict['from']
                print('client_id: ',client_id)
                if client_id in self.clients:
                    print('* from is a client')
                    if 'data' in data_dict:
                        if 'message' in data_dict['data']:
                            if 'extend' in data_dict['data']['message']:
                                print('handshake called again on client ',client_id,'. We could have done something here to repopulate data')
                                self.publish( client_id , client_id , client_id ,'handshake','labware','result','already_connected')
                            if 'shake' in data_dict['data']['message']:
                                self.publish_client_ids(client_id,client_id)
{'fraction_non_alphanumeric': 0.11962616822429907, 'fraction_numerical': 0.0016021361815754338, 'mean_word_length': 1.681460272011453, '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': '2184035', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1039, 'n_words': 229}