• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

localstack / localstack / 20565403496

29 Dec 2025 05:11AM UTC coverage: 84.103% (-2.8%) from 86.921%
20565403496

Pull #13567

github

web-flow
Merge 4816837a5 into 2417384aa
Pull Request #13567: Update ASF APIs

67166 of 79862 relevant lines covered (84.1%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.29
/localstack-core/localstack/utils/platform.py
1
import platform
1✔
2
from functools import lru_cache
1✔
3

4

5
def is_mac_os() -> bool:
1✔
6
    return "darwin" == platform.system().lower()
1✔
7

8

9
def is_linux() -> bool:
1✔
10
    return "linux" == platform.system().lower()
1✔
11

12

13
def is_windows() -> bool:
1✔
14
    return "windows" == platform.system().lower()
1✔
15

16

17
@lru_cache
1✔
18
def is_debian() -> bool:
1✔
19
    from localstack.utils.files import load_file
1✔
20

21
    return "Debian" in load_file("/etc/issue", "")
1✔
22

23

24
@lru_cache
1✔
25
def is_redhat() -> bool:
1✔
26
    from localstack.utils.files import load_file
×
27

28
    return "rhel" in load_file("/etc/os-release", "")
×
29

30

31
class Arch(str):
1✔
32
    """LocalStack standardised machine architecture names"""
33

34
    amd64 = "amd64"
1✔
35
    arm64 = "arm64"
1✔
36

37

38
def standardized_arch(arch: str):
1✔
39
    """
40
    Returns LocalStack standardised machine architecture name.
41
    """
42
    if arch == "x86_64":
1✔
43
        return Arch.amd64
1✔
44
    if arch == "aarch64":
×
45
        return Arch.arm64
×
46
    return arch
×
47

48

49
def get_arch() -> str:
1✔
50
    """
51
    Returns the current machine architecture.
52
    """
53
    arch = platform.machine()
1✔
54
    return standardized_arch(arch)
1✔
55

56

57
# TODO: implement proper architecture detection (e.g., test whether an architecture-specific binary actually runs)
58
#   because this naive implementation does not cover cross-architecture emulation
59
def is_arm_compatible() -> bool:
1✔
60
    """Returns true if the current machine is compatible with ARM instructions and false otherwise."""
61
    return get_arch() == Arch.arm64
×
62

63

64
def get_os() -> str:
1✔
65
    if is_mac_os():
×
66
        return "osx"
×
67
    if is_linux():
×
68
        return "linux"
×
69
    if is_windows():
×
70
        return "windows"
×
71
    raise ValueError("Unable to determine local operating system")
×
72

73

74
def in_docker() -> bool:
1✔
75
    from localstack import config
1✔
76

77
    return config.in_docker()
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc