MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / check_node

Function check_node

botasaurus_server/botasaurus_server/check_node.py:5–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import sys
4
5def 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)

Callers 2

run_frontendFunction · 0.90
runFunction · 0.90

Calls 2

extract_numberFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected