Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cloudmesh/cloudmesh-common
Browse files Browse the repository at this point in the history
  • Loading branch information
laszewsk committed Feb 8, 2024
2 parents c27e5fc + e207a77 commit c69cb08
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
7 changes: 3 additions & 4 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Gregor von Laszewski <[email protected]>
J.P Fleischer <[email protected]>
J.P Fleischer <[email protected]>
J.P. Fleischer <[email protected]>
J.P. Fleischer <[email protected]>
J.P. Fleischer <[email protected]>
Robert Knuuti <[email protected]>
Fugang Wang <[email protected]>
Badi Abdul-Wahid <[email protected]>
Andrew Holland <[email protected]>
J.P Fleisher <[email protected]>
Rick Otten <[email protected]>
Robert Knuuti <[email protected]>
Dave DeMeulenaere <[email protected]>
Expand All @@ -14,7 +14,6 @@ Anthon van der Neut <[email protected]>
Anthony Orlowski <[email protected]>
Jackson Miskill <[email protected]>
Toble007 <[email protected]>
J.P. Fleischer <[email protected]>
Ketan Pimparkar <[email protected]>
Vafa Andalibi <[email protected]>
Alex Beck <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.54
5.0.58
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 27 additions & 1 deletion src/cloudmesh/common/Shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions src/cloudmesh/common/parameter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from cloudmesh.common.dotdict import dotdict
from hostlist import expand_hostlist
from itertools import product


class Parameter(object):
Expand Down Expand Up @@ -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

0 comments on commit c69cb08

Please sign in to comment.