def _log_service_call(self, srv_name, log_format, *args): if self.verbose: name = ansi_format(srv_name, C_NAME) if args: rospy.loginfo(log_format, name, *args) else: rospy.loginfo(log_format, name)
def __execute(self): self._is_job_running = True success = None rospy.loginfo("Code execution triggered") try: if self.execute_func is not None: success = self.execute_func(self) else: success = self.execute() except ServiceCallFailure as expt: rospy.logerr("The client routine was interrupted by an uncaught " "service call exception: \n%s", expt) except NotImplementedError: rospy.logerr("You haven't (fully) implemented function: %s", ansi_format(get_exception_raising_function(), C_NAME)) except KeyboardInterrupt: rospy.logwarn("The client routine was interrupted by the user.") except Exception: # pylint: disable=broad-except # catch all exceptions to ensure that the interface is informed # about the job result, but still log the full stack trace rospy.logerr("The client routine was interrupted by an uncaught " "exception: %s", traceback.format_exc()) if not isinstance(success, bool): rospy.loginfo("Client code did not return boolean indicating " "success, assuming %sunsuccessful completion%s", C_WARN, C_END) success = False elif success: rospy.loginfo("Client code completed %ssuccessfully%s", C_OK, C_END) else: rospy.loginfo("Client code completed %sunsuccessfully%s", C_WARN, C_END) self.notify_job_finished(success) rospy.loginfo("Code execution completed") return success
def _handle_response_error_code(self, srv_name, resp): name = ansi_format(srv_name, C_NAME) if resp.success: if self.verbose: rospy.loginfo("%s %ssucceeded%s", name, C_OK, C_END) return True error_code = RLLErrorCode(resp.error_code) if error_code.is_critical_failure(): rospy.logerr( "%s %sfailed critically with error: %s%s", name, C_FAIL, C_END, error_code) raise CriticalServiceCallFailure( error_code, "Service call %s failed with error: %s" % ( srv_name, error_code)) else: rospy.logwarn("%s %sfailed: %s%s", name, C_FAIL, C_END, error_code) if self._exception_on_any_failure: raise ServiceCallFailure( error_code, "Service call %s failed: %s" % (srv_name, error_code)) elif error_code.code == RLLErrorCode.JOB_EXECUTION_TIMED_OUT: raise ServiceCallFailure( error_code, "You exceeded the maximum job execution duration.") hint = error_code.get_hint() if hint is not None: rospy.loginfo("%sPossible failure reason:%s %s", C_INFO, C_END, hint) return False