Skip to content

Commit

Permalink
update python task
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrlaczykowski committed Jun 5, 2024
1 parent c65cf93 commit b4c4cdd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
34 changes: 13 additions & 21 deletions update-pc-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,25 @@
user_download_folder = os.path.join(os.path.expanduser("~"), "Downloads")
dell_support_assist_installer_filename = "SupportAssistInstaller.exe"
support_assist_installer_path = os.path.join(user_download_folder, dell_support_assist_installer_filename)

mobo_manufacturer = wmi.WMI().Win32_ComputerSystem()[0].Manufacturer
# Get the user's update choice
update_choice = display_update_menu()
# Update Dell SupportAssist
print(wmi.WMI().Win32_ComputerSystem()[0].Manufacturer)
if "Dell" in wmi.WMI().Win32_ComputerSystem()[0].Manufacturer and (update_choice == 1 or update_choice == 5) and is_supportassist_installed():
print(mobo_manufacturer)
if "Dell" in mobo_manufacturer and (update_choice == 1 or update_choice == 5) and is_supportassist_installed():
launch_dell_supportassist()
# Download the installer
if not is_supportassist_installed():
response = requests.get(support_assist_download_url, stream=True)
if response.status_code == 200:
if not os.path.exists(user_download_folder):
os.makedirs(user_download_folder)

with open(support_assist_installer_path, 'wb') as installer_file:
for chunk in response.iter_content(chunk_size=1024):
installer_file.write(chunk)

# Install Dell SupportAssist
if os.path.exists(support_assist_installer_path):
try:
subprocess.run([support_assist_installer_path], check=True)
print("Dell SupportAssist installed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error installing Dell SupportAssist: {e}")
else:
print("Error: Installer not found.")
download_installer(url=support_assist_download_url, user_download_folder=user_download_folder,installer_path=support_assist_installer_path)
# Install Dell SupportAssist
if os.path.exists(support_assist_installer_path):
try:
subprocess.run([support_assist_installer_path], check=True)
print("Dell SupportAssist installed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error installing Dell SupportAssist: {e}")
else:
print("Error: Installer not found.")
# Update Winget
# Check if the user needs to accept terms for using winget
if update_choice == 2 or update_choice == 5:
Expand Down
13 changes: 12 additions & 1 deletion utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ctypes
import subprocess
import winreg
import requests

# Function to display the update menu
def display_update_menu():
Expand Down Expand Up @@ -72,4 +73,14 @@ def is_supportassist_installed():
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Dell\SupportAssistAgent", 0, winreg.KEY_READ) as key:
return True
except FileNotFoundError:
return False
return False

def download_installer(url, user_download_folder, installer_path):
response = requests.get(url, stream=True)
if response.status_code == 200:
if not os.path.exists(user_download_folder):
os.makedirs(user_download_folder)

with open(installer_path, 'wb') as installer_file:
for chunk in response.iter_content(chunk_size=1024):
installer_file.write(chunk)

0 comments on commit b4c4cdd

Please sign in to comment.