-
Notifications
You must be signed in to change notification settings - Fork 0
/
WhirlpoolGLI
72 lines (55 loc) · 2.33 KB
/
WhirlpoolGLI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import os
import subprocess
import wget
import tarfile
import re
# Define the desired OpenJDK version
openjdk_version = "19"
# Run the installation command
install_command = f"sudo apt install -y openjdk-{openjdk_version}-jre-headless"
try:
subprocess.run(install_command, shell=True, check=True)
print(f"OpenJDK {openjdk_version} installed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error installing OpenJDK {openjdk_version}: {e}")
# Define the directory path
directory_path = os.path.expanduser("~/Whirlpool")
try:
# Create the directory if it doesn't exist
os.makedirs(directory_path, exist_ok=True)
print(f"Directory {directory_path} created successfully.")
except OSError as e:
print(f"Error creating directory {directory_path}: {e}")
# Define the directory path
directory_path = os.path.expanduser("~/Whirlpool")
try:
# Create the directory if it doesn't exist
os.makedirs(directory_path, exist_ok=True)
print(f"Directory {directory_path} created successfully.")
# Change to the Whirlpool directory
os.chdir(directory_path)
# Download the JAR file
download_command = "wget https://code.samourai.io/whirlpool/whirlpool-client-cli/uploads/63621e145967f536a562851853bd0990/whirlpool-client-cli-0.10.16-run.jar"
subprocess.run(download_command, shell=True, check=True)
print("JAR file downloaded successfully.")
except OSError as e:
print(f"Error creating directory or downloading JAR file: {e}")
except subprocess.CalledProcessError as e:
print(f"Error running wget command: {e}")
# Define the command to be executed
command = ["java", "-jar", "whirlpool-client-cli-0.10.16-run.jar", "--init"]
# Define the working directory
working_directory = "/home/humble/Whirlpool"
# Expand the tilde (~) to the user's home directory
expanded_working_directory = subprocess.check_output(["echo", "-n", working_directory], universal_newlines=True).strip()
# Change to the working directory and execute the command
try:
# Change the current working directory
os.chdir(expanded_working_directory)
# Execute the command
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"Command failed with exit code {e.returncode}")
except FileNotFoundError:
print("The specified directory does not exist.")