Reticulum/RNS/vendor/platformutils.py

47 lines
1.2 KiB
Python
Raw Normal View History

2021-12-01 11:39:06 +01:00
def get_platform():
from os import environ
2025-04-11 12:30:22 +02:00
if "ANDROID_ARGUMENT" in environ: return "android"
elif "ANDROID_ROOT" in environ: return "android"
2021-12-01 11:39:06 +01:00
else:
import sys
2022-01-12 10:07:44 +01:00
return sys.platform
2022-10-12 16:07:53 +02:00
def is_linux():
2025-04-11 12:30:22 +02:00
if get_platform() == "linux": return True
else: return False
2022-10-12 16:07:53 +02:00
2022-01-12 11:50:03 +01:00
def is_darwin():
2025-04-11 12:30:22 +02:00
if get_platform() == "darwin": return True
else: return False
2022-01-12 11:50:03 +01:00
def is_android():
2025-04-11 12:30:22 +02:00
if get_platform() == "android": return True
else: return False
2022-01-12 11:50:03 +01:00
2022-01-12 11:18:24 +01:00
def is_windows():
2025-04-11 12:30:22 +02:00
if str(get_platform()).startswith("win"): return True
else: return False
2022-01-12 11:18:24 +01:00
2025-04-08 02:33:32 +02:00
def use_epoll():
2025-04-09 17:15:38 +02:00
if is_linux() or is_android(): return True
else: return False
def use_af_unix():
if is_linux() or is_android(): return True
2025-04-08 02:33:32 +02:00
else: return False
2022-01-12 10:07:44 +01:00
def platform_checks():
2022-01-12 11:18:24 +01:00
if is_windows():
2022-01-12 10:16:59 +01:00
import sys
2025-04-11 12:30:22 +02:00
if sys.version_info.major >= 3 and sys.version_info.minor >= 8: pass
2022-01-12 10:07:44 +01:00
else:
2022-01-12 10:16:59 +01:00
import RNS
RNS.log("On Windows, Reticulum requires Python 3.8 or higher.", RNS.LOG_ERROR)
RNS.log("Please update Python to run Reticulum.", RNS.LOG_ERROR)
2022-01-12 11:18:24 +01:00
RNS.panic()
def cryptography_old_api():
import cryptography
2025-04-11 12:30:22 +02:00
if cryptography.__version__ == "2.8": return True
else: return False