forgot to push
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Socket server.
|
||||
"""
|
||||
|
||||
import socket
|
||||
import threading
|
||||
|
||||
HEADER = 64
|
||||
PORT = 5050
|
||||
SERVER = socket.gethostbyname(socket.gethostname())
|
||||
ADDR = (SERVER, PORT)
|
||||
FORMAT = 'utf-8'
|
||||
DISCONNECT_MESSAGE = '!DISCONNECT'
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
server.bind(ADDR)
|
||||
|
||||
def handle_client(conn, addr):
|
||||
"""Deal with one client."""
|
||||
print(f"[NEW CONNECTION] {addr} connected.")
|
||||
|
||||
while True:
|
||||
msg_length = conn.recv(HEADER).decode(FORMAT)
|
||||
msg_length = int(msg_length)
|
||||
msg = conn.recv(msg_length).decode(FORMAT)
|
||||
if msg == DISCONNECT_MESSAGE:
|
||||
break
|
||||
|
||||
print(f"[{addr}] {msg}")
|
||||
conn.close()
|
||||
|
||||
|
||||
|
||||
|
||||
def start():
|
||||
"""Start the server."""
|
||||
server.listen()
|
||||
while True:
|
||||
conn, addr = server.accept()
|
||||
thread = threading.Thread(target=handle_client, args=(conn, addr))
|
||||
thread.start()
|
||||
print(f"[ACTIVE CONNECTIONS] {threading.activeCount() - 1}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("[STARTING] server is starting ...")
|
||||
start()
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from rich import print
|
||||
|
||||
if not 'commands.yml' in os.listdir():
|
||||
print(f"File [bold]commands.yml[/bold] not found in \
|
||||
[bold]{os.getcwd()}[/bold]!")
|
||||
quit()
|
||||
|
||||
if len(sys.argv)==1:
|
||||
print("[bold]No command[\bold] given as input.")
|
||||
quit()
|
||||
|
||||
with open('commands.yml') as f:
|
||||
commands = yaml.load(f, Loader=yaml.FullLoader)
|
||||
|
||||
command = sys.argv[1]
|
||||
if not command in commands:
|
||||
print(f"Command [bold]{command}[\bold] does not exist.")
|
||||
quit()
|
||||
|
||||
code = commands[command]
|
||||
os.system(code)
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from pygame_geometry.context import Surface
|
||||
from pygame_geometry.curves import Trajectory, BezierCurve
|
||||
from pygame_geometry.abstract import Point
|
||||
from pygame_geometry import colors
|
||||
|
||||
import random
|
||||
|
||||
# create objects
|
||||
surface=Surface(name="Curves demonstration")
|
||||
l=10
|
||||
points=[Point(2*x,random.randint(-5,5)) for x in range(l)]
|
||||
t=Trajectory(points,segment_color=colors.GREEN)
|
||||
b=BezierCurve(points,segment_color=colors.RED)
|
||||
n=0
|
||||
ncp=50 #number construction points
|
||||
|
||||
while surface.open:
|
||||
# surface stuff
|
||||
surface.check()
|
||||
surface.clear()
|
||||
surface.control()
|
||||
surface.show() # show a math grid in background
|
||||
|
||||
# update
|
||||
Point.turnPoints([1/1000 for i in range(l)],points)
|
||||
n=(n+1)%(ncp+1)
|
||||
b.showConstruction(surface,n/ncp)
|
||||
p1=b(n/ncp)
|
||||
p2=Point(*t(n/ncp))
|
||||
|
||||
# show
|
||||
t.show(surface)
|
||||
b.show(surface)
|
||||
p1.show(surface,color=colors.YELLOW,radius=0.1,fill=True)
|
||||
p2.show(surface,color=colors.YELLOW,radius=0.1,fill=True)
|
||||
|
||||
# flip
|
||||
surface.flip()
|
||||
@@ -0,0 +1,37 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(['test_pygame_geometry.py'],
|
||||
pathex=['/Users/marcpartensky/Programs/Python/Repository-2020'],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='test_pygame_geometry',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False )
|
||||
app = BUNDLE(exe,
|
||||
name='test_pygame_geometry.app',
|
||||
icon=None,
|
||||
bundle_identifier=None)
|
||||
Reference in New Issue
Block a user