16
16
import subprocess
17
17
from typing import Optional
18
18
19
+
19
20
# Configure logging
20
21
logging .basicConfig (level = logging .INFO )
21
22
logger = logging .getLogger (__name__ )
@@ -26,10 +27,10 @@ def analyze_debug_log(log_file: str = "debug.log") -> None:
26
27
Analyze a debug log file for common issues.
27
28
"""
28
29
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 )
30
31
return
31
32
32
- logger .info (f "Analyzing { log_file } ..." )
33
+ logger .info ("Analyzing %s ..." , log_file )
33
34
with open (log_file , "r" ) as f :
34
35
content = f .read ()
35
36
@@ -46,7 +47,7 @@ def analyze_debug_log(log_file: str = "debug.log") -> None:
46
47
line_end = len (content )
47
48
48
49
line = content [line_start :line_end ].strip ()
49
- logger .warning (f "Potential issue found: { line } " )
50
+ logger .warning ("Potential issue found: %s" , line )
50
51
errors_found = True
51
52
52
53
if not errors_found :
@@ -71,22 +72,24 @@ def test_connectivity(server_url: Optional[str] = None) -> None:
71
72
logger .error ("No server URL provided and couldn't find one in ~/.zuliprc" )
72
73
return
73
74
74
- logger .info (f "Testing connectivity to { server_url } ..." )
75
+ logger .info ("Testing connectivity to %s ..." , server_url )
75
76
try :
76
77
import requests
77
78
78
79
response = requests .get (f"{ server_url } /api/v1/server_settings" )
79
80
if response .status_code == 200 :
80
- logger .info (f "Successfully connected to { server_url } " )
81
+ logger .info ("Successfully connected to %s" , server_url )
81
82
try :
82
83
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
+ )
84
87
except json .JSONDecodeError :
85
88
logger .error ("Received response, but couldn't parse as JSON" )
86
89
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 )
88
91
except Exception as e :
89
- logger .error (f "Connection error: { e } " )
92
+ logger .error ("Connection error: %s" , e )
90
93
91
94
92
95
def check_terminal_capabilities () -> None :
@@ -97,10 +100,10 @@ def check_terminal_capabilities() -> None:
97
100
98
101
# Check for color support
99
102
colors = os .environ .get ("TERM" , "unknown" )
100
- logger .info (f "TERM environment: { colors } " )
103
+ logger .info ("TERM environment: %s" , colors )
101
104
102
105
if "COLORTERM" in os .environ :
103
- logger .info (f "COLORTERM: { os .environ [' COLORTERM' ] } " )
106
+ logger .info ("COLORTERM: %s" , os .environ [" COLORTERM" ] )
104
107
105
108
# Check for Unicode support
106
109
logger .info ("Testing Unicode rendering capabilities:" )
@@ -112,17 +115,7 @@ def check_terminal_capabilities() -> None:
112
115
]
113
116
114
117
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 )
126
119
127
120
128
121
def main () -> None :
@@ -138,7 +131,9 @@ def main() -> None:
138
131
139
132
# Connectivity test
140
133
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
+ )
142
137
143
138
# Terminal test
144
139
subparsers .add_parser ("terminal" , help = "Check terminal capabilities" )
@@ -159,8 +154,8 @@ def main() -> None:
159
154
cmd = ["zulip-term" , "-d" ]
160
155
if args .profile :
161
156
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 )
164
159
else :
165
160
parser .print_help ()
166
161
0 commit comments