# -*- coding: utf-8 -*- """ This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences) """ import logging import sys try: import qi except ImportError: qi = None def get_qi_session(): """ Create and return a Qi session if available. :return: The active Qi session or ``None`` if unavailable. :rtype: qi.Session | None """ if qi is None: logging.info("Unable to import qi. Running in stand-alone mode.") return None if "--qi-url" not in sys.argv: logging.info("No Qi URL argument given. Running in stand-alone mode.") return None try: app = qi.Application() app.start() return app.session except RuntimeError: logging.info("Unable to connect to the robot. Running in stand-alone mode.") return None