Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync #6

Merged
merged 8 commits into from
Jun 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changes to install java
  • Loading branch information
gokulprathin8 committed Jun 2, 2023
commit 51ebdd6b4889279db3ef0f33688c9eceae3c4395
35 changes: 26 additions & 9 deletions pygeoweaver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,45 @@ def is_java_installed():
# Check if Java is installed by running "java -version" command
subprocess.run(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return True
except FileNotFoundError:
except subprocess.CalledProcessError:
return False

def install_java():
system = platform.system()
if system == "Darwin":
# Install Java on MacOS using Homebrew
os.system("/bin/bash -c '/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"'")
os.system(
"/bin/bash -c '/usr/bin/ruby -e \"$(curl -fsSL "
"https://raw.githubusercontent.com/Homebrew/install/master/install)\"'")
os.system("brew install openjdk")
elif system == "Linux":
# Install Java on Linux using apt package manager
os.system("sudo apt update")
os.system("sudo apt install -y default-jre default-jdk")
# need to check if the package manager type is apt or yum
# arch / debian
package_manager = None
if os.path.exists("/usr/bin/apt"):
package_manager = "apt"
elif os.path.exists("/usr/bin/yum"):
package_manager = "yum"

if package_manager:
os.system(f"sudo {package_manager} update")
os.system(f"sudo {package_manager} install -y default-jre default-jdk")
else:
print("Package manager not found. Unable to install Java.")
sys.exit(1)
elif system == "Windows":
# Install Java on Windows using Chocolatey package manager
os.system("powershell -Command \"Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\"")
# note: this requires admin access to the pc, else it will fail saying
# Access to the path 'C:\ProgramData\chocolatey\lib-bad' is denied.
os.system(
"powershell -Command \"Set-ExecutionPolicy Bypass -Scope Process -Force; ["
"System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object "
"System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\"")
os.system("choco install -y openjdk")
else:
print("Unsupported operating system.")
sys.exit(1)

def checkJava():

def check_java():
# Check if Java is installed
if is_java_installed():
print("Java is already installed.")
Expand Down