def stop_app(self, appname): resp = StopAppResponse(stopped=False) try: app = self._current_app_definition # request to stop all apps. if app is not None and appname == '*': appname = app.name if app is None or app.name != appname: rospy.loginfo("handle stop app: app [%s] is not running [x]" % (appname)) resp.error_code = StatusCodes.NOT_RUNNING resp.message = "app %s is not running" % (appname) else: try: if self._launch: rospy.loginfo("handle stop app: stopping app [%s]" % (appname)) self._status_pub.publish( AppStatus(AppStatus.INFO, 'stopping %s' % (app.display_name))) self._stop_current() rospy.loginfo("handle stop app: app [%s] stopped" % (appname)) resp.stopped = True resp.message = "%s stopped" % (appname) else: rospy.loginfo( "handle stop app: app [%s] is not running" % (appname)) resp.message = "app [%s] is not running" % (appname) resp.error_code = StatusCodes.NOT_RUNNING finally: self._launch = None self._set_current_app(None, None) except Exception as e: rospy.logerr("handle stop app: internal error %s" % (e)) resp.error_code = StatusCodes.INTERNAL_ERROR resp.message = "internal error: %s" % (str(e)) return resp
def stop_apps(self): resp = StopAppResponse(stopped=False) current_app_definitions = self._current_app_definitions current_apps = self._current_apps launches = self._launches try: for app in current_app_definitions: launches[app.name].shutdown() app_to_stop = current_apps[current_app_definitions.index(app)] current_apps.remove(app_to_stop) current_app_definitions.remove(app) self._set_current_apps(current_apps, current_app_definitions) resp.stopped = True except Exception as e: rospy.logerr("handle stop app: internal error %s" % (e)) resp.error_code = StatusCodes.INTERNAL_ERROR resp.message = "internal error: %s" % (str(e)) return resp
def stop_app(self, appname): resp = StopAppResponse(stopped=False) try: app = self._current_app_definition # request to stop all apps. if app is not None and appname == '*': appname = app.name if app is None or app.name != appname: rospy.loginfo("handle stop app: app [%s] is not running [x]"%(appname)) resp.error_code = StatusCodes.NOT_RUNNING resp.message = "app %s is not running"%(appname) else: try: if self._launch: rospy.loginfo("handle stop app: stopping app [%s]"%(appname)) self._status_pub.publish(AppStatus(AppStatus.INFO, 'stopping %s'%(app.display_name))) self._stop_current() rospy.loginfo("handle stop app: app [%s] stopped"%(appname)) resp.stopped = True resp.message = "%s stopped"%(appname) else: rospy.loginfo("handle stop app: app [%s] is not running"%(appname)) resp.message = "app [%s] is not running"%(appname) resp.error_code = StatusCodes.NOT_RUNNING finally: self._launch = None self._set_current_app(None, None) except Exception as e: rospy.logerr("handle stop app: internal error %s"%(e)) resp.error_code = StatusCodes.INTERNAL_ERROR resp.message = "internal error: %s"%(str(e)) return resp