21
21
# Replace the default implementation
22
22
warnings .showwarning = (
23
23
lambda message , category , filename , lineno , file = None , line = None : click .echo (
24
- f" { click .style (' warning:' , fg = ' yellow' )} { message } " , err = True
24
+ f' { click .style (" warning:" , fg = " yellow" )} { message } ' , err = True
25
25
)
26
26
)
27
27
@@ -64,13 +64,13 @@ def status(json: bool):
64
64
if login_status .get ('user_name' ):
65
65
click .echo (
66
66
click .style ('bitsrun: ' , fg = 'green' )
67
- + f" { login_status [' user_name' ]} ({ login_status [' online_ip' ]} ) is online"
67
+ + f' { login_status [" user_name" ]} ({ login_status [" online_ip" ]} ) is online'
68
68
)
69
69
print_status_table (login_status )
70
70
else :
71
71
click .echo (
72
72
click .style ('bitsrun: ' , fg = 'cyan' )
73
- + f" { login_status [' online_ip' ]} is offline"
73
+ + f' { login_status [" online_ip" ]} is offline'
74
74
)
75
75
76
76
@@ -113,17 +113,17 @@ def do_action(action, username, password, verbose):
113
113
114
114
if action == 'login' :
115
115
resp = user .login ()
116
- message = f" { user .username } ({ resp [' online_ip' ]} ) logged in"
116
+ message = f' { user .username } ({ resp [" online_ip" ]} ) logged in'
117
117
elif action == 'logout' :
118
118
resp = user .logout ()
119
- message = f" { resp [' online_ip' ]} logged out"
119
+ message = f' { resp [" online_ip" ]} logged out'
120
120
else :
121
121
# Should not reach here, but just in case
122
122
raise ValueError (f'Unknown action `{ action } `' )
123
123
124
124
# Output direct result of the API response if verbose
125
125
if verbose :
126
- click .echo (f" { click .style (' bitsrun:' , fg = ' cyan' )} Response from API:" )
126
+ click .echo (f' { click .style (" bitsrun:" , fg = " cyan" )} Response from API:' )
127
127
print_json (data = resp )
128
128
129
129
# Handle error from API response. When field `error` is not `ok`, then the
@@ -136,11 +136,11 @@ def do_action(action, username, password, verbose):
136
136
)
137
137
138
138
# Print success message
139
- click .echo (f" { click .style (' bitsrun:' , fg = ' green' )} { message } " )
139
+ click .echo (f' { click .style (" bitsrun:" , fg = " green" )} { message } ' )
140
140
141
141
except Exception as e :
142
142
# Exception is caught and printed to stderr
143
- click .echo (f" { click .style (' error:' , fg = ' red' )} { e } " , err = True )
143
+ click .echo (f' { click .style (" error:" , fg = " red" )} { e } ' , err = True )
144
144
# Throw with error code 1 for scripts to pick up error state
145
145
sys .exit (1 )
146
146
0 commit comments