@@ -76,23 +76,23 @@ def _create_ssh_connection(self) -> str:
7676
7777 def _ensure_runner_environment (self ):
7878 # Check python3 is available in remote host
79- if self .remote_conn .run_command ("python3 --version" ).success :
79+ if self .remote_conn .run_command ("python3 --version" , "Checking python3 version" ).success :
8080 self .remote_python_command = "python3"
8181 else :
82- result = self .remote_conn .run_command ("python --version" )
82+ result = self .remote_conn .run_command ("python --version" , "Checking python version" )
8383 if result .success and "Python 3" in result .stdout :
8484 self .remote_python_command = "python"
8585 else :
8686 self .logger .error ("Unable to locate Python 3 executable in remote SSH environment" )
8787
8888 # Determine if remote host is Windows
89- result = self .remote_conn .run_command (f'{ self .remote_python_command } -c "import os; print(os.name)"' )
89+ result = self .remote_conn .run_command (f'{ self .remote_python_command } -c "import os; print(os.name)"' , "Checking remote OS type" )
9090 if not result .success :
9191 self .logger .error ("Unable to determine remote OS type" )
9292 self .is_remote_windows = result .stdout == "nt"
9393
9494 # Get remote user home folder
95- result = self .remote_conn .run_command (f'{ self .remote_python_command } -c "from pathlib import Path; print(Path.home())"' )
95+ result = self .remote_conn .run_command (f'{ self .remote_python_command } -c "from pathlib import Path; print(Path.home())"' , "Checking remote home folder" )
9696 if not result .success :
9797 self .logger .error ("Unable to determine remote home user folder" )
9898 home_folder = result .stdout
@@ -104,11 +104,10 @@ def _ensure_runner_environment(self):
104104 remote_conan_home = Path (home_folder ) / ".conan2remote" / "conanhome"
105105 remote_conan_home = remote_conan_home .as_posix ().replace ("\\ " , "/" )
106106 self .remote_conan_home = remote_conan_home
107- self .logger .verbose (f"Remote workfolder: { remote_folder } " )
108107
109108 # Ensure remote folders exist
110109 for folder in [remote_folder , remote_conan_home ]:
111- if not self .remote_conn .run_command (f'{ self .remote_python_command } -c "import os; os.makedirs(\' { folder } \' , exist_ok=True)"' ).success :
110+ if not self .remote_conn .run_command (f'{ self .remote_python_command } -c "import os; os.makedirs(\' { folder } \' , exist_ok=True)"' , f"Checking { folder } folder exists" ).success :
112111 self .logger .error (f"Unable to create remote workfolder at { folder } : { result .stderr } " )
113112
114113 # TODO: allow multiple venv given the client side conan version
@@ -120,9 +119,6 @@ def _ensure_runner_environment(self):
120119 else :
121120 conan_cmd = remote_folder + "/venv/bin/conan"
122121
123- self .logger .verbose (f"Expected remote conan home: { remote_conan_home } " )
124- self .logger .verbose (f"Expected remote conan command: { conan_cmd } " )
125-
126122 # Check if remote Conan executable exists, otherwise invoke pip inside venv
127123 has_remote_conan = self .remote_conn .check_file_exists (conan_cmd )
128124
@@ -133,28 +129,28 @@ def _ensure_runner_environment(self):
133129
134130 if not has_remote_conan :
135131 self .logger .verbose (f"Creating remote venv" )
136- result = self .remote_conn .run_command (f"{ self .remote_python_command } -m venv { conan_venv } " )
132+ result = self .remote_conn .run_command (f"{ self .remote_python_command } -m venv { conan_venv } " , "Creating remote venv" )
137133 if not result .success :
138134 self .logger .error (f"Unable to create remote venv: { result .stderr } " )
139135 self ._install_conan_remotely (python_command , requested_conan_version )
140136 else :
141- version = self .remote_conn .run_command (f"{ conan_cmd } --version" , verbose = True ).stdout
137+ version = self .remote_conn .run_command (f"{ conan_cmd } --version" , "Checking conan version" , verbose = True ).stdout
142138 remote_conan_version = Version (version [version .rfind (" " )+ 1 :])
143139 if requested_conan_version == "dev" and remote_conan_version .bump (1 ) == str (conan_version ).replace ("-dev" , "" ):
144140 pass
145141 elif remote_conan_version != requested_conan_version :
146142 self .logger .verbose (f"Remote Conan version mismatch: { remote_conan_version } != { requested_conan_version } " )
147143 self ._install_conan_remotely (python_command , requested_conan_version )
148144
149- if not self .remote_conn .run_command (f"{ conan_cmd } remote update conancenter --url='https://center2.conan.io'" ).success :
145+ if not self .remote_conn .run_command (f"{ conan_cmd } remote update conancenter --url='https://center2.conan.io'" , "Updating conancenter remote" ).success :
150146 self .logger .error (f"Unable to update conancenter remote: { result .stderr } " )
151147
152148 self ._create_remote_conan_wrapper (remote_conan_home , remote_folder , conan_cmd )
153149
154150 def _install_conan_remotely (self , python_command : str , version : str ):
155151 self .logger .verbose (f"Installing conan version: { version } " )
156152 # Note: this may fail on windows
157- result = self .remote_conn .run_command (f"{ python_command } -m pip install conan{ f'=={ version } ' if version != 'dev' else ' --upgrade' } " )
153+ result = self .remote_conn .run_command (f"{ python_command } -m pip install conan{ f'=={ version } ' if version != 'dev' else ' --upgrade' } " , "Installing conan" )
158154 if not result .success :
159155 self .logger .error (f"Unable to install conan in venv: { result .stderr } " )
160156
@@ -174,8 +170,8 @@ def _create_remote_conan_wrapper(self, remote_conan_home: str, remote_folder: st
174170 conan_wrapper_contents = f"""{ env_lines } \n { conan_cmd } $@\n """
175171
176172 self .remote_conan = self .remote_conn .create_remote_script (conan_wrapper_contents , remote_folder + "/conan" , self .is_remote_windows )
177- self .remote_conn .run_command (f"{ self .remote_conan } config home" , verbose = True )
178- if not self .remote_conn .run_command (f"{ self .remote_conan } profile detect --force" ) :
173+ self .remote_conn .run_command (f"{ self .remote_conan } config home" , "Checking conan home" , verbose = True )
174+ if not self .remote_conn .run_command (f"{ self .remote_conan } profile detect --force" , "Detecting remote profile" ). success :
179175 self .logger .error ("Error creating default profile in remote machine" )
180176
181177
@@ -209,7 +205,7 @@ def _copy_working_conanfile_path(self):
209205
210206 # Create temporary destination directory
211207 temp_dir_create_cmd = f"""{ self .remote_python_command } -c "import tempfile; print(tempfile.mkdtemp(dir='{ self .remote_workspace } '))" """
212- result = self .remote_conn .run_command (temp_dir_create_cmd )
208+ result = self .remote_conn .run_command (temp_dir_create_cmd , "Creating remote temporary directory" )
213209 if not result .success or not result .stdout :
214210 self .logger .error (f"Unable to create remote temporary directory: { result .stderr } " )
215211 self .remote_create_dir = result .stdout .replace ("\\ " , '/' )
@@ -237,9 +233,8 @@ def _remote_create(self):
237233 conan_create_cmd = f'{ self .remote_conan } create { raw_args } --format json > { remote_json_output } '
238234 script_path = _Path (self .remote_create_dir ).joinpath ("conan_create" ).as_posix ()
239235 script_path = self .remote_conn .create_remote_script (conan_create_cmd , script_path , self .is_remote_windows )
240- self .logger .status (f"Remote command: { conan_create_cmd } " , fg = Color .BRIGHT_MAGENTA )
241236
242- if self .remote_conn .run_interactive_command (script_path , self .is_remote_windows ):
237+ if self .remote_conn .run_interactive_command (script_path , self .is_remote_windows , f"Running conan create { raw_args } " ):
243238 self ._update_local_cache (remote_json_output )
244239
245240 self .client .close ()
@@ -254,6 +249,7 @@ def _update_local_cache(self, json_result: str):
254249 raise ConanException ("Unable to generate remote package list" )
255250
256251 conan_cache_tgz = _Path (self .remote_create_dir ).joinpath ("cache.tgz" ).as_posix ()
252+ self .logger .status ("Retrieving remote artifacts into local cache..." , fg = Color .BRIGHT_MAGENTA )
257253 self .logger .verbose ("Remote cache tgz: " + conan_cache_tgz )
258254 cache_save_command = f"{ self .remote_conan } cache save --list { pkg_list_json } --file { conan_cache_tgz } "
259255 _ , stdout , _ = self .client .exec_command (cache_save_command )
@@ -320,23 +316,26 @@ def __init__(self, success, stdout, stderr):
320316 self .stdout = stdout
321317 self .stderr = stderr
322318
323- def run_command (self , command : str , verbose : bool = False ) -> RunResult :
319+ def run_command (self , command : str , friendly_command : str = "" , verbose : bool = False ) -> RunResult :
324320 _ , stdout , stderr = self .client .exec_command (command )
325321 log = self .logger .status if verbose else self .logger .verbose
326- log (f'$ { command } ' , fg = Color .BLUE )
322+ log (f'{ friendly_command } ...' , fg = Color .BLUE )
323+ self .logger .debug (f'$ { command } ' )
327324 result = RemoteConnection .RunResult (stdout .channel .recv_exit_status () == 0 ,
328325 stdout .read ().decode ().strip (),
329326 stderr .read ().decode ().strip ())
330327 log (f"{ result .stdout } " )
331328 return result
332329
333- def run_interactive_command (self , command : str , is_remote_windows : bool ) -> bool :
330+ def run_interactive_command (self , command : str , is_remote_windows : bool , friendly_command : str = "" ) -> bool :
334331 ''' Run a command in an SSH session.
335332 When requesting a pseudo-terminal from the server,
336333 ensure we pass width and height that matches the current
337334 terminal
338335 :return: True if the command succeeded
339336 '''
337+ self .logger .status (f'{ friendly_command } ...' , fg = Color .BLUE )
338+ self .logger .debug (f"$ { command } " )
340339 channel = self .client .get_transport ().open_session ()
341340 if sys .stdout .isatty ():
342341 width , height = os .get_terminal_size ()
0 commit comments