Skip to content

Commit

Permalink
Merge pull request #2 from grubyhs/feature/placzykowski/moving-dell-t…
Browse files Browse the repository at this point in the history
…o-external-def

Feature/placzykowski/moving dell to external def
  • Loading branch information
piotrlaczykowski authored Jun 6, 2024
2 parents fb06062 + 2d4c85d commit 60d0122
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 47 deletions.
40 changes: 40 additions & 0 deletions dell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import winreg
from utilities import *
# Define the URL to download Dell SupportAssist
support_assist_download_url = "https://downloads.dell.com/serviceability/catalog/SupportAssistInstaller.exe"

# Set the installer path to the specified download folder
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)
def launch_dell_support_assist():
try:
ps_command = (
"Get-AppxPackage | Where-Object {$_.Name -like 'DellSupportAssist'} | "
"Foreach-Object {"
"$packageName = $_.PackageFamilyName;"
"Start-Process shell:AppsFolder\\$packageName!App;"
"}"
)
subprocess.run(["powershell", "-Command", ps_command], check=True)
except subprocess.CalledProcessError as e:
print(f"Error launching the UWP app: {e}")


def install_support_assist():
download_installer(url=support_assist_download_url, user_download_folder=user_download_folder,installer_path=support_assist_installer_path)
# Install Dell SupportAssist
install_program(support_assist_installer_path)

# Check if Dell SupportAssist is already installed
def launch_dell_support_assist():
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Dell\SupportAssistAgent", 0, winreg.KEY_READ):
launch_dell_support_assist()
except FileNotFoundError:
install_support_assist()

def dell():
mobo_manufacturer()
launch_dell_support_assist()
26 changes: 24 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
wmi
requests
altgraph==0.17.4
bottle==0.12.25
bottle-websocket==0.2.9
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
Eel==0.16.0
future==1.0.0
gevent==24.2.1
gevent-websocket==0.10.1
greenlet==3.0.3
idna==3.7
packaging==24.0
pefile==2023.2.7
pycparser==2.22
pyparsing==3.1.2
pywin32==306
pywin32-ctypes==0.2.2
requests==2.31.0
urllib3==2.2.1
whichcraft==0.6.1
WMI==1.5.1
zope.event==5.0
zope.interface==6.3
25 changes: 3 additions & 22 deletions update-pc-script.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
import os
import sys
import subprocess
import wmi
import requests
from utilities import *
from dell import *

if __name__ == "__main__":
if run_as_admin():
try:
# Define the URL to download Dell SupportAssist
support_assist_download_url = "https://downloads.dell.com/serviceability/catalog/SupportAssistInstaller.exe"

# Set the installer path to the specified download folder
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(mobo_manufacturer)
if "Dell" in mobo_manufacturer and (update_choice == 1 or update_choice == 5) and is_support_assist_installed():
launch_dell_support_assist()
# Download the installer
if not is_support_assist_installed():
download_installer(url=support_assist_download_url, user_download_folder=user_download_folder,installer_path=support_assist_installer_path)
# Install Dell SupportAssist
install_program(support_assist_installer_path)
if (update_choice == 1 or update_choice == 5):
dell()
# Update Winget
# Check if the user needs to accept terms for using winget
if update_choice == 2 or update_choice == 5:
Expand Down
28 changes: 5 additions & 23 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import sys
import ctypes
import subprocess
import winreg
import requests
import wmi

# Function to display the update menu
def display_update_menu():
Expand All @@ -20,6 +20,10 @@ def display_update_menu():
else:
print("Invalid choice. Please enter a valid option.")

def mobo_manufacturer():
motherboard = wmi.WMI().Win32_ComputerSystem()[0].Manufacturer
return motherboard

def run_as_admin():
if ctypes.windll.shell32.IsUserAnAdmin():
return True
Expand Down Expand Up @@ -53,28 +57,6 @@ def upgrade_choco_packages():
except subprocess.CalledProcessError as e:
print(f"Error upgrading Chocolatey packages: {e}")


def launch_dell_support_assist():
try:
ps_command = (
"Get-AppxPackage | Where-Object {$_.Name -like 'DellSupportAssist'} | "
"Foreach-Object {"
"$packageName = $_.PackageFamilyName;"
"Start-Process shell:AppsFolder\\$packageName!App;"
"}"
)
subprocess.run(["powershell", "-Command", ps_command], check=True)
except subprocess.CalledProcessError as e:
print(f"Error launching the UWP app: {e}")

# Check if Dell SupportAssist is already installed
def is_support_assist_installed():
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Dell\SupportAssistAgent", 0, winreg.KEY_READ):
return True
except FileNotFoundError:
return False

def download_installer(url, user_download_folder, installer_path):
response = requests.get(url, stream=True)
if response.status_code == 200:
Expand Down

0 comments on commit 60d0122

Please sign in to comment.