| 81 | return value |
| 82 | |
| 83 | def _run_command(self, comm, shell = False): |
| 84 | c = None |
| 85 | try: |
| 86 | if shell and type(comm) is list: |
| 87 | comm = " ".join(shlex.quote(x) for x in comm) |
| 88 | if not shell and type(comm) is str: |
| 89 | comm = shlex.split(comm) |
| 90 | p = subprocess.Popen(comm, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 91 | c = p.communicate() |
| 92 | except: |
| 93 | if c == None: |
| 94 | return ("", "Command not found!", 1) |
| 95 | return (self._decode(c[0]), self._decode(c[1]), p.returncode) |
| 96 | |
| 97 | def run(self, command_list, leave_on_fail = False): |
| 98 | # Command list should be an array of dicts |