Merge pull request 'clan-cli: add a check for the flatpak sandbox' (#1088) from a-kenji-clan-cli/check/flatpak-sandbox into main
This commit is contained in:
commit
439293a079
@ -6,7 +6,18 @@ from pathlib import Path
|
|||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from . import backups, config, facts, flakes, flash, history, machines, secrets, vms
|
from . import (
|
||||||
|
backups,
|
||||||
|
config,
|
||||||
|
facts,
|
||||||
|
flakes,
|
||||||
|
flash,
|
||||||
|
flatpak,
|
||||||
|
history,
|
||||||
|
machines,
|
||||||
|
secrets,
|
||||||
|
vms,
|
||||||
|
)
|
||||||
from .custom_logger import setup_logging
|
from .custom_logger import setup_logging
|
||||||
from .dirs import get_clan_flake_toplevel
|
from .dirs import get_clan_flake_toplevel
|
||||||
from .errors import ClanCmdError, ClanError
|
from .errors import ClanCmdError, ClanError
|
||||||
@ -129,6 +140,8 @@ def main() -> None:
|
|||||||
if args.debug:
|
if args.debug:
|
||||||
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
|
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
|
||||||
log.debug("Debug log activated")
|
log.debug("Debug log activated")
|
||||||
|
if flatpak.is_flatpak():
|
||||||
|
log.debug("Running inside a flatpak sandbox")
|
||||||
else:
|
else:
|
||||||
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
||||||
|
|
||||||
|
16
pkgs/clan-cli/clan_cli/flatpak.py
Normal file
16
pkgs/clan-cli/clan_cli/flatpak.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def is_flatpak() -> bool:
|
||||||
|
"""Check if the current process is running inside a flatpak sandbox."""
|
||||||
|
# FLATPAK_ID environment variable check
|
||||||
|
flatpak_env = "FLATPAK_ID" in os.environ
|
||||||
|
|
||||||
|
flatpak_file = False
|
||||||
|
try:
|
||||||
|
with open("/.flatpak-info"):
|
||||||
|
flatpak_file = True
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return flatpak_env and flatpak_file
|
Loading…
Reference in New Issue
Block a user