Change how platform support is defined #379
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #377
Summary
phase anymore, but continue trying using the method.
Before
PlatformName constant, which is used to both: (1) As type for current
platform (2) As types to list in subclasses of Method in the
supported_platforms attribute.
The problem was that the supported platforms definition was not very
flexible. For example when adding support for FreeBSD (GhostBSD), in
#359, one would have needed
to add the PlatformName.FREEBSD to each of the methods, like this:
Now
Now there's the possibility to use
where the UNIX_LIKE_FOSS contains all FOSS Unix-like systems (linux+bsd,
but not MacOS or Android). Adding now systems to the list does not
require any changes in the Method subclasses supporting UNIX_LIKE_FOSS.
There are now two types of constants: (1) IdentifiedPlatformType, which
is used as the type of the current platform and (2) PlatformType, which
is used in the subclasses of Method in the supported_platforms
attribute.
New PlatformTypes
PlatformType.BSD
: Any BSD system. Currently only consists of FreeBSD butthe list may grow in the future.
PlatformType.UNIX_LIKE_FOSS
: Unix-like desktop environment, but FOSS.Includes: Linux and BSD. Excludes: Android (mobile), MacOS (non-FOSS),
ChromeOS (non-FOSS)
PlatformType.ANY
: Any platform.New behavior
Platform support check does not fail (but returns "I don't know"/None)
if the platform could not be detected. This means that methods like
org.gnome.SessionManager will be tried also on non-linux systems (which
might be using Gnome).
BACKWARDS INCOMPATIBLE CHANGES
The name of the enum class to use in Method.supported_platforms was
changed from PlatformName to PlatformType. This only breaks code which
uses custom wakepy.Methods, and the fix is to rename the variable.
Other small changes
get_platform_supported() now takes the current platform and supported
platforms as arguments (previously, used Method and current platform).