Ejemplo n.º 1
0
def main():
        # Configure log
        configure_logging()

        # Load configuration
        configure = SymConfig('../resources/config.json')
        configure.load_config()

        # Authenticate based on authType in config
        if ('authType' not in configure.data or configure.data['authType'] == 'rsa'):
            print('Python Client runs using RSA authentication')
            auth = SymBotRSAAuth(configure)
        else:
            print('Python Client runs using certificate authentication')
            auth = Auth(configure)
        auth.authenticate()

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

        # Initialize datafeed service
        datafeed_event_service = bot_client.get_async_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
        datafeed_event_service.add_im_listener(IMListenerImpl(bot_client))
        datafeed_event_service.add_room_listener(RoomListenerImpl(bot_client))
        datafeed_event_service.add_elements_listener(ElementsListenerImpl(bot_client))

        # Create and read the datafeed
        print('Starting datafeed')
        try:
            loop = asyncio.get_event_loop()
            loop.run_until_complete(datafeed_event_service.start_datafeed())
        except (KeyboardInterrupt, SystemExit):
            None
        except:
            raise
def main():
        parser = argparse.ArgumentParser()
        parser.add_argument("--auth", choices=["rsa", "cert"], default="rsa",
            help="Authentication method to use")
        parser.add_argument("--config", help="Config json file to be used")
        args = parser.parse_args()
        # Cert Auth flow: pass path to certificate config.json file
        config_path = args.config
        configure = SymConfig(config_path, config_path)
        configure.load_config()
        if args.auth == "rsa":
            auth = SymBotRSAAuth(configure)
        elif args.auth == "cert":
            auth = Auth(configure)
        else:
            raise ValueError("Unexpected value for auth: " + args.auth)
        auth.authenticate()
        # Initialize SymBotClient with auth and configure objects
        bot_client = SymBotClient(auth, configure)
        print('successfully authenticated')
        run_import(bot_client)
        print('successfully imported')
Ejemplo n.º 3
0
def main():
        global loopCount

        # Configure log
        configure_logging()

        # Cert Auth flow: pass path to certificate config.json file
        config_path = os.path.join(os.path.dirname(__file__), "../resources", "config.json")
        
        configure = SymConfig(config_path, config_path)
        configure.load_config()

        auth = SymBotRSAAuth(configure)
        auth.authenticate()

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

        # add rss instance to bot
        mr = reader.RssReader('../resources/state.json')
        bot_client.reader = mr

        # Initialize datafeed service
        datafeed_event_service = bot_client.get_async_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 = AsyncIMListenerImp(bot_client)
        datafeed_event_service.add_im_listener(im_listener)

        room_listener = AsyncRoomListenerImp(bot_client)
        datafeed_event_service.add_room_listener(room_listener)

        # Create and read the datafeed
        logging.info('Datafeed started - bot is ready')
        loop = asyncio.get_event_loop()
        awaitables = asyncio.gather(datafeed_event_service.start_datafeed())
        loop.run_until_complete(awaitables)
Ejemplo n.º 4
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("--auth",
                        choices=["rsa", "cert"],
                        default="rsa",
                        help="Authentication method to use")
    parser.add_argument("--config", help="Config json file to be used")

    args = parser.parse_args()

    # Configure log
    configure_logging()

    # Cert Auth flow: pass path to certificate config.json file
    if args.config is None:
        config_path = os.path.join(os.path.dirname(__file__), "..",
                                   "sym_api_client_python", "resources",
                                   "config.json")
    else:
        config_path = args.config

    configure = SymConfig(config_path, config_path)
    configure.load_config()

    if args.auth == "rsa":
        auth = SymBotRSAAuth(configure)
    elif args.auth == "cert":
        auth = Auth(configure)
    else:
        raise ValueError("Unexpected value for auth: " + args.auth)

    auth.authenticate()

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

    # Initialize datafeed service
    datafeed_event_service = bot_client.get_async_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 = AsyncIMListenerImp(bot_client)
    datafeed_event_service.add_im_listener(im_listener_test)
    room_listener_test = AsyncRoomListenerImp(bot_client)
    datafeed_event_service.add_room_listener(room_listener_test)

    # This is just a function to demonstrate the non-blocking nature of the async datafeed
    async def timed_ringer(period_in_seconds, message):
        while True:
            await asyncio.sleep(period_in_seconds)
            print(message)

    # Create and read the datafeed
    print('Starting datafeed')
    loop = asyncio.get_event_loop()
    awaitables = asyncio.gather(timed_ringer(2, "Ding"),
                                timed_ringer(5, "Dong"),
                                datafeed_event_service.start_datafeed())
    loop.run_until_complete(awaitables)
Ejemplo n.º 5
0
def step_impl(context):
    configure = SymConfig('../resources/config.json')
    configure.load_config()
    auth = SymBotRSAAuth(configure)
    auth.authenticate()
    pass