1616import subprocess
1717from typing import Optional
1818
19+
1920# Configure logging
2021logging .basicConfig (level = logging .INFO )
2122logger = logging .getLogger (__name__ )
@@ -26,10 +27,10 @@ def analyze_debug_log(log_file: str = "debug.log") -> None:
2627 Analyze a debug log file for common issues.
2728 """
2829 if not os .path .exists (log_file ):
29- logger .error (f "Log file '{ log_file } ' not found" )
30+ logger .error ("Log file '%s ' not found" , log_file )
3031 return
3132
32- logger .info (f "Analyzing { log_file } ..." )
33+ logger .info ("Analyzing %s ..." , log_file )
3334 with open (log_file , "r" ) as f :
3435 content = f .read ()
3536
@@ -46,7 +47,7 @@ def analyze_debug_log(log_file: str = "debug.log") -> None:
4647 line_end = len (content )
4748
4849 line = content [line_start :line_end ].strip ()
49- logger .warning (f "Potential issue found: { line } " )
50+ logger .warning ("Potential issue found: %s" , line )
5051 errors_found = True
5152
5253 if not errors_found :
@@ -71,22 +72,24 @@ def test_connectivity(server_url: Optional[str] = None) -> None:
7172 logger .error ("No server URL provided and couldn't find one in ~/.zuliprc" )
7273 return
7374
74- logger .info (f "Testing connectivity to { server_url } ..." )
75+ logger .info ("Testing connectivity to %s ..." , server_url )
7576 try :
7677 import requests
7778
7879 response = requests .get (f"{ server_url } /api/v1/server_settings" )
7980 if response .status_code == 200 :
80- logger .info (f "Successfully connected to { server_url } " )
81+ logger .info ("Successfully connected to %s" , server_url )
8182 try :
8283 settings = response .json ()
83- logger .info (f"Server version: { settings .get ('zulip_version' , 'unknown' )} " )
84+ logger .info (
85+ "Server version: %s" , settings .get ("zulip_version" , "unknown" )
86+ )
8487 except json .JSONDecodeError :
8588 logger .error ("Received response, but couldn't parse as JSON" )
8689 else :
87- logger .error (f "Failed to connect: HTTP status { response .status_code } " )
90+ logger .error ("Failed to connect: HTTP status %s" , response .status_code )
8891 except Exception as e :
89- logger .error (f "Connection error: { e } " )
92+ logger .error ("Connection error: %s" , e )
9093
9194
9295def check_terminal_capabilities () -> None :
@@ -97,10 +100,10 @@ def check_terminal_capabilities() -> None:
97100
98101 # Check for color support
99102 colors = os .environ .get ("TERM" , "unknown" )
100- logger .info (f "TERM environment: { colors } " )
103+ logger .info ("TERM environment: %s" , colors )
101104
102105 if "COLORTERM" in os .environ :
103- logger .info (f "COLORTERM: { os .environ [' COLORTERM' ] } " )
106+ logger .info ("COLORTERM: %s" , os .environ [" COLORTERM" ] )
104107
105108 # Check for Unicode support
106109 logger .info ("Testing Unicode rendering capabilities:" )
@@ -112,17 +115,7 @@ def check_terminal_capabilities() -> None:
112115 ]
113116
114117 for name , chars in test_chars :
115- logger .info (f" { name } : { chars } " )
116-
117- # Check for urwid compatibility
118- try :
119- import urwid
120-
121- logger .info ("Urwid detected. Running basic urwid test..." )
122- # This doesn't actually run a visual test - just checks if urwid can be imported
123- logger .info ("Urwid import successful" )
124- except ImportError :
125- logger .warning ("Urwid not found. This may indicate installation issues." )
118+ logger .info (" %s: %s" , name , chars )
126119
127120
128121def main () -> None :
@@ -138,7 +131,9 @@ def main() -> None:
138131
139132 # Connectivity test
140133 conn_parser = subparsers .add_parser ("connect" , help = "Test connectivity" )
141- conn_parser .add_argument ("--server" , help = "Server URL (e.g., https://chat.zulip.org)" )
134+ conn_parser .add_argument (
135+ "--server" , help = "Server URL (e.g., https://chat.zulip.org)"
136+ )
142137
143138 # Terminal test
144139 subparsers .add_parser ("terminal" , help = "Check terminal capabilities" )
@@ -159,8 +154,8 @@ def main() -> None:
159154 cmd = ["zulip-term" , "-d" ]
160155 if args .profile :
161156 cmd .append ("--profile" )
162- logger .info (f "Running: { ' ' .join (cmd )} " )
163- subprocess .run (cmd )
157+ logger .info ("Running: %s" , " " .join (cmd ))
158+ subprocess .run (cmd , check = False )
164159 else :
165160 parser .print_help ()
166161
0 commit comments