diff options
author | crupest <crupest@outlook.com> | 2022-11-28 13:05:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-11-28 13:05:32 +0800 |
commit | 873c9b4e39e47d2e6e1dbf40ee6f2e812c229adb (patch) | |
tree | 736f2155b95b610b8ff77bc9e0caac728fbde73b /tool/modules/check.py | |
parent | 3ab852dbd30351665cf97a10894f584a1c3ee36b (diff) | |
download | crupest-873c9b4e39e47d2e6e1dbf40ee6f2e812c229adb.tar.gz crupest-873c9b4e39e47d2e6e1dbf40ee6f2e812c229adb.tar.bz2 crupest-873c9b4e39e47d2e6e1dbf40ee6f2e812c229adb.zip |
Make io more maintainable.
Diffstat (limited to 'tool/modules/check.py')
-rw-r--r-- | tool/modules/check.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tool/modules/check.py b/tool/modules/check.py new file mode 100644 index 0000000..2a082f6 --- /dev/null +++ b/tool/modules/check.py @@ -0,0 +1,20 @@ +import sys +import re +from os.path import * + + +def check_python_version(required_version=(3, 10)): + return sys.version_info < required_version + + +def check_ubuntu(): + if not exists("/etc/os-release"): + return False + else: + with open("/etc/os-release", "r") as f: + content = f.read() + if re.search(r"NAME=\"?Ubuntu\"?", content, re.IGNORECASE) is None: + return False + if re.search(r"VERSION_ID=\"?22.04\"?", content, re.IGNORECASE) is None: + return False + return True |