~aleteoryx/employ

ad29286e5e2b95b89139325d63d079d211ee44bc — Aleteoryx 9 days ago 03f38b6
taken.py
2 files changed, 68 insertions(+), 0 deletions(-)

A COPYING
A taken.py
A COPYING => COPYING +16 -0
@@ 0,0 1,16 @@
this software distributed under a "fuck around, find out" license. the
author gives nobody in the world any explicit legal right to use this
code for any purpose whatsoever. the author reserves the right to send
holy legal fury down from the heavens should you invoke her ire.

the author does not have the money to do so, in any juris diction
worldwide. the author is also prety chill, she thinks, so, you know, do
what you want or whatever. the text of this license is intentionally
god damn stupid specifically to scare away corporate lawyers and
attract internet queers

if you do choose to redistribute this software (to "fuck around", as it
were), you should change this disclaimer some and make it funnier

the mitochondrea is the powerhouse of the cell


A taken.py => taken.py +52 -0
@@ 0,0 1,52 @@
#!/bin/env python3

import socket
from sys import argv, stderr, exit

argv0 = 'taken.py'

def usage():
	global argv0
	print(f'usage: {argv0} <host> <port>', file=stderr)
	exit(-1)

def send_cmd(reader, writer, cmd):
	lines = []

	writer.write(cmd.encode()+b'\n')
	writer.flush()
	while True:
		line = reader.readline()
		if line == b'?\n':
			raise Exception('bad cmd')
		elif line == b'OKAY\n':
			return lines
		else:
			lines.append(line.decode().strip())


if len(argv) > 0:
	argv0 = argv[0]
	argv = argv[1:]
if len(argv) != 2:
	usage()
host, port = argv

sok = socket.create_connection((host, port))
reader, writer = sok.makefile('rb'), sok.makefile('wb')

taken = send_cmd(reader, writer, 'list taken jobs')
for job in taken:
	jid = job.split('\t',1)[0]

	print(f'job {jid}:')

	info = send_cmd(reader, writer, f'info for job {jid} is')
	for line in info:
		print(f'\t{line}')
	print()

	meta = send_cmd(reader, writer, 'meta is')
	for line in meta:
		print(f'\t{line}')
	print()