()
| 3 | import sys |
| 4 | |
| 5 | def check_node(): |
| 6 | import re |
| 7 | |
| 8 | def extract_number(s): |
| 9 | if isinstance(s, str): |
| 10 | # Use regular expression to find all numbers in the text |
| 11 | numbers = re.findall(r"\b\d+(?:\.\d+)?\b", s) |
| 12 | # Convert the extracted strings to floats or integers |
| 13 | ls = [float(num) if "." in num else int(num) for num in numbers] |
| 14 | |
| 15 | return ls[0] if ls else None |
| 16 | |
| 17 | if isinstance(s, int) or isinstance(s, float): |
| 18 | return s |
| 19 | |
| 20 | try: |
| 21 | NODE_BIN = os.environ.get("NODE_BIN") or ( |
| 22 | getattr(os.environ, "NODE_BIN") |
| 23 | if hasattr(os.environ, "NODE_BIN") |
| 24 | else "node" |
| 25 | ) |
| 26 | node_version = subprocess.check_output( |
| 27 | [NODE_BIN, "-v"], universal_newlines=True |
| 28 | ).replace("v", "") |
| 29 | major_version = int(extract_number(node_version)) |
| 30 | |
| 31 | MIN_VER = 14 |
| 32 | if major_version < MIN_VER: |
| 33 | print( |
| 34 | f"Your Node.js version is {major_version}, which is less than {MIN_VER}. To use Botasaurus via a User Interface, you need Node.js {MIN_VER}+, Kindly install it by visiting https://nodejs.org/." |
| 35 | ) |
| 36 | sys.exit(1) |
| 37 | except Exception as e: |
| 38 | print( |
| 39 | "To use Botasaurus via a User Interface, you need to have Node.js installed on your system. You do not have Node.js installed on your system, Kindly install it by visiting https://nodejs.org/. After installation, please restart your PC." |
| 40 | ) |
| 41 | sys.exit(1) |
no test coverage detected