diff --git a/.mailmap b/.mailmap index c039765..86f4222 100644 --- a/.mailmap +++ b/.mailmap @@ -1,11 +1,11 @@ Gregor von Laszewski -J.P Fleischer <70083705+stapmoshun@users.noreply.github.com> -J.P Fleischer +J.P. Fleischer <70083705+stapmoshun@users.noreply.github.com> +J.P. Fleischer +J.P. Fleischer <70083705+jpfleischer@users.noreply.github.com> Robert Knuuti Fugang Wang Badi Abdul-Wahid Andrew Holland -J.P Fleisher <70083705+jpfleischer@users.noreply.github.com> Rick Otten Robert Knuuti Dave DeMeulenaere @@ -14,7 +14,6 @@ Anthon van der Neut Anthony Orlowski Jackson Miskill <103867645+j-miskill@users.noreply.github.com> Toble007 <74217657+Toble007@users.noreply.github.com> -J.P. Fleischer <70083705+jpfleischer@users.noreply.github.com> Ketan Pimparkar <43309148+kpimparkar@users.noreply.github.com> Vafa Andalibi Alex Beck <105373869+abeck14@users.noreply.github.com> diff --git a/VERSION b/VERSION index dc128b2..753b278 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.54 +5.0.58 diff --git a/pyproject.toml b/pyproject.toml index 2dea91e..255ad9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires = [ [project] name = "cloudmesh-common" -version = "5.0.54" +version = "5.0.58" description = "A set of useful APIs for cloudmesh" readme = "README.md" requires-python = ">=3.8" diff --git a/src/cloudmesh/common/Shell.py b/src/cloudmesh/common/Shell.py index 75c702d..93fdd37 100755 --- a/src/cloudmesh/common/Shell.py +++ b/src/cloudmesh/common/Shell.py @@ -621,8 +621,27 @@ def install_chocolatey(): # Join the script directory with "bin" bin_directory = os.path.join(script_directory, "bin") - print(f"Looking in {bin_directory} for install script...") + print(f"Looking in {bin_directory} for install script...") + # Check if the bin_directory exists + if not os.path.exists(bin_directory): + Console.info("dir does not exist? downloading script...") + # Create the directories if they don't exist + os.makedirs(bin_directory, exist_ok=True) + + # If it doesn't exist, download the script from the URL + url = "https://raw.githubusercontent.com/cloudmesh/cloudmesh-common/main/src/cloudmesh/common/bin/win-setup.bat" + response = requests.get(url) + + # Check if the request was successful + if response.status_code == 200: + # If it was, save the script to a file + with open(rf"{bin_directory}\win-setup.bat", "w") as file: + file.write(response.text) + else: + # If the request was not successful, print an error message and return + Console.error("Failed to download the script.") + return False # Command to install Chocolatey using the Command Prompt chocolatey_install_command = rf"powershell Start-Process -Wait -FilePath {bin_directory}\win-setup.bat" print(chocolatey_install_command) @@ -639,6 +658,12 @@ def install_chocolatey(): "You are currently standing in a non-existent directory." ) return False + # Check if the command failed + if completed_process.returncode != 0: + # If it failed, print an error message and return False + Console.error(f"Failed: {completed_process.stderr}") + return False + print(completed_process) Console.ok("Chocolatey installed") return True @@ -2192,6 +2217,7 @@ def mkdir(cls, directory): Console.error(e, traceflag=True) return False + @classmethod def unzip(cls, source_filename, dest_dir): """Unzips a file into the destination directory. diff --git a/src/cloudmesh/common/parameter.py b/src/cloudmesh/common/parameter.py index 25a5d2a..16620d0 100644 --- a/src/cloudmesh/common/parameter.py +++ b/src/cloudmesh/common/parameter.py @@ -1,5 +1,6 @@ from cloudmesh.common.dotdict import dotdict from hostlist import expand_hostlist +from itertools import product class Parameter(object): @@ -212,3 +213,18 @@ def separate(text, sep=":"): return text.split(sep, 1) else: return None, text + + @staticmethod + def permutate(data): + """returns a list of all permutations of the dict + + Args: + data: the dict + + Returns: + list of dicts + """ + keys = data.keys() + values = data.values() + permutations = [dict(zip(keys, v)) for v in product(*values)] + return permutations