Example #1
0
    def _stop_application(self, app_id):
        state = {}
        state['loop'] = self._get_glib_loop()
        state['expected_app_id'] = app_id

        UbuntuAppLaunch.observer_add_app_stop(self._on_stopped, state)
        GLib.timeout_add_seconds(10.0, self._on_timeout, state)

        UbuntuAppLaunch.stop_application(app_id)
        state['loop'].run()
        UbuntuAppLaunch.observer_delete_app_stop(self._on_stopped)

        if state.get('status', None) == UpstartApplicationLauncher.Timeout:
            _logger.error(
                "Timed out waiting for Application with app_id '%s' to stop.",
                app_id)
    def launch(self):
        UAL.observer_add_app_failed(self.on_failed)
        UAL.observer_add_app_started(self.on_started)
        UAL.observer_add_app_focus(self.on_focus)
        UAL.observer_add_app_stop(self.on_stopped)
        UAL.observer_add_app_resume(self.on_resume)

        #start up the application
        UAL.start_application(self.appid)

        try:
            self.loop.run()
        except KeyboardInterrupt:
            pass

        print("Sdk-Launcher> The Application exited, cleaning up")

        UAL.observer_delete_app_failed(self.on_failed)
        UAL.observer_delete_app_started(self.on_started)
        UAL.observer_delete_app_focus(self.on_focus)
        UAL.observer_delete_app_stop(self.on_stopped)
        UAL.observer_delete_app_resume(self.on_resume)

        return self.exitCode