()
| 1878 | |
| 1879 | |
| 1880 | def get_platform() -> Platform: |
| 1881 | try: |
| 1882 | system = platform.system().lower() |
| 1883 | platform_name = platform.platform().lower() |
| 1884 | except Exception: |
| 1885 | return "Unknown" |
| 1886 | |
| 1887 | if "iphone" in platform_name or "ipad" in platform_name: |
| 1888 | # Tested using Python3IDE on an iPhone 11 and Pythonista on an iPad 7 |
| 1889 | # system is Darwin and platform_name is a string like: |
| 1890 | # - Darwin-21.6.0-iPhone12,1-64bit |
| 1891 | # - Darwin-21.6.0-iPad7,11-64bit |
| 1892 | return "iOS" |
| 1893 | |
| 1894 | if system == "darwin": |
| 1895 | return "MacOS" |
| 1896 | |
| 1897 | if system == "windows": |
| 1898 | return "Windows" |
| 1899 | |
| 1900 | if "android" in platform_name: |
| 1901 | # Tested using Pydroid 3 |
| 1902 | # system is Linux and platform_name is a string like 'Linux-5.10.81-android12-9-00001-geba40aecb3b7-ab8534902-aarch64-with-libc' |
| 1903 | return "Android" |
| 1904 | |
| 1905 | if system == "linux": |
| 1906 | # https://distro.readthedocs.io/en/latest/#distro.id |
| 1907 | distro_id = distro.id() |
| 1908 | if distro_id == "freebsd": |
| 1909 | return "FreeBSD" |
| 1910 | |
| 1911 | if distro_id == "openbsd": |
| 1912 | return "OpenBSD" |
| 1913 | |
| 1914 | return "Linux" |
| 1915 | |
| 1916 | if platform_name: |
| 1917 | return OtherPlatform(platform_name) |
| 1918 | |
| 1919 | return "Unknown" |
| 1920 | |
| 1921 | |
| 1922 | @lru_cache(maxsize=None) |
no test coverage detected