''' Created on 19 mar 2020 @author: Emanuele Trabattoni ''' import queue, sys, time, socket, logging SOCK_TIMEOUT = 2 def tsc_printer(q_in: queue.Queue, q_out: queue.Queue, q_cmd: queue.Queue, ip: str, port: int, logger: logging.getLogger): def riconnetti_socket(): pass def invia_file(): pass def elimina_file(): pass def muovi_file(): pass while True: # connetti mantieni vivo il socket try: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as prt: prt.create_connection(address=(ip, port), timeout=SOCK_TIMEOUT) while True: itm = q_in.get(block=True) cmd = itm['name'] par = itm['parameters'] if cmd == 'DOWNLOAD': pass elif cmd == 'REMOVE': pass elif cmd == 'MOVE': pass elif cmd == 'LIST': pass elif cmd == 'RUN': pass else: logger.error("Comando stampante non riconosciuto") except socket.timeout as st: logger.error(f"Stampante {__name__} irraggiungibile:{st}") prt.close() del prt except Exception as e: logger.error("Errore generale inizializzando la stampante: {}".format(e)) pass