コード例 #1
0
ファイル: emailaccount.py プロジェクト: AlexUlrich/digsby
    def on_error(self, task=None):
        '''
        Called when an error occurs. task is a callable that can be used to make another attempt
        at whatever caused the error (if error_count is less than max_error).
        '''
        self.error_count += 1

        log.error('%r\'s error count is now: %d',self, self.error_count)
        log.error('on_error called from %s', get_func_name(2))

        if self.error_count < pref('email.err_max_tolerance', self.error_max):
            if task is None:
                task = self.update_now
            log.error('error count is under, calling %r now', task)

            if not callable(task):
                # If it was an exception assume that update_now was called. (the account type
                # probably just hasn't been fixed yet
                task = self.update_now
            util.call_later(pref('email.err_retry_time', type=int, default=2), task)
        else:
            log.error('assuming the connection has died')
            self.set_offline(self.Reasons.CONN_FAIL)
            self.error_count = 0

        del self.emails[:]
コード例 #2
0
ファイル: emailaccount.py プロジェクト: sgricci/digsby
    def update(self):
        # Protocols must override this method to check for new messages.
        if self.update == EmailAccount.update:
            log.warning('not implemented: %s.update', self.__class__.__name__)
            raise NotImplementedError

        if not self.enabled:
            return

        log.info('%s (%s) -- preparing for update. update called from: %s',
                 self, self.state, get_func_name(2))

        if self.state == self.Statuses.OFFLINE:
            # First check -- either after creation or failing to connect for some reason
            self.change_state(self.Statuses.CONNECTING)
        elif self.state == self.Statuses.ONLINE:
            # A follow-up check.
            self.change_state(self.Statuses.CHECKING)
        elif self.state == self.Statuses.CONNECTING:
            # Already connecting -- if there have been errors this is just the Nth attempt.
            # if there are not errors, something is wrong! -- disconnect
            if not self.error_count:
                log.error(
                    '%s -- called update while connecting, and no errors! disconnecting...',
                    self)
                self.set_offline(self.Reasons.CONN_FAIL)
        else:
            log.error('Unexpected state for update: %r', self.state)
コード例 #3
0
ファイル: emailaccount.py プロジェクト: sgricci/digsby
    def on_error(self, task=None):
        '''
        Called when an error occurs. task is a callable that can be used to make another attempt
        at whatever caused the error (if error_count is less than max_error).
        '''
        self.error_count += 1

        log.error('%r\'s error count is now: %d', self, self.error_count)
        log.error('on_error called from %s', get_func_name(2))

        if self.error_count < pref('email.err_max_tolerance', self.error_max):
            if task is None:
                task = self.update_now
            log.error('error count is under, calling %r now', task)

            if not callable(task):
                # If it was an exception assume that update_now was called. (the account type
                # probably just hasn't been fixed yet
                task = self.update_now
            util.call_later(pref('email.err_retry_time', type=int, default=2),
                            task)
        else:
            log.error('assuming the connection has died')
            self.set_offline(self.Reasons.CONN_FAIL)
            self.error_count = 0

        del self.emails[:]
コード例 #4
0
ファイル: MSNUtil.py プロジェクト: AlexUlrich/digsby
def gen_msg_payload(obj, socket, trid, msg, src_account, src_display, *params):
    """
    MSG (MeSsaGe) with a payload.
    There are different payload types, so the appropriate function is called
    to handle that type of payload.
    """
    type = msg.get('Content-Type', None)
    if type:
        type = type.split(';')[0]
    if type not in msgtypes:
        log.critical("Can't handle type %s", type)
        return
    func = get_func(obj, get_func_name(2) + '_%s' % msgtypes[type])
    if func: func(socket, msg, src_account, src_display, *params)
    else: assert False
コード例 #5
0
ファイル: MSNUtil.py プロジェクト: sgricci/digsby
def gen_msg_payload(obj, socket, trid, msg, src_account, src_display, *params):
    """
    MSG (MeSsaGe) with a payload.
    There are different payload types, so the appropriate function is called
    to handle that type of payload.
    """
    type = msg.get('Content-Type', None)
    if type:
        type = type.split(';')[0]
    if type not in msgtypes:
        log.critical("Can't handle type %s", type)
        return
    func = get_func(obj, get_func_name(2) + '_%s' % msgtypes[type])
    if func: func(socket, msg, src_account, src_display, *params)
    else: assert False
コード例 #6
0
ファイル: emailaccount.py プロジェクト: AlexUlrich/digsby
    def update(self):
        # Protocols must override this method to check for new messages.
        if self.update == EmailAccount.update:
            log.warning('not implemented: %s.update', self.__class__.__name__)
            raise NotImplementedError

        if not self.enabled:
            return

        log.info('%s (%s) -- preparing for update. update called from: %s', self, self.state, get_func_name(2))

        if self.state == self.Statuses.OFFLINE:
            # First check -- either after creation or failing to connect for some reason
            self.change_state(self.Statuses.CONNECTING)
        elif self.state == self.Statuses.ONLINE:
            # A follow-up check.
            self.change_state(self.Statuses.CHECKING)
        elif self.state == self.Statuses.CONNECTING:
            # Already connecting -- if there have been errors this is just the Nth attempt.
            # if there are not errors, something is wrong! -- disconnect
            if not self.error_count:
                log.error('%s -- called update while connecting, and no errors! disconnecting...',self)
                self.set_offline(self.Reasons.CONN_FAIL)
        else:
            log.error('Unexpected state for update: %r', self.state)