31
31
from urllib3 .exceptions import InsecureRequestWarning
32
32
import uvicorn
33
33
34
- print (f"Python { platform .python_version ()} ({ platform .architecture ()[0 ]} ) @ { sys .executable } " )
34
+ print (
35
+ f"Python { platform .python_version ()} ({ platform .architecture ()[0 ]} ) @ { sys .executable } "
36
+ )
35
37
print (f"Current file path: { os .path .abspath (__file__ )} " )
36
38
39
+
37
40
def adjust_python_path ():
38
41
"""Adjusts the Python path to include the Framework directory."""
39
42
root_dir = Path .cwd ()
@@ -48,12 +51,46 @@ def adjust_python_path():
48
51
# Move to Framework directory and add parent to path for module imports
49
52
os .chdir (framework_dir )
50
53
54
+
55
+ def create_config_file ():
56
+ settings_conf_path = Path .cwd () / "settings.conf"
57
+ if settings_conf_path .exists ():
58
+ return
59
+
60
+ today = date .today ().strftime ("%Y-%m-%d" )
61
+
62
+ config = ConfigObj ()
63
+ config ["Authentication" ] = {"username" : "" , "api-key" : "" , "server_address" : "" }
64
+ config ["Advanced Options" ] = {
65
+ "module_update_interval" : 30 ,
66
+ "log_delete_interval" : 7 ,
67
+ "last_module_update_date" : today ,
68
+ "last_log_delete_date" : today ,
69
+ "element_wait" : 10 ,
70
+ "available_to_all_project" : False ,
71
+ "_file" : "temp_config.ini" ,
72
+ "_file_upload_path" : "TestExecutionLog" ,
73
+ "stop_live_log" : False ,
74
+ }
75
+ config ["Inspector" ] = {
76
+ "Window" : "" ,
77
+ "No_of_level_to_skip" : 0 ,
78
+ "ai_plugin" : True ,
79
+ }
80
+ config ["server" ] = {"port" : 0 }
81
+ config .filename = str (settings_conf_path )
82
+ config .write ()
83
+ print (f"Created settings.conf at { settings_conf_path } " )
84
+
85
+
51
86
adjust_python_path ()
87
+ create_config_file ()
88
+
52
89
53
90
from Framework .module_installer import ( # noqa: E402
54
91
check_min_python_version ,
55
- install_missing_modules ,
56
92
update_outdated_modules ,
93
+ # install_missing_modules,
57
94
)
58
95
59
96
from Framework .deploy_handler import ( # noqa: E402
@@ -65,39 +102,10 @@ def adjust_python_path():
65
102
from Framework .node_server_state import STATE # noqa: E402
66
103
from server import main as node_server # noqa: E402
67
104
68
- settings_conf_path = str (Path (__file__ ).parent / "Framework" / "settings.conf" )
69
- def create_config_file ():
70
- if not os .path .exists (settings_conf_path ):
71
- config = ConfigObj ()
72
- config ["Authentication" ] = {
73
- "username" : "" ,
74
- "api-key" : "" ,
75
- "server_address" : ""
76
- }
77
- config ["Advanced Options" ] = {
78
- "module_update_interval" : 30 ,
79
- "log_delete_interval" : 7 ,
80
- "last_module_update_date" : "2025-02-21" ,
81
- "last_log_delete_date" : "2023-09-19" ,
82
- "element_wait" : 10 ,
83
- "available_to_all_project" : False ,
84
- "_file" : "temp_config.ini" ,
85
- "_file_upload_path" : "TestExecutionLog" ,
86
- "stop_live_log" : False
87
- }
88
- config ["Inspector" ] = {
89
- "Window" : "" ,
90
- "No_of_level_to_skip" : 0 ,
91
- "ai_plugin" : True
92
- }
93
- config ["server" ] = {
94
- "port" : 0
95
- }
96
- config .filename = settings_conf_path
97
- config .write ()
98
- print (f"Created settings.conf at { settings_conf_path } " )
99
105
100
106
def start_server ():
107
+ settings_conf_path = Path .cwd () / "settings.conf"
108
+
101
109
def is_port_in_use (port ):
102
110
with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
103
111
return s .connect_ex (("127.0.0.1" , port )) == 0
@@ -109,7 +117,7 @@ def run():
109
117
while is_port_in_use (node_server_port ) and tries < 99 :
110
118
node_server_port += 1
111
119
tries += 1
112
- config = ConfigObj (settings_conf_path )
120
+ config = ConfigObj (str ( settings_conf_path ) )
113
121
config ["server" ]["port" ] = node_server_port
114
122
config .write ()
115
123
uvicorn .run (
@@ -118,7 +126,7 @@ def run():
118
126
port = node_server_port ,
119
127
log_level = "warning" ,
120
128
)
121
-
129
+
122
130
except Exception as e :
123
131
print (f"[WARN] Failed to launch node-server: { str (e )} " )
124
132
@@ -165,7 +173,6 @@ def monkeypatch_fromisoformat():
165
173
166
174
167
175
def main ():
168
-
169
176
# Load environment variables from .env file
170
177
load_dotenv ()
171
178
@@ -181,7 +188,6 @@ def main():
181
188
182
189
kill_old_process (Path .cwd ().parent / "pid.txt" )
183
190
check_min_python_version (min_python_version = "3.11" , show_warning = True )
184
- create_config_file ()
185
191
update_outdated_modules ()
186
192
monkeypatch_fromisoformat ()
187
193
start_server ()
@@ -1059,9 +1065,11 @@ def Bypass():
1059
1065
1060
1066
STATE .reconnect_with_credentials = None
1061
1067
1062
- server_name = ConfigModule .get_config_value (
1063
- AUTHENTICATION_TAG , "server_address"
1064
- ).strip ('""' ).strip ()
1068
+ server_name = (
1069
+ ConfigModule .get_config_value (AUTHENTICATION_TAG , "server_address" )
1070
+ .strip ('""' )
1071
+ .strip ()
1072
+ )
1065
1073
api = (
1066
1074
ConfigModule .get_config_value (AUTHENTICATION_TAG , "api-key" )
1067
1075
.strip ('"' )
@@ -1070,7 +1078,10 @@ def Bypass():
1070
1078
1071
1079
if len (server_name ) == 0 and len (api ) == 0 :
1072
1080
if print_login_information :
1073
- console .print ("\n " + ":red_circle: " + "Zeuz Node is disconnected." , style = "bold red" )
1081
+ console .print (
1082
+ "\n " + ":red_circle: " + "Zeuz Node is disconnected." ,
1083
+ style = "bold red" ,
1084
+ )
1074
1085
console .print ("Please log in to ZeuZ server and connect." )
1075
1086
1076
1087
print_login_information = False
@@ -1087,8 +1098,8 @@ def Bypass():
1087
1098
1088
1099
if RUN_ONCE :
1089
1100
console .print (
1090
- ":yellow_circle: " +
1091
- "Zeuz Node is going offline after running one session, since `--once` or `-o` flag is specified." ,
1101
+ ":yellow_circle: "
1102
+ + "Zeuz Node is going offline after running one session, since `--once` or `-o` flag is specified." ,
1092
1103
style = "bold cyan" ,
1093
1104
)
1094
1105
os ._exit (0 )
0 commit comments