def execute(self): if self.conf.command: LOG.info('Executing exec job. Command: {0}'.format( self.conf.command)) exec_cmd.execute(self.conf.command) else: LOG.warning('No command info options were set. Exiting.') return {}
def execute_method(self): logging.info('[*] exec job....') if self.conf.command: logging.info('[*] Executing exec job....') exec_cmd.execute(self.conf.command) else: logging.warning('[*] No command info options were set. Exiting.') return {}
def execute_method(self): logging.info('[*] exec job....') if self.conf.command: logging.info('[*] Executing exec job....') exec_cmd.execute(self.conf.command) else: logging.warning( '[*] No command info options were set. Exiting.') return {}
def test__exec_cmd_with_pipe(self): cmd = "echo test|wc -l" popen = patch('freezer.utils.exec_cmd.subprocess.Popen') mock_popen = popen.start() mock_popen.return_value = mock.Mock() mock_popen.return_value.communicate = mock.Mock() mock_popen.return_value.communicate.return_value = ['some stderr'] mock_popen.return_value.returncode = 0 exec_cmd.execute(cmd) assert (mock_popen.call_count == 2) popen.stop()
def test_exec_cmd(self): cmd = "echo test > test.txt" popen = patch('freezer.utils.exec_cmd.subprocess.Popen') mock_popen = popen.start() mock_popen.return_value = mock.Mock() mock_popen.return_value.communicate = mock.Mock() mock_popen.return_value.communicate.return_value = ['some stderr'] mock_popen.return_value.returncode = 0 exec_cmd.execute(cmd) assert (mock_popen.call_count == 1) mock_popen.assert_called_with(['echo', 'test', '>', 'test.txt'], shell=False, stderr=subprocess.PIPE, stdout=subprocess.PIPE) popen.stop()