|
4 | 4 | import tempfile
|
5 | 5 |
|
6 | 6 | from conan.api.conan_api import ConanAPI
|
7 |
| -from conan.api.output import Color |
| 7 | +from conan.api.output import Color, ConanOutput |
8 | 8 | from conan.errors import ConanException
|
9 | 9 |
|
10 | 10 | import os
|
@@ -38,9 +38,11 @@ def __init__(
|
38 | 38 | hostname = self._create_ssh_connection()
|
39 | 39 | except Exception as e:
|
40 | 40 | raise ConanException(f"Error creating SSH connection: {e}")
|
41 |
| - self.logger = RunnerOutput(hostname) |
| 41 | + self.logger = ConanOutput() |
| 42 | + self.logger.set_warnings_as_errors(True) |
| 43 | + self.runner_logger = RunnerOutput(hostname) |
42 | 44 | self.logger.status(f"Connected to {hostname}", fg=Color.BRIGHT_MAGENTA)
|
43 |
| - self.remote_conn = RemoteConnection(self.client, self.logger) |
| 45 | + self.remote_conn = RemoteConnection(self.client, self.runner_logger) |
44 | 46 |
|
45 | 47 | def run(self):
|
46 | 48 | self._ensure_runner_environment()
|
@@ -136,7 +138,7 @@ def _ensure_runner_environment(self):
|
136 | 138 | self.logger.error(f"Unable to create remote venv: {result.stderr}")
|
137 | 139 | self._install_conan_remotely(python_command, requested_conan_version)
|
138 | 140 | else:
|
139 |
| - version = self.remote_conn.run_command(f"{conan_cmd} --version").stdout |
| 141 | + version = self.remote_conn.run_command(f"{conan_cmd} --version", verbose=True).stdout |
140 | 142 | remote_conan_version = Version(version[version.rfind(" ")+1:])
|
141 | 143 | if requested_conan_version == "dev" and remote_conan_version.bump(1) == str(conan_version).replace("-dev", ""):
|
142 | 144 | pass
|
@@ -172,8 +174,7 @@ def _create_remote_conan_wrapper(self, remote_conan_home: str, remote_folder: st
|
172 | 174 | conan_wrapper_contents = f"""{env_lines}\n{conan_cmd} $@\n"""
|
173 | 175 |
|
174 | 176 | self.remote_conan = self.remote_conn.create_remote_script(conan_wrapper_contents, remote_folder + "/conan", self.is_remote_windows)
|
175 |
| - conan_config_home = self.remote_conn.run_command(f"{self.remote_conan} config home").stdout |
176 |
| - self.logger.verbose(f"Remote conan config home returned: {conan_config_home}") |
| 177 | + self.remote_conn.run_command(f"{self.remote_conan} config home", verbose=True) |
177 | 178 | if not self.remote_conn.run_command(f"{self.remote_conan} profile detect --force"):
|
178 | 179 | self.logger.error("Error creating default profile in remote machine")
|
179 | 180 |
|
@@ -319,11 +320,15 @@ def __init__(self, success, stdout, stderr):
|
319 | 320 | self.stdout = stdout
|
320 | 321 | self.stderr = stderr
|
321 | 322 |
|
322 |
| - def run_command(self, command: str) -> RunResult: |
| 323 | + def run_command(self, command: str, verbose: bool = False) -> RunResult: |
323 | 324 | _, stdout, stderr = self.client.exec_command(command)
|
324 |
| - return RemoteConnection.RunResult(stdout.channel.recv_exit_status() == 0, |
325 |
| - stdout.read().decode().strip(), |
326 |
| - stderr.read().decode().strip()) |
| 325 | + log = self.logger.status if verbose else self.logger.verbose |
| 326 | + log(f'$ {command}', fg=Color.BLUE) |
| 327 | + result = RemoteConnection.RunResult(stdout.channel.recv_exit_status() == 0, |
| 328 | + stdout.read().decode().strip(), |
| 329 | + stderr.read().decode().strip()) |
| 330 | + log(f"{result.stdout}") |
| 331 | + return result |
327 | 332 |
|
328 | 333 | def run_interactive_command(self, command: str, is_remote_windows: bool) -> bool:
|
329 | 334 | ''' Run a command in an SSH session.
|
@@ -366,6 +371,5 @@ def replace_cursor_match(match):
|
366 | 371 | # sys.stdout.buffer.write(line)
|
367 | 372 | # sys.stdout.buffer.flush()
|
368 | 373 | line = remove_cursor_movements(line.replace(b'\r', b'').decode(errors='ignore').strip())
|
369 |
| - for l in line.splitlines(): |
370 |
| - self.logger.status(l) |
| 374 | + self.logger.status(line) |
371 | 375 | return stdout.channel.recv_exit_status() == 0
|
0 commit comments