def connect(self): config = self.config self.device_path = config.port try: #: Save a reference self.protocol.transport = self #: Make the wrapper self._protocol = RawFdProtocol(self, self.protocol) self.connection = SerialPort( self._protocol, config.port, reactor, baudrate=config.baudrate, bytesize=config.bytesize, parity=SERIAL_PARITIES[config.parity], stopbits=config.stopbits, xonxoff=config.xonxoff, rtscts=config.rtscts ) log.debug("{} | opened".format(config.port)) except Exception as e: #: Make sure to log any issues as these tracebacks can get #: squashed by twisted log.error("{} | {}".format(config.port, traceback.format_exc())) raise
def connect(self): config = self.config self.device_path = config.port try: #: Save a reference self.protocol.transport = self #: Make the wrapper self._protocol = RawFdProtocol(self, self.protocol) self.connection = SerialPort(self._protocol, config.port, reactor, baudrate=config.baudrate, bytesize=config.bytesize, parity=SERIAL_PARITIES[config.parity], stopbits=config.stopbits, xonxoff=config.xonxoff, rtscts=config.rtscts) # Twisted is missing this if config.dsrdtr: try: self.connection._serial.dsrdtr = True except AttributeError as e: log.warning("{} | dsrdtr is not supported {}".format( config.port, e)) log.debug("{} | opened".format(config.port)) except Exception as e: #: Make sure to log any issues as these tracebacks can get #: squashed by twisted log.error("{} | {}".format(config.port, traceback.format_exc())) raise
def connect(self): try: config = self.config #: Save a reference self.protocol.transport = self #: Make the wrapper self._protocol = InkcutProtocol(self, self.protocol) self.connection = SerialPort( self._protocol, config.port, reactor, baudrate=config.baudrate, bytesize=config.bytesize, parity=SERIAL_PARITIES[config.parity], stopbits=config.stopbits, xonxoff=config.xonxoff, rtscts=config.rtscts ) log.debug("{} | opened".format(self.config.port)) except Exception as e: #: Make sure to log any issues as these tracebacks can get #: squashed by twisted log.error("{} | {}".format( self.config.port, traceback.format_exc() )) raise
def set_window_icon(self): """ Set the main application window icon """ ui = self.workbench.get_plugin('enaml.workbench.ui') try: icon = get_cached_qicon(load_icon('logo')) ui.window.proxy.widget.setWindowIcon(icon) except Exception as e: log.error('Failed to set window icon: {}'.format(e))
def set_window_icon(self): """ Set the main application window icon """ ui = self.workbench.get_plugin('enaml.workbench.ui') try: icon = get_cached_qicon(load_icon('logo')) ui.window.proxy.widget.setWindowIcon(icon) except Exception as e: log.error('Failed to set window icon: {}'.format(e))
def set_app_name(self): """ Set the application name """ ui = self.workbench.get_plugin('enaml.workbench.ui') try: qt_app = ui._application._qapp qt_app.setApplicationName('inkcut') if hasattr(qt_app, 'setApplicationDisplayName'): qt_app.setApplicationDisplayName('Inkcut') except Exception as e: log.error('Failed to set app name: {}'.format(e))
def connect(self): try: #: Save a reference self.protocol.transport = self self.connection.transport = self self.connection.open() log.debug("{} | opened".format(self.config.printer)) except Exception as e: #: Make sure to log any issues as these tracebacks can get #: squashed by twisted log.error("{} | {}".format( self.config.printer, traceback.format_exc() )) raise
def open_serial_port(self, config): try: serial_port = QSerialPort() serial_port.setPortName(config.port) #Setting the AllDirections flag is supported on all platforms. Windows supports only this mode. serial_port.setBaudRate(config.baudrate, QSerialPort.AllDirections) serial_port.setParity(config.parity) serial_port.setStopBits(config.stopbits) serial_port.setDataBits(config.bytesize) serial_port.setFlowControl(config.flowcontrol) serial_port.open(QSerialPort.ReadWrite) return serial_port except Exception as e: log.error("{}".format(traceback.format_exc())) return None
def connect(self): try: # Always create a new connection self.connection = self._default_connection() # Save a reference self.protocol.transport = self self.connection.transport = self self.connection.open() log.debug("{} | opened".format(self.config.printer)) except Exception as e: # Make sure to log any issues as these tracebacks can get # squashed by twisted log.error("{} | {}".format( self.config.printer, traceback.format_exc() )) raise
def connect(self): config = self.config #self.device_path = config.port device_path = self.device_path = config.port try: #: Save a reference self.protocol.transport = self self.connection = self.open_serial_port(config) self.connected = True log.debug("{} | opened".format(config.port)) self.protocol.connection_made() except Exception as e: #: Make sure to log any issues log.error("{} | {}".format(config.port, traceback.format_exc())) raise
def start_default_workspace(self): try: ui = self.workbench.get_plugin('enaml.workbench.ui') ui.select_workspace('inkcut.workspace') except SystemExit: raise except: log.error(traceback.format_exc()) tb = traceback.format_exc().split("\n") msg = "\n".join(tb[max(-len(tb), -11):]) self.workbench.message_critical( "Workspace startup error", "An error prevented startup. This is either a bug or a " "required library is missing on your system. " "\n\n{}\n\n" "Please report this issue or request help at " "https://github.com/codelv/inkcut ".format(msg.strip())) raise
def connect(self): config = self.config device_path = self.device_path = config.device_path if 'win32' in sys.platform: # Well, technically it works, but only with stdin and stdout raise OSError("Raw device support cannot be used on Windows") try: self.fd = open(device_path, config.mode) fd = self.fd.fileno() log.debug("-- {} | opened".format(device_path)) self._protocol = RawFdProtocol(self, self.protocol) self.connection = stdio.StandardIO(self._protocol, fd, fd) except Exception as e: #: Make sure to log any issues as these tracebacks can get #: squashed by twisted log.error("{} | {}".format(device_path, traceback.format_exc())) raise
def start_default_workspace(self): try: ui = self.workbench.get_plugin('enaml.workbench.ui') ui.select_workspace('inkcut.workspace') except SystemExit: raise except: log.error(traceback.format_exc()) tb = traceback.format_exc().split("\n") msg = "\n".join(tb[max(-len(tb), -11):]) config_dir = os.path.dirname(self._state_file) log_dir = os.path.join(config_dir, 'logs') self.workbench.message_critical( "Workspace startup error", ERROR_TEMPLATE.format(config_dir=config_dir, error=msg.strip(), log_dir=log_dir)) raise
def start_default_workspace(self): try: ui = self.workbench.get_plugin('enaml.workbench.ui') ui.select_workspace('inkcut.workspace') except SystemExit: raise except: log.error(traceback.format_exc()) tb = traceback.format_exc().split("\n") msg = "\n".join(tb[max(-len(tb), -11):]) config_dir = os.path.dirname(self._state_file) log_dir = os.path.join(config_dir, 'logs') self.workbench.message_critical( "Workspace startup error", ERROR_TEMPLATE.format(config_dir=config_dir, error=msg.strip(), log_dir=log_dir)) raise
from atom.atom import set_default from atom.api import List, Instance, Unicode from inkcut.core.api import Plugin, Model, log from inkcut.device.plugin import DeviceTransport from twisted.internet import reactor from twisted.internet.protocol import ProcessProtocol try: if sys.platform == 'win32': import win32print else: import cups PRINTER_AVAILABLE = True except ImportError as e: log.error(e) PRINTER_AVAILABLE = False # ----------------------------------------------------------------------------- # Abstract API # ----------------------------------------------------------------------------- class PrinterConfig(Model): #: Available printers printers = List() #: Serial port config printer = Unicode().tag(config=True) # ------------------------------------------------------------------------- # Defaults
from atom.atom import set_default from atom.api import List, Instance, Unicode from inkcut.core.api import Plugin, Model, log from inkcut.device.plugin import DeviceTransport from twisted.internet import reactor from twisted.internet.protocol import ProcessProtocol try: if sys.platform == 'win32': import win32print else: import cups PRINTER_AVAILABLE = True except ImportError as e: log.error(e) PRINTER_AVAILABLE = False # ----------------------------------------------------------------------------- # Abstract API # ----------------------------------------------------------------------------- class PrinterConfig(Model): #: Available printers printers = List() #: Serial port config printer = Unicode().tag(config=True) # ------------------------------------------------------------------------- # Defaults # -------------------------------------------------------------------------