コード例 #1
0
                    valid_traceback = getattr(e, 'traceback', sys.exc_info())
                    formatted_traceback = "".join(
                        traceback.format_exception(*valid_traceback))
                    _logger.debug("netrpc: communication-level exception",
                                  exc_info=True)
                    ts.mysend(valid_exception,
                              exception=True,
                              traceback=formatted_traceback)
                    break
                except Exception, ex:
                    #terminate this channel if we can't properly send back the error
                    _logger.exception(
                        "netrpc: cannot deliver exception message to client")
                    break

        netsvc.close_socket(self.sock)
        self.sock = None
        self.threads.remove(self)
        self.running = False
        return True

    def stop(self):
        self.running = False


def netrpc_handle_exception_legacy(e):
    if isinstance(e, openerp.osv.osv.except_osv):
        return 'warning -- ' + e.name + '\n\n' + e.value
    if isinstance(e, openerp.exceptions.Warning):
        return 'warning -- Warning\n\n' + str(e)
    if isinstance(e, openerp.exceptions.AccessError):
コード例 #2
0
 def disconnect(self):
     netsvc.close_socket(self.sock)
コード例 #3
0
 def _close_socket(self):
     netsvc.close_socket(self.socket)
コード例 #4
0
                #terminate this channel because other endpoint is gone
                break
            except Exception, e:
                try:
                    valid_exception = Exception(netrpc_handle_exception_legacy(e)) 
                    valid_traceback = getattr(e, 'traceback', sys.exc_info())
                    formatted_traceback = "".join(traceback.format_exception(*valid_traceback))
                    _logger.debug("netrpc: communication-level exception", exc_info=True)
                    ts.mysend(valid_exception, exception=True, traceback=formatted_traceback)
                    break
                except Exception, ex:
                    #terminate this channel if we can't properly send back the error
                    _logger.exception("netrpc: cannot deliver exception message to client")
                    break

        netsvc.close_socket(self.sock)
        self.sock = None
        self.threads.remove(self)
        self.running = False
        return True

    def stop(self):
        self.running = False
        
def netrpc_handle_exception_legacy(e):
    if isinstance(e, openerp.osv.osv.except_osv):
        return 'warning -- ' + e.name + '\n\n' + e.value
    if isinstance(e, openerp.exceptions.Warning):
        return 'warning -- Warning\n\n' + str(e)
    if isinstance(e, openerp.exceptions.AccessError):
        return 'warning -- AccessError\n\n' + str(e)
コード例 #5
0
 def _close_socket(self):
     netsvc.close_socket(self.socket)