diff options
| author | AAGaming <aagaming@riseup.net> | 2023-08-26 22:06:01 -0400 |
|---|---|---|
| committer | marios8543 <marios8543@gmail.com> | 2023-10-17 17:08:23 +0300 |
| commit | e2d708a6af0ec75c557b11d3a442af57240302b4 (patch) | |
| tree | 4d784163cc7fe0e7eb12a0a5de75aae1e2a64501 /backend/localplatformlinux.py | |
| parent | 1e1e82ed71524ad5cb879e80fc4f7615d59fdba2 (diff) | |
| download | decky-loader-e2d708a6af0ec75c557b11d3a442af57240302b4.tar.gz decky-loader-e2d708a6af0ec75c557b11d3a442af57240302b4.zip | |
begin adding static types to backend code
Diffstat (limited to 'backend/localplatformlinux.py')
| -rw-r--r-- | backend/localplatformlinux.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/backend/localplatformlinux.py b/backend/localplatformlinux.py index 811db8a6..58b9dbc2 100644 --- a/backend/localplatformlinux.py +++ b/backend/localplatformlinux.py @@ -29,21 +29,17 @@ def _get_effective_user_group() -> str: return grp.getgrgid(_get_effective_user_group_id()).gr_name # Get the user owner of the given file path. -def _get_user_owner(file_path) -> str: +def _get_user_owner(file_path: str) -> str: return pwd.getpwuid(os.stat(file_path).st_uid).pw_name -# Get the user group of the given file path. -def _get_user_group(file_path) -> str: - return grp.getgrgid(os.stat(file_path).st_gid).gr_name +# Get the user group of the given file path, or the user group hosting the plugin loader +def _get_user_group(file_path: str | None = None) -> str: + return grp.getgrgid(os.stat(file_path).st_gid if file_path is not None else _get_user_group_id()).gr_name # Get the group id of the user hosting the plugin loader def _get_user_group_id() -> int: return pwd.getpwuid(_get_user_id()).pw_gid -# Get the group of the user hosting the plugin loader -def _get_user_group() -> str: - return grp.getgrgid(_get_user_group_id()).gr_name - def chown(path : str, user : UserType = UserType.HOST_USER, recursive : bool = True) -> bool: user_str = "" @@ -146,7 +142,7 @@ def get_privileged_path() -> str: return path -def _parent_dir(path : str) -> str: +def _parent_dir(path : str | None) -> str | None: if path == None: return None @@ -166,7 +162,7 @@ def get_unprivileged_path() -> str: # Expected path of loader binary is /home/deck/homebrew/service/PluginLoader path = _parent_dir(_parent_dir(os.path.realpath(sys.argv[0]))) - if not os.path.exists(path): + if path != None and not os.path.exists(path): path = None if path == None: |
