| 172 | self.executable = executable |
| 173 | |
| 174 | def _call(self, command, args, kw, repository=None, call=False): |
| 175 | cmd = [self.executable, command] + list(args) |
| 176 | cwd = None |
| 177 | |
| 178 | if repository is not None: |
| 179 | cwd = os.getcwd() |
| 180 | os.chdir(repository) |
| 181 | |
| 182 | try: |
| 183 | if call: |
| 184 | return subprocess.call(cmd, **kw) |
| 185 | else: |
| 186 | return subprocess.Popen(cmd, **kw) |
| 187 | finally: |
| 188 | if cwd is not None: |
| 189 | os.chdir(cwd) |
| 190 | |
| 191 | def __call__(self, command, *a, **kw): |
| 192 | ret = self._call(command, a, {}, call=True, **kw) |