~aleteoryx/employ

57dcb401decae30d53b57a01440e08a36127caa4 — Aleteoryx 8 days ago c336b37
hopefully the final unfuck to employee's networking
2 files changed, 18 insertions(+), 14 deletions(-)

M employee.py
M queuers/reenc.py
M employee.py => employee.py +15 -11
@@ 42,7 42,6 @@ co_lock = asyncio.Lock()
class JobError(Exception):
	pass
async def send_cmd(reader, writer, cmd):

	global co_lock

	async def impl():


@@ 50,13 49,11 @@ async def send_cmd(reader, writer, cmd):

		async with co_lock:
			writer.write(cmd.encode()+b'\n')
			print(cmd)
			await writer.drain()
			while True:
				line = (await reader.readline()).rstrip()
				print(line)
				if line == b'?':
					raise JobError(cmd)
					raise JobError(f'{cmd} {lines}')
				elif line == b'OKAY':
					return lines
				else:


@@ 66,6 63,8 @@ async def send_cmd(reader, writer, cmd):


async def take_job(reader, writer):
	global co_lock

	l = logging.getLogger('employee.job')

	while True:


@@ 82,14 81,17 @@ async def take_job(reader, writer):

	l.info(f'took job {jid}')

	writer.write(b'SCRIPT IS\n')
	await writer.drain()
	async with co_lock:
		writer.write(b'SCRIPT IS\n')
		await writer.drain()

	line = (await reader.readline()).strip()
	length = int(line.decode())
	script = await reader.readexactly(length)
	
	await reader.readline()
		line = (await reader.readline()).strip()
		if line == b'?':
			raise JobError('SCRIPT IS')
		length = int(line.decode())
		script = await reader.readexactly(length)
		
		await reader.readline()

	return script



@@ 181,6 183,8 @@ async def main():
	l.info(f'connected!')
	
	while True:
		try:
			
		script = await take_job(reader, writer)
		await run_script(reader, writer, script)
		

M queuers/reenc.py => queuers/reenc.py +3 -3
@@ 26,8 26,8 @@ from typing import Optional
from os import system
import socket

RESOLUTIONS=[(1280, 720), (1366, 768), (1920, 1080)]
#RESOLUTIONS=[(710, 480), (1136, 768)]
#RESOLUTIONS=[(1280, 720), (1366, 768), (1920, 1080)]
RESOLUTIONS=[(710, 480), (1136, 768)]

argv0 = 'reenc.py'



@@ 41,7 41,7 @@ class JobError(Exception):
def send_cmd(reader, writer, cmd):
	lines = []

	writer.write(cmd.encode()+b'\n')
	writer.write(cmd+'\n')
	writer.flush()
	while True:
		line = reader.readline()