def start_server(self): os.chdir(os.path.join(self.webroot, "htdocs")) print_job_handler_class = get_print_job_hander(self.print_mgr) self.httpd = socketserver.TCPServer(("", self.port), print_job_handler_class) print("Daemon started on port : ", self.port) try: threading.Thread(target=self.run_server, args=()).start() except KeyboardInterrupt: print("Stopping....") self.httpd.server_close() finally: self.print_mgr.close_printer()
if (args.printer_port): print_mgr.set_printer_port(args.printer_port) print(print_mgr.get_config()) if (args.run_as_daemon): # daemon = PrintDaemon() print("****** Open Labels Daemon ******") print("Starting....") os.chdir( os.path.join(os.path.dirname(os.path.realpath('__file__')), "htdocs")) print_job_handler_class = get_print_job_hander(print_mgr) httpd = socketserver.TCPServer(("", 31173), print_job_handler_class) print("Daemon started on port : ", 31173) try: httpd.serve_forever() except KeyboardInterrupt: pass print("Stopping....") httpd.server_close() finally: print_mgr.close_printer() else: print_mgr.set_label_file(args.label_file) print_mgr.set_label_size(args.width_mm, args.height_mm)
print_mgr.set_print_options(args.labels_per_row, args.paper_width_mm,args.label_x_offset_mm,args.label_y_offset_mm) print_mgr.set_label_count(args.label_count) if(args.printer_port): print_mgr.set_printer_port(args.printer_port) print(print_mgr.get_config()) if(args.run_as_daemon): # daemon = PrintDaemon() print("****** Open Labels Daemon ******") print("Starting....") os.chdir(os.path.join(os.path.dirname(os.path.realpath('__file__')), "htdocs")) print_job_handler_class = get_print_job_hander(print_mgr) httpd = socketserver.TCPServer(("", 31173), print_job_handler_class) print("Daemon started on port : ", 31173) try: httpd.serve_forever() except KeyboardInterrupt: pass print("Stopping....") httpd.server_close() finally: print_mgr.close_printer() else: print_mgr.set_label_file(args.label_file) print_mgr.set_label_size(args.width_mm, args.height_mm)