Fix isLatest() and add canInstallUpdate() (#1263)

* Revert "Update isLatest() (#1253)"

This reverts commit b129fa3757.

* Add canInstallUpdate method

---------

Co-authored-by: Benjamin Oddou <85166574+BenjaminOddou@users.noreply.github.com>
This commit is contained in:
JonnyWong16 2023-10-03 21:18:18 -07:00 committed by GitHub
parent 75fb265800
commit 44fc13f2b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -615,7 +615,8 @@ class PlexServer(PlexObject):
return self.checkForUpdate(force=force, download=download)
def checkForUpdate(self, force=True, download=False):
""" Returns a :class:`~plexapi.base.Release` object containing release info.
""" Returns a :class:`~plexapi.server.Release` object containing release info
if an update is available or None if no update is available.
Parameters:
force (bool): Force server to check for new releases
@ -629,12 +630,19 @@ class PlexServer(PlexObject):
return releases[0]
def isLatest(self):
""" Check if the installed version of PMS is the latest. """
""" Returns True if the installed version of Plex Media Server is the latest. """
release = self.checkForUpdate(force=True)
return release is None
def canInstallUpdate(self):
""" Returns True if the newest version of Plex Media Server can be installed automatically.
(e.g. Windows and Mac can install updates automatically, but Docker and NAS devices cannot.)
"""
release = self.query('/updater/status')
return utils.cast(bool, release.get('canInstall'))
def installUpdate(self):
""" Install the newest version of Plex Media Server. """
""" Automatically install the newest version of Plex Media Server. """
# We can add this but dunno how useful this is since it sometimes
# requires user action using a gui.
part = '/updater/apply'