MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / CheckAndInstallPackageUpdates

Function CheckAndInstallPackageUpdates

Scripts/InstallFEX.py:210–251  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208 return DidUpdate
209
210def CheckAndInstallPackageUpdates():
211 PackagesToInstall = GetPackagesToInstall()
212 for Package in PackagesToInstall[:]:
213 UpgradableStatus = subprocess.check_output(["apt", "list", "--upgradable", Package]).decode("utf-8")
214 Found = False
215 for Line in UpgradableStatus.split("\n"):
216 # If the package exists to be upgraded then it will appear in this list
217 # We need to check multiple lines
218 # $ apt list --upgradable <Package>
219 # With upgrade available
220 # Listing... Done
221 # <Package>/<Repo> <NewVersion> <arch> [upgradable from: <Installed version>]
222 # Without upgrade available
223 # Listing... Done
224 # <EOF>
225 if Package in Line and "upgradable" in Line:
226 Found = True
227
228 if Found == False:
229 PackagesToInstall.remove(Package)
230
231 if len(PackagesToInstall) > 0:
232 print ("Found updates for packages: {}".format(PackagesToInstall))
233 print ("This bit may ask for your password")
234
235 DidInstall = False
236 try:
237 CmdResult = subprocess.call(["sudo", "apt-get", "-y", "install"] + PackagesToInstall)
238 DidInstall = CmdResult == 0
239 except KeyboardInterrupt:
240 print ("Keyboard interrupt")
241 DidInstall = False
242 pass
243
244 if DidInstall:
245 print("Packages updated")
246 else:
247 print("Packages failed to update")
248
249 return DidInstall
250
251 return True
252
253def CheckPackageInstallStatus():
254 PackagesToInstall = GetPackagesToInstall()

Callers 1

mainFunction · 0.85

Calls 3

GetPackagesToInstallFunction · 0.85
printFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected