Cat-Printer
Cat-Printer copied to clipboard
TypeError: exceptions must derive from BaseException
Hi there, thanks for making this! I was hoping to use this project for some thermal printing, I was able to print a couple test prints (image and text), however then it kinda just... broke?
I'm no longer able to print anything anymore, every time I try to (image or text), it connects to the printer but all I get is an Exception:
Exception occurred during processing of request from ('127.0.0.1', 55465)
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\socketserver.py", line 317, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\socketserver.py", line 348, in process_request
self.finish_request(request, client_address)
File "C:\Users\user\Documents\dev\Cat-Printer\server.py", line 329, in finish_request
self.handler.__init__(request, client_address, self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\socketserver.py", line 755, in __init__
self.handle()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\http\server.py", line 436, in handle
self.handle_one_request()
File "C:\Users\user\Documents\dev\Cat-Printer\server.py", line 104, in handle_one_request
super().handle_one_request()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\http\server.py", line 424, in handle_one_request
method()
File "C:\Users\user\Documents\dev\Cat-Printer\server.py", line 271, in do_POST
self.handle_api()
File "C:\Users\user\Documents\dev\Cat-Printer\server.py", line 219, in handle_api
self.printer.print(io.BytesIO(body))
File "C:\Users\user\Documents\dev\Cat-Printer\printer.py", line 414, in print
self._print_bitmap(printer_data)
File "C:\Users\user\Documents\dev\Cat-Printer\printer.py", line 478, in _print_bitmap
self._prepare()
File "C:\Users\user\Documents\dev\Cat-Printer\printer.py", line 458, in _prepare
self.set_energy(self.energy)
File "C:\Users\user\Documents\dev\Cat-Printer\printer_lib\commander.py", line 149, in set_energy
self.send( self.make_command(0xaf, int_to_bytes(amount, length=2)) )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\Documents\dev\Cat-Printer\printer_lib\commander.py", line 55, in int_to_bytes
raise f'int_to_bytes: {i} > {max_value}'
TypeError: exceptions must derive from BaseException
----------------------------------------
Thanks in advance for taking a look