Ejemplo n.º 1
0
    def _raw(self, txt):
        """ send raw text to the server. """

        if not txt:
            return

        rlog(2, self.name + '.sending', txt)

        try:
            self.lastoutput = time.time()
            itxt = toenc(outputmorphs.do(txt), self.encoding)
            if self.ssl:
                self.sock.write(itxt + '\n')
            else:
                self.sock.send(itxt[:500] + '\n')
        except Exception, ex:
            # check for broken pipe error .. if so ignore
            # used for nonblocking sockets
            try:
                (errno, errstr) = ex
                if errno != 32 and errno != 9:
                    raise
                else:
                    rlog(10, self.name,
                         'broken pipe/bad socket  error .. ignoring')
            except:
                rlog(10, self.name, "ERROR: can't send %s" % str(ex))
                self.reconnect()
Ejemplo n.º 2
0
    def send(self, what):
        """ send stanza to the server. """

        if self.stopped:
            return
        self.outqueue.put(toenc(what))
        jabbermonitor.put(self, unicode(what))
Ejemplo n.º 3
0
    def send(self, txt):
        """ send text to irc server. """

        if not txt:
            return

        if self.stopped:
            return

        try:
            self.outputlock.acquire()
            now = time.time()
            timetosleep = 4 - (now - self.lastoutput)
            if timetosleep > 0 and not self.nolimiter:
                rlog(0, self.name, 'flood protect')
                time.sleep(timetosleep)
            txt = toenc(strippedtxt(txt))
            txt = txt.rstrip()
            self._raw(txt)
            try:
                self.outputlock.release()
            except:
                pass
            self.lastoutput = time.time()
        except Exception, ex:
            try:
                self.outputlock.release()
            except:
                pass
            if not self.blocking and 'broken pipe' in str(ex).lower():
                rlog(11, self.name, 'broken pipe error .. ignoring')
            else:
                rlog(11, self.name, 'send error: %s' % str(ex))
                self.reconnect()
                return
Ejemplo n.º 4
0
    def _raw(self, txt):
 
        """ send raw text to the server. """

        if not txt:
            return

        rlog(2, self.name + '.sending', txt)

        try:
            self.lastoutput = time.time()
            itxt = toenc(outputmorphs.do(txt), self.encoding)
            if self.ssl:
                self.sock.write(itxt + '\n')
            else:
                self.sock.send(itxt[:500] + '\n')
        except Exception, ex:
            # check for broken pipe error .. if so ignore 
            # used for nonblocking sockets
            try:
                (errno, errstr) = ex
                if errno != 32 and errno != 9:
                    raise
                else:
                    rlog(10, self.name, 'broken pipe/bad socket  error .. ignoring')
            except:
                rlog(10, self.name, "ERROR: can't send %s" % str(ex))
                self.reconnect()
Ejemplo n.º 5
0
    def sendnocb(self, what):

        """ send to server without calling callbacks/monitors """

        if self.stopped:
            return
        self.outqueue.put(toenc(what))
Ejemplo n.º 6
0
    def send(self, what):

        """ send stanza to the server. """

        if self.stopped:
           return
        self.outqueue.put(toenc(what))
        jabbermonitor.put(self, unicode(what))
Ejemplo n.º 7
0
    def out(self, printto, what, who=None, how='msg', fromm=None, speed=5):
        """ output the first 375 chars .. put the rest into cache. """

        # convert the data to the encoding
        try:
            what = toenc(what.rstrip())
        except Exception, ex:
            rlog(10, self.name, "can't output: %s" % str(ex))
            return
Ejemplo n.º 8
0
    def out(self, printto, what, who=None, how='msg', fromm=None, speed=5):

        """ output the first 375 chars .. put the rest into cache. """

        # convert the data to the encoding
        try:
            what = toenc(what.rstrip())
        except Exception, ex:
            rlog(10, self.name, "can't output: %s" % str(ex))
            return
Ejemplo n.º 9
0
    def send(self, txt):

        """ send text to irc server. """

        if not txt:
            return

        if self.stopped:
            return

        try:
            self.outputlock.acquire()
            now = time.time()
            timetosleep = 4 - (now - self.lastoutput)
            if timetosleep > 0 and not self.nolimiter:
                rlog(0, self.name, 'flood protect')
                time.sleep(timetosleep)
            txt = toenc(strippedtxt(txt))
            txt = txt.rstrip()
            self._raw(txt)
            try:
                self.outputlock.release()
            except:
                pass
            self.lastoutput = time.time()
        except Exception, ex:
            try:
                self.outputlock.release()
            except:
                pass
            if not self.blocking and 'broken pipe' in str(ex).lower():
                rlog(11, self.name, 'broken pipe error .. ignoring')
            else:
                rlog(11, self.name, 'send error: %s' % str(ex))
                self.reconnect()
                return
Ejemplo n.º 10
0
    def sendnocb(self, what):
        """ send to server without calling callbacks/monitors """

        if self.stopped:
            return
        self.outqueue.put(toenc(what))