text stringlengths 1 93.6k |
|---|
if "Please enter a different name." in response:
|
print(Fore.RED + response)
|
return False
|
self.username = username
|
print(Fore.BLUE + "Help Menu:")
|
print("\t/help -> Help menu")
|
return True
|
def listen_to_server(self):
|
while True:
|
data = self.client_socket.recv(1024).decode('utf-8')
|
if not data:
|
break
|
if data.strip() == "/clear":
|
os.system('cls' if os.name == 'nt' else 'clear')
|
print(f"{Fore.GREEN}\n\t/help -> Help menu\n{Style.RESET_ALL}{self.username}:{Fore.YELLOW} Enter your message: {Style.RESET_ALL}",end='')
|
continue
|
with self.message_lock:
|
if "Username changed to " in data:
|
self.username = data.split("Username changed to ")[1].rstrip(".")
|
print(f"{Fore.GREEN}\n{data}\n{Style.RESET_ALL}{self.username}:{Fore.YELLOW} Enter your message: {Style.RESET_ALL}", end='')
|
else:
|
print(f"{Fore.GREEN}\n{data}\n{Style.RESET_ALL}{self.username}:{Fore.YELLOW} Enter your message: {Style.RESET_ALL}", end='')
|
def send_messages(self):
|
while True:
|
try:
|
print(f"{self.username}: {Fore.YELLOW}Enter your message: {Style.RESET_ALL}", end='')
|
message = input()
|
if message == "/exit":
|
self.client_socket.send(message.encode('utf-8'))
|
break
|
self.client_socket.send(message.encode('utf-8'))
|
except ConnectionRefusedError as e:
|
if e.errno == 111:
|
print("Connection refused")
|
else:
|
print(f"An unknown error occurred {e}")
|
except KeyboardInterrupt:
|
print(Fore.RED + "\nClosing connection...")
|
self.client_socket.send("/exit".encode('utf-8'))
|
break
|
def run(self):
|
if self.connect():
|
if self.get_username():
|
threading.Thread(target=self.listen_to_server, daemon=True).start()
|
self.send_messages()
|
self.client_socket.close()
|
if __name__ == "__main__":
|
parser = argparse.ArgumentParser(description="Connect to the chat server.")
|
parser.add_argument("--host", default="127.0.0.1", help="The server's IP address.")
|
parser.add_argument("--port", type=int, default=12345, help="The port number of the server.")
|
args = parser.parse_args()
|
client = ChatClient(args.host, args.port)
|
client.run()
|
# <FILESEP>
|
import streamlit as st
|
import numpy as np
|
import pandas as pd
|
import plost
|
st.set_page_config(page_title='Plost', page_icon=':tomato:')
|
"""
|
# 🍅 Plost
|
A deceptively simple plotting library for [Streamlit](https://github.com/streamlit/streamlit).
|
_“Because you've been writing plots wrong all this time”_
|
Below you'll find documentation and live examples showing how to use Plost. Of course,
|
the first step is:
|
```
|
pip install streamlit
|
pip install plost
|
```
|
---
|
## Intro
|
Plost makes it easy to build common plots using the
|
[Vega-Lite](https://vega.github.io/vega-lite/)
|
library but without having to delve into Vega-Lite specs (unless you're doing
|
something tricky), and without having to melt your DataFrame from long format to wide
|
format (the bane of most Vega-Lite plots!)
|
For example, let's say you have a "long-format" table like this:
|
| time | stock_name | stock_value |
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.