Add Python Version Check to Python Scripts

ISSUE #204 : Running on versions prior to 3.10 will fail, due to
the use of `match` statements. Other parts of the script assume
a recent Python also, and the system as a whole expects a recent
version of Ubuntu.

`pythonCheck.py` polls `sys.version_info` to detect the in-use
version of Python. If the version is prior to 3.10, it bails out
with the message "LibreQoS requires Python 3.10 or greater".

This should help with outdated OS detection in general.
This commit is contained in:
Herbert Wolverson committed 2023-02-15 15:00:53 +00:00
1 parent 85caa6be19
commit f8f438e8d7
4 files changed
+20 -1

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
#!/usr/bin/python3
from pythonCheck import checkPythonVersion
checkPythonVersion()
import csv
import io
import ipaddress
+2
View File
@@ -1,3 +1,5 @@
from pythonCheck import checkPythonVersion
checkPythonVersion()
import requests
from ispConfig import excludeSites, findIPv6usingMikrotik, bandwidthOverheadFactor, exceptionCPEs, splynx_api_key, splynx_api_secret, splynx_api_url
from integrationCommon import isIpv4Permitted
+2
View File
@@ -1,3 +1,5 @@
from pythonCheck import checkPythonVersion
checkPythonVersion()
import requests
import os
import csv
+14
View File
@@ -0,0 +1,14 @@
import os
def checkPythonVersion():
# Perform a version check
import sys
print("Running Python Version " + sys.version)
version_ok = True
if sys.version_info[0] < 3:
version_ok = False
if sys.version_info[0]==3 and sys.version_info[1] < 10:
version_ok = False
if version_ok == False:
print("LibreQoS requires Python 3.10 or greater.")
os._exit(-1)