Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how platform support is defined #379

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

fohrloop
Copy link
Owner

@fohrloop fohrloop commented Sep 13, 2024

Closes: #377

Summary

  • Replace PlatformName with PlatformType and IdentifiedPlatformType
  • If platform is unknown, do not fail in the platform check
    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:

class SomeMethod(Method):
    supported_platforms = (PlatformName.LINUX, PlatformName.FREEBSD) 

Now

Now there's the possibility to use

class SomeMethod(Method):
    supported_platforms = (PlatformType.UNIX_LIKE_FOSS, ) 

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 but
the 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).

@fohrloop fohrloop force-pushed the issue-377-improve-how-supported-platforms-are-defined branch from 962bdc0 to a9f41b3 Compare September 13, 2024 18:10
@fohrloop fohrloop force-pushed the issue-377-improve-how-supported-platforms-are-defined branch from a9f41b3 to 37c3eaa Compare September 13, 2024 18:58
@fohrloop fohrloop merged commit 6b3b0f8 into main Sep 13, 2024
14 checks passed
@fohrloop fohrloop deleted the issue-377-improve-how-supported-platforms-are-defined branch September 17, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve how supported platforms are defined in Methods
1 participant