Run a OS command defineClassAndFunctionToExecOsCmd() must be run before this one return string (stdout or stderr) or Exception
(self, cmd, printResponse=True, retryNb=1)
| 138 | return True |
| 139 | |
| 140 | def __runOSCmd__ (self, cmd, printResponse=True, retryNb=1): |
| 141 | ''' |
| 142 | Run a OS command |
| 143 | defineClassAndFunctionToExecOsCmd() must be run before this one |
| 144 | return string (stdout or stderr) or Exception |
| 145 | ''' |
| 146 | logging.info("Execute the following command system remotly: {0}".format(cmd)) |
| 147 | data = self.__execQuery__(query=self.SOURCE_OS_COMMAND_EXEC.format(cmd),ld=[]) |
| 148 | if isinstance(data,Exception): |
| 149 | logging.info("Impossible to execute the system command: {0}".format(str(data))) |
| 150 | if self.JAVA_SESSION_CLEARED in str(data): |
| 151 | if retryNb == 0 : return data |
| 152 | logging.info("Run again the OS command...") |
| 153 | return self.__runOSCmd__ (cmd=cmd, printResponse=printResponse, retryNb=retryNb-1) |
| 154 | return data |
| 155 | if data[0][0] == None : |
| 156 | logging.info('The system command output is empty') |
| 157 | return '' |
| 158 | else : |
| 159 | logging.info('The system command output is: `{0}`...'.format(data[0][0][:100])) |
| 160 | if printResponse == True : |
| 161 | self.args['print'].printOSCmdOutput(data[0][0]) |
| 162 | return data[0][0] |
| 163 | |
| 164 | def execOSCommand(self,cmd, printResponse=True, needCreateClassAndFunction=True, needDeleteClassAndFunction=True): |
| 165 | ''' |
no test coverage detected