()
| 208 | return DidUpdate |
| 209 | |
| 210 | def 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 | |
| 253 | def CheckPackageInstallStatus(): |
| 254 | PackagesToInstall = GetPackagesToInstall() |
no test coverage detected