@@ -93,6 +93,23 @@ def _write_attribution_file(config, payload: dict) -> None:
9393 Core .save_file (config .license_file_name , json .dumps (payload , indent = 2 ))
9494
9595
96+ DEFAULT_API_TIMEOUT = 1200
97+
98+
99+ def get_api_request_timeout (config : CliConfig ) -> int :
100+ return config .timeout if config .timeout is not None else DEFAULT_API_TIMEOUT
101+
102+
103+ def build_socket_sdk (config : CliConfig ) -> socketdev :
104+ cli_user_agent_string = f"SocketPythonCLI/{ config .version } "
105+ return socketdev (
106+ token = config .api_token ,
107+ timeout = get_api_request_timeout (config ),
108+ allow_unverified = config .allow_unverified ,
109+ user_agent = cli_user_agent_string
110+ )
111+
112+
96113def cli ():
97114 try :
98115 main_code ()
@@ -135,8 +152,7 @@ def main_code():
135152 "1. Command line: --api-token YOUR_TOKEN\n "
136153 "2. Environment variable: SOCKET_SECURITY_API_TOKEN" )
137154 sys .exit (3 )
138- cli_user_agent_string = f"SocketPythonCLI/{ config .version } "
139- sdk = socketdev (token = config .api_token , allow_unverified = config .allow_unverified , user_agent = cli_user_agent_string )
155+ sdk = build_socket_sdk (config )
140156
141157 # Suppress urllib3 InsecureRequestWarning when using --allow-unverified
142158 if config .allow_unverified :
@@ -155,7 +171,7 @@ def main_code():
155171 socket_config = SocketConfig (
156172 api_key = config .api_token ,
157173 allow_unverified_ssl = config .allow_unverified ,
158- timeout = config . timeout if config . timeout is not None else 1200 # Use CLI timeout if provided
174+ timeout = get_api_request_timeout ( config )
159175 )
160176 log .debug ("loaded socket_config" )
161177 client = CliClient (socket_config )
0 commit comments