@@ -837,6 +837,48 @@ def tue_install_snap(self, pkgs: List[str]) -> bool:
837837 return True
838838
839839 def tue_install_snap_now (self , pkgs : List [str ]) -> bool :
840+ self .tue_install_debug (f"tue-install-snap-now { pkgs = } " )
841+
842+ if not pkgs :
843+ self .tue_install_error ("Invalid tue-install-snap-now call: needs packages as argument" )
844+ # ToDo: This depends on behaviour of tue-install-error
845+ return False
846+
847+ self .tue_install_system_now (["snapd" ])
848+
849+ cmd = "snap list"
850+ cmd , cmds = _which_split_cmd (cmd )
851+ self .tue_install_echo (repr (cmd ))
852+ sub = BackgroundPopen (args = cmds , err_handler = self ._err_handler , stdout = sp .PIPE , text = True )
853+ sub .wait ()
854+ if sub .returncode != 0 :
855+ self .tue_install_error (f"Error while getting snap list({ sub .returncode } ):\n { repr (cmd )} " )
856+ # ToDo: This depends on behaviour of tue-install-error
857+ return False
858+
859+ snaps_installed = sub .stdout .read ().splitlines ()[1 :]
860+ snaps_installed = [snap .split ()[0 ] for snap in snaps_installed ]
861+ snaps_to_install = []
862+ for pkg in pkgs :
863+ if pkg not in snaps_installed :
864+ snaps_to_install .append (pkg )
865+ self .tue_install_debug (f"Snap '{ pkg } ' is not installed yet" )
866+ else :
867+ self .tue_install_debug (f"Snap '{ pkg } ' is already installed" )
868+
869+ if not snaps_to_install :
870+ self .tue_install_debug ("No snaps to install" )
871+ return True
872+
873+ for pkg in snaps_to_install :
874+ cmd = f"sudo snap install --classic { pkg } "
875+ sub = self ._default_background_popen (cmd )
876+ breakpoint ()
877+ if sub .returncode != 0 :
878+ self .tue_install_error (f"An error occurred while installing snap: { pkg } " )
879+ # ToDo: This depends on behaviour of tue-install-error
880+ return False
881+
840882 return True
841883
842884 def tue_install_gem (self , pkgs : List [str ]) -> bool :
0 commit comments