def _handle_service_rc(self, command): if os.path.exists(self.init_script_name): process_tools.call_command( "{} {}".format(self.init_script_name, command), self.log) else: self.log( "rc-script {} does not exist".format(self.init_script_name), logging_tools.LOG_LEVEL_WARN)
def _service_command_i(self, name, cmd): return process_tools.call_command( "{} {} {}".format(self._service, name, cmd), self.log, close_fds=True, log_stdout=False, )
def _call(self, cur_inst): full_service_name = "/etc/init.d/{}".format(self.option_dict["service"]) if self.option_dict["mode"] in ["start", "stop", "restart"]: if os.path.isfile(full_service_name): cur_com = "{} {}".format(full_service_name, self.option_dict["mode"]) ret_stat, _stdout, _stderr = process_tools.call_command(cur_com, cur_inst.log) # cstat, _c_logs = process_tools.submit_at_command(at_com, self.option_dict.get("timediff", 0)) if ret_stat: cur_inst.srv_com.set_result( "error calling '{}': {}".format(cur_com, "{} {}".format(_stdout, _stderr).strip()), server_command.SRV_REPLY_STATE_ERROR ) else: cur_inst.srv_com.set_result( "ok called '{}': {}".format(cur_com, "{} {}".format(_stdout, _stderr).strip()), ) else: cur_inst.srv_com.set_result( "error unknown service '{}'".format(full_service_name), server_command.SRV_REPLY_STATE_ERROR ) else: cur_inst.srv_com.set_result( "error unknown mode '{}'".format(self.option_dict["mode"]), server_command.SRV_REPLY_STATE_ERROR )
def _call_command(self, com_str): _stat, _out, _err = process_tools.call_command(com_str, self.log, close_fds=True, log_stdout=False) _out = _out.decode("utf-8") _err = _err.decode("utf-8") return _stat, _out, _err
def _call_command(self, com_str): return process_tools.call_command(com_str, self.log, close_fds=True, log_stdout=False)