<commit_before>#!/usr/bin/env python3
# echo.py
# author: <NAME>
# Modified by: <NAME> & <NAME>
# version: March 23, 2017

import socket
import sys

SERVERADDRESS = (socket.gethostname(), 6000)
Clientlist=[]

class EchoServer():
    def __init__(self):
        self.__s = socket.socket()
        self.__s.bind(SERVERADDRESS)
        print('You can now launch the chat script.')        

    def run(self):
        self.__s.listen(0)
        while True:
            client, addr = self.__s.accept()
            try:
                user = self._receive(client).decode().rstrip()
                if ":list:" in user:
                    global ADDRESS
                    ADDRESS = str(user.rsplit(':')[2])
                    self._send()
                if user not in Clientlist and ":list:" not in user :
                     Clientlist.append(user)
                client.close()
            except OSError:
                print('Error while receiving message.')

    def _receive(self, client):
        chunks = []
        finished = False
        while not finished:
            data = client.recv(1024)
            chunks.append(data)
            finished = data == b''
        return b''.join(chunks)

    def _send(self):
        totalsent = 0
        if len(Clientlist)==0:
            msg = '0 User Online.'
        else:
            msg = 'Online Users:\n'
        for i in Clientlist:
            msg += i + '\n'

        t=socket.socket(type=socket.SOCK_DGRAM)
        t.bind(SERVERADDRESS)
        
        n=ADDRESS[1:][:-1]
        Ip=n.split(',')[0][1:][:-1]
        Port=int(n.split(',')[1])
        try:
            while totalsent < len(msg):
                sent = t.sendto(msg[totalsent:].encode(), (Ip, Port))
                totalsent += sent
            t.close()
        except OSError:
            print('Error while sending message.')
            t.close()

EchoServer().run()<commit_msg>Update echo.py<commit_after>#!/usr/bin/env python3
# echo.py
# author: <NAME>
# Modified by: <NAME> & <NAME>
# version: March 30, 2017

import socket
import sys

SERVERADDRESS = (socket.gethostname(), 6000)
Clientlist=[]

class EchoServer():
    def __init__(self):
        self.__s = socket.socket()
        self.__s.bind(SERVERADDRESS)
        print('You can now launch the chat script.')        

    def run(self):
        self.__s.listen(0)
        while True:
            client, addr = self.__s.accept()
            try:
                user = self._receive(client).decode().rstrip()
                if ":list:" in user:
                    ADDRESS = user.rsplit(':')[2]
                    self._send(ADDRESS)
                if user not in Clientlist and ":list:" not in user :
                     Clientlist.append(user)
                client.close()
            except OSError:
                print('Error while receiving message.')

    def _receive(self, client):
        chunks = []
        finished = False
        while not finished:
            data = client.recv(1024)
            chunks.append(data)
            finished = data == b''
        return b''.join(chunks)

    def _send(self, address):
        totalsent = 0
        if len(Clientlist)==0:
            msg = '0 User Online.'
        else:
            msg = 'Online Users:\n'
        for i in Clientlist:
            msg += i + '\n'

        t=socket.socket(type=socket.SOCK_DGRAM)
        t.bind(SERVERADDRESS)
        
        n=address[1:][:-1]
        Ip=n.split(',')[0][1:][:-1]
        Port=int(n.split(',')[1])
        try:
            while totalsent < len(msg):
                sent = t.sendto(msg[totalsent:].encode(), (Ip, Port))
                totalsent += sent
            t.close()
        except OSError:
            print('Error while sending message.')
            t.close()

EchoServer().run()
{'fraction_non_alphanumeric': 0.13067436368407243, 'fraction_numerical': 0.013644712673838887, 'mean_word_length': 1.572199730094467, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 9, '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': '6495959', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1101, 'n_words': 269}