Esempio n. 1
0
    def roster_background_thread(self, sr):
        '''Entry for background roster update thread'''
        try:
            logging.debug('roster_thread for ' + str(sr))
            # Allow test hooks with static ejabberd_controller
            if hasattr(self.ctx, 'ejabberd_controller'
                       ) and self.ctx.ejabberd_controller is not None:
                e = self.ctx.ejabberd_controller
            else:
                e = ejabberdctl(self.ctx)
            groups, commands = self.roster_update_users(e, sr)
            self.roster_update_groups(e, groups)
            # For some reason, the vcard changes are (were?)
            # not pushed to the clients. Rinse and repeat.
# Maybe no longer necessary with (mostly) synchronous thread?
#            for cmd in commands:
#                e.execute(cmd)
#        except AttributeError:
#            pass # For tests
        except Exception as err:
            (etype, value, tb) = sys.exc_info()
            traceback.print_exception(etype, value, tb)
            logging.warn('roster_groups thread: %s:\n%s' %
                         (str(err), ''.join(traceback.format_tb(tb))))
            return False
Esempio n. 2
0
 def roster_background_thread(self, sr):
     '''Entry for background roster update thread'''
     start = time.time()
     ucommands = gcommands = ()
     try:
         logging.debug('roster_thread for ' + str(sr))
         # Allow test hooks with static ejabberd_controller
         if hasattr(self.ctx, 'ejabberd_controller'
                    ) and self.ctx.ejabberd_controller is not None:
             e = self.ctx.ejabberd_controller
         else:
             e = ejabberdctl(self.ctx)
         groups, ucommands = self.roster_update_users(e, sr)
         self.ctx.db.conn.dump('rosterinfo')
         gcommands = self.roster_update_groups(e, groups)
     except Exception as err:
         (etype, value, tb) = sys.exc_info()
         traceback.print_exception(etype, value, tb)
         logging.warn('roster_groups thread: %s:\n%s' %
                      (str(err), ''.join(traceback.format_tb(tb))))
         logging.debug(
             'roster_groups thread failed after %s+%s commands in %s seconds',
             len(ucommands), len(gcommands),
             time.time() - start)
         return False
     finally:
         logging.debug(
             'roster_groups thread finished %s+%s commands in %s seconds',
             len(ucommands), len(gcommands),
             time.time() - start)
def setup_module():
    global xc, sc
    xc = xcauth(domain_db={
        'xdomain': '99999\thttps://remotehost\tydomain\t',
        'udomain': '8888\thttps://oldhost\t',
    },
                default_url='https://localhost',
                default_secret='01234',
                ejabberdctl='/no/bin/ejabberdctl',
                shared_roster_db={})
    xc.ejabberd_controller = ejabberdctl(xc)
    sc = sigcloud(xc, 'user1', 'domain1')
def test_echo():
    xc = xcauth(ejabberdctl='/bin/echo')
    e = ejabberdctl(xc)
    assertEqual(e.execute(['Hello', 'world']), 'Hello world\n')
def test_false():
    xc = xcauth(ejabberdctl='/bin/false')
    e = ejabberdctl(xc)
    assertEqual(e.execute(['Hello', 'world']), None)
def test_true():
    xc = xcauth(ejabberdctl='/bin/true')
    e = ejabberdctl(xc)
    assertEqual(e.execute(['Hello', 'world']), '')