Skip to content

Commit

Permalink
Fix install Scoop
Browse files Browse the repository at this point in the history
  • Loading branch information
panther7 authored and Filip Mösner committed Dec 15, 2022
1 parent c3c0164 commit 92100ef
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
9 changes: 4 additions & 5 deletions wingetui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def detectWinget(self):
def detectScoop(self):
try:
self.callInMain.emit(lambda: self.loadingText.setText(_("Locating Scoop...")))
o = subprocess.run(f"powershell -Command scoop -v", shell=True, stdout=subprocess.PIPE)
o = subprocess.run(f"{scoopHelpers.scoop} -v", shell=True, stdout=subprocess.PIPE)
print(o.stdout)
print(o.stderr)
globals.componentStatus["scoopFound"] = o.returncode == 0
Expand All @@ -211,22 +211,21 @@ def detectScoop(self):
try:
if not getSettings("DisableUpdateIndexes"):
self.callInMain.emit(lambda: self.loadingText.setText(_("Clearing Scoop cache...")))
p = subprocess.Popen(f"powershell -Command scoop cache rm *", shell=True, stdout=subprocess.PIPE)

p = subprocess.Popen(f"{scoopHelpers.scoop} cache rm *", shell=True, stdout=subprocess.PIPE)
p.wait()
except Exception as e:
print(e)
try:
if(getSettings("EnableScoopCleanup")):
p2 = subprocess.Popen(f"powershell -Command scoop cleanup --all", shell=True, stdout=subprocess.PIPE)
p2 = subprocess.Popen(f"{scoopHelpers.scoop} cleanup --all", shell=True, stdout=subprocess.PIPE)
p2.wait()
except Exception as e:
report(e)
self.loadStatus += 1
try:
if not getSettings("DisableUpdateIndexes"):
self.callInMain.emit(lambda: self.loadingText.setText(_("Updating Scoop sources...")))
o = subprocess.run(f"powershell -Command scoop update", shell=True, stdout=subprocess.PIPE)
o = subprocess.run(f"{scoopHelpers.scoop} update", shell=True, stdout=subprocess.PIPE)
self.callInMain.emit(lambda: self.loadingText.setText(_("Updated Scoop sources")))
except Exception as e:
print(e)
Expand Down
7 changes: 1 addition & 6 deletions wingetui/resources/install_scoop.cmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
@echo off
echo This script will install Scoop and the dependencies required by WingetUI.
pause
powershell -NoProfile -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser"
echo Installing scoop...
powershell -NoProfile -Command "iex ""& {$(irm get.scoop.sh)} -RunAsAdmin"""
echo Installing git...
powershell -NoProfile -Command "scoop install git"
echo Done!
powershell -ExecutionPolicy ByPass -File "%~dp0\install_scoop.ps1"
pause
10 changes: 10 additions & 0 deletions wingetui/resources/install_scoop.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Write-Output "Installing scoop..."

Invoke-Expression "& {$(Invoke-RestMethod get.scoop.sh)}"

If (-Not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Output "Installing git..."
scoop install git
}

Write-Output "Done!"
7 changes: 3 additions & 4 deletions wingetui/resources/uninstall_scoop.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
echo This script will remove scoop from your machine.
echo Removing scoop implies removing all scoop installed packages, buckets and preferences, and might also erase valuable user data related to the affected packages
echo|set/p="Press <ENTER> to continue or CLOSE this window to abort this process"&runas/u: "">NUL
echo Installing scoop...
powershell -NoProfile -Command "scoop uninstall -p scoop"
echo Reverting ExecutionPolicy
powershell -NoProfile -Command "Set-ExecutionPolicy Restricted -Scope CurrentUser"
echo.
echo Uninstalling scoop...
powershell -ExecutionPolicy ByPass -Command "scoop uninstall -p scoop"
echo Done!
pause
2 changes: 2 additions & 0 deletions wingetui/scoopHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')

scoop = "powershell -ExecutionPolicy ByPass -Command scoop"

def searchForPackage(signal: Signal, finishSignal: Signal) -> None:
print("🟢 Starting scoop search...")
p = subprocess.Popen(' '.join(["powershell", "-Command", "scoop", "search"]), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, cwd=os.getcwd(), env=os.environ, shell=True)
Expand Down

0 comments on commit 92100ef

Please sign in to comment.