Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 30 additions & 2 deletions Windows-Standalone/chocolatey.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import json
import os
from dependencies import run_command_with_progress
from datetime import datetime
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import (
Expand Down Expand Up @@ -113,6 +114,10 @@ def init_ui(self):

# Layout
layout = QVBoxLayout()
from PyQt5.QtWidgets import QProgressBar
self.progress_bar = QProgressBar()
self.progress_bar.setValue(0)
layout.addWidget(self.progress_bar)
layout.addWidget(self.status_label)
layout.addWidget(self.install_button)
layout.addWidget(self.update_button)
Expand Down Expand Up @@ -183,7 +188,15 @@ def install_chocolatey(self):
)

try:
os.system(f"powershell -Command \"{install_script}\"")
from dependencies import run_command_with_progress

def update_progress(output):
self.progress_bar.setValue(min(self.progress_bar.value() + 2, 95))
QApplication.processEvents()

run_command_with_progress(f"powershell -Command \"{install_script}\"", update_progress)
self.progress_bar.setValue(100)

log_info("Chocolatey installed successfully.")
QMessageBox.information(self, "Success", "Chocolatey installed successfully.")
self.installed = True
Expand All @@ -200,11 +213,26 @@ def update_chocolatey(self):

update_script = "choco upgrade chocolatey -y"

# Reset progress bar
self.progress_bar.setValue(0)

try:
os.system(f"powershell -Command \"{update_script}\"")
# Progress callback
def update_progress(output):
self.progress_bar.setValue(min(self.progress_bar.value() + 5, 95))
QApplication.processEvents()

# Run command with progress
run_command_with_progress(update_script, update_progress)

# Complete progress
self.progress_bar.setValue(100)

log_info("Chocolatey updated successfully.")
QMessageBox.information(self, "Success", "Chocolatey updated successfully.")

self.check_status()

except Exception as e:
log_error(f"Failed to update Chocolatey: {e}")
QMessageBox.critical(self, "Error", f"Failed to update Chocolatey: {e}")
Expand Down
47 changes: 46 additions & 1 deletion Windows-Standalone/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@
from datetime import datetime
from logging_setup import log_info, log_error, log_warning



def run_command_with_progress(command, progress_callback=None):
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True,
text=True
)

for line in process.stdout:
if progress_callback:
progress_callback(line.strip())

process.wait()
return process.returncode











# Load dependencies from the JSON file
def load_dependencies():
json_path = "install_details.json"
Expand Down Expand Up @@ -34,7 +62,24 @@ def install_dependencies_with_choco(dependencies):
log_info("Installing dependencies with Chocolatey...")
for dep in dependencies:
log_info(f"Installing {dep}...")
run_command(f"choco install {dep} -y")

from dependencies import run_command_with_progress # if not already added

progress = 0

def progress_callback(output):
global progress
progress = min(progress + 2, 100)
print(f"Progress: {progress}% | {output}")

run_command_with_progress(f"choco install {dep} -y", progress_callback)



def progress_callback(output):
print("Installing:", output)

run_command_with_progress(f"choco install {dep} -y", progress_callback)

# Update the JSON file for dependencies
def update_dependency_status():
Expand Down
Loading