@@ -228,15 +228,15 @@ def _write_stdin(msg) -> None:
228228 else :
229229 self .tue_install_tee (line )
230230
231- def _out_handler_sudo_password (self , sub : BackgroundPopen , line : Union [bytes , str ]) -> None :
231+ def _err_handler_sudo_password (self , sub : BackgroundPopen , line : Union [bytes , str ]) -> None :
232232 line = line .strip ()
233233 if line .startswith ("[sudo] password for" ):
234234 if self ._sudo_password is None :
235235 self ._sudo_password = getpass .getpass (line )
236236 sub .stdin .write (f"{ self ._sudo_password } \n " )
237237 sub .stdin .flush ()
238238 else :
239- self .tue_install_tee (line )
239+ self .tue_install_tee (line , color = "red" )
240240
241241 def tue_install_error (self , msg : str ) -> None :
242242 # Make sure the entire msg is indented, not just the first line
@@ -398,13 +398,13 @@ def tue_install_target(self, target: str, now: bool = False) -> bool:
398398 sub = BackgroundPopen (
399399 args = cmds ,
400400 out_handler = self ._out_handler ,
401- stderr = subprocess . PIPE ,
401+ err_handler = self . _err_handler_sudo_password ,
402402 stdin = subprocess .PIPE ,
403403 text = True ,
404404 )
405405 sub .wait ()
406406 if sub .returncode != 0 :
407- stderr = sub .stderr .read ()
407+ # stderr = sub.stderr.read()
408408 self .tue_install_error (
409409 f"Error while running({ sub .returncode } ):\n { ' ' .join (cmds )} " f"\n \n { stderr } "
410410 )
@@ -498,27 +498,26 @@ def tue_install_cp(self, source: str, target: str) -> bool:
498498 self .tue_install_debug (f"tue-install-cp: copying { file } to { cp_target } " )
499499
500500 if root_required :
501- sudo_cmd = "sudo -S "
501+ sudo_cmd = "sudo "
502502 self .tue_install_debug (f"Using elevated privileges (sudo) to copy ${ file } to ${ cp_target } " )
503503 else :
504504 sudo_cmd = ""
505505
506506 cmd = f"{ sudo_cmd } python -c 'import os; os.makedirs(\" { target } \" , exist_ok=True)'"
507507 cmds = _which_split_cmd (cmd )
508- print (cmds )
509508 self .tue_install_echo (" " .join (cmds ))
510509 sub = BackgroundPopen (
511510 args = cmds ,
512- out_handler = self ._out_handler_sudo_password ,
511+ err_handler = self ._err_handler_sudo_password ,
513512 stderr = subprocess .PIPE ,
514513 stdin = subprocess .PIPE ,
515514 text = True ,
516515 )
517516 sub .wait ()
518517 if sub .returncode != 0 :
519- stderr = sub .stderr .read ()
518+ # stderr = sub.stderr.read()
520519 self .tue_install_error (
521- f"Error while creating the directory({ sub .returncode } ):\n { ' ' .join (cmds )} " f"\n \n { stderr } "
520+ f"Error while creating the directory({ sub .returncode } ):\n { ' ' .join (cmds )} " # f"\n\n{stderr}"
522521 )
523522 # ToDo: This depends on behaviour of tue-install-error
524523 return False
@@ -528,7 +527,7 @@ def tue_install_cp(self, source: str, target: str) -> bool:
528527 self .tue_install_echo (" " .join (cmds ))
529528 sub = BackgroundPopen (
530529 args = cmds ,
531- out_handler = self ._out_handler_sudo_password ,
530+ err_handler = self ._err_handler_sudo_password ,
532531 stderr = subprocess .PIPE ,
533532 stdin = subprocess .PIPE ,
534533 text = True ,
0 commit comments