예제 #1
0
파일: demobot.py 프로젝트: renfieldk/botpoc
def main():
    if 'DEBUG' in sys.argv:
        if 'FILE' in sys.argv:
            logging.basicConfig(format='%(asctime)s %(message)s',
                                level=logging.DEBUG,
                                filename='./logs/botlog.log',
                                filemode='w')
        else:
            logging.basicConfig(format='%(asctime)s %(message)s',
                            level=logging.DEBUG)
    else:
        logging.basicConfig(format='%(asctime)s %(message)s',
                            level=logging.INFO,
                           filename='.logs/botlog.log',
                           filemode='w')

    configure = SymConfig('./config.json')
    configure.load_rsa_config()
    auth = SymBotRSAAuth(configure)
    auth.authenticate()

    bot_client = DemoBotClient(auth, configure)

    datafeed_event_service = bot_client.get_datafeed_event_service()

    im_ear = IListenToIMs(bot_client)
    datafeed_event_service.add_im_listener(im_ear)

    logging.debug('starting datafeed...')
    datafeed_event_service.start_datafeed()
def main():
        print('Python Client runs using RSA authentication')

        # Configure log
        configure_logging()

        # RSA Auth flow: pass path to rsa_config.json file
        configure = SymConfig('sym_api_client_python/resources'
                              '/rsa_config.json')
        configure.load_rsa_config()
        auth = SymBotRSAAuth(configure)
        auth.authenticate()

        # Initialize SymBotClient with auth and configure objects
        bot_client = SymBotClient(auth, configure)

        # Initialize datafeed service
        datafeed_event_service = bot_client.get_datafeed_event_service()

        # Initialize listener objects and append them to datafeed_event_service
        # Datafeed_event_service polls the datafeed and the event listeners
        # respond to the respective types of events
        im_listener_test = IMListenerTestImp(bot_client)
        datafeed_event_service.add_im_listener(im_listener_test)
        room_listener_test = RoomListenerTestImp(bot_client)
        datafeed_event_service.add_room_listener(room_listener_test)

        # Create and read the datafeed
        print('Starting datafeed')
        datafeed_event_service.start_datafeed()
 def setUp(self):
     logging.debug('hi')
     #RSA Auth flow:
     configure = SymConfig(
         'sym_api_client_python/resources/rsa_config.json')
     configure.load_rsa_config()
     auth = SymBotRSAAuth(configure)
     auth.authenticate()
     #initialize SymBotClient with auth and configure objects
     self.botClient = SymBotClient(auth, configure)