@@ -109,13 +109,21 @@ def shell():
109
109
args = parser .parse_args ()
110
110
sys .stdout .flush ()
111
111
112
+ config_already_read = False
113
+
112
114
with pyradio_config_file () as pyradio_config :
113
115
114
- if args .update or args .sng_master or args .sng_devel :
116
+ if args .uninstall or args .update or \
117
+ args .sng_master or args .sng_devel :
118
+ if not config_already_read :
119
+ read_config (pyradio_config )
120
+ config_already_read = True
115
121
if pyradio_config .distro != 'None' and \
116
122
not platform .startswith ('win' ):
117
- no_update ()
123
+ no_update (args .uninstall )
124
+ sys .exit ()
118
125
126
+ if args .update or args .sng_master or args .sng_devel :
119
127
package = 0
120
128
if args .sng_master :
121
129
package = 1
@@ -227,13 +235,9 @@ def shell():
227
235
228
236
if args .list is False and args .add is False :
229
237
print ('Reading config...' )
230
- ret = pyradio_config .read_config ()
231
- if ret == - 1 :
232
- print ('Error opening config: "{}"' .format (pyradio_config .config_file ))
233
- sys .exit (1 )
234
- elif ret == - 2 :
235
- print ('Config file is malformed: "{}"' .format (pyradio_config .config_file ))
236
- sys .exit (1 )
238
+ if not config_already_read :
239
+ read_config (pyradio_config )
240
+ config_already_read = True
237
241
238
242
if args .use_player != '' :
239
243
requested_player = args .use_player
@@ -356,8 +360,18 @@ def shell():
356
360
else :
357
361
print ('\n This terminal can not display colors.\n PyRadio cannot function in such a terminal.\n ' )
358
362
359
- def no_update (action = 'update' ):
360
- print ('PyRadio has been installed using your distribution\' s package manager.\n Please use that to {} it.\n ' .format (action ))
363
+ def read_config (pyradio_config ):
364
+ ret = pyradio_config .read_config ()
365
+ if ret == - 1 :
366
+ print ('Error opening config: "{}"' .format (pyradio_config .config_file ))
367
+ sys .exit (1 )
368
+ elif ret == - 2 :
369
+ print ('Config file is malformed: "{}"' .format (pyradio_config .config_file ))
370
+ sys .exit (1 )
371
+
372
+ def no_update (uninstall ):
373
+ action = 'uninstall' if uninstall else 'update'
374
+ print ('PyRadio has been installed using either pip or your distribution\' s\n package manager. Please use that to {} it.\n ' .format (action ))
361
375
sys .exit (1 )
362
376
363
377
def print_playlist_selection_error (a_selection , cnf , ret , exit_if_malformed = True ):
0 commit comments