Skip to content

Commit f37ac23

Browse files
committed
- Adding theme not supported message
- Fixing theme fallback selection mechanism - Updating docs
1 parent 1504141 commit f37ac23

File tree

9 files changed

+136
-91
lines changed

9 files changed

+136
-91
lines changed

Changelog

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
2020-09-29 s-n-g
1+
2020-10-13 s-n-g
2+
This is a long-overdue update!
3+
This is a called a beta release in the sense that some
4+
of the intended features have not been implemented yet.
5+
26
* Version 0.8.7.3 (0.8.8-beta2)
37
* Adding PASTE MODE in editing windows
48
* Finalizing alternative modes (registers, register mode,
@@ -7,13 +11,13 @@
711
* Toggling transparency enabled in theme selection window
812
* Pyradio respects global encoding
913
* Info window gets updated as data are read
10-
* Display message when fallback theme is used
14+
* Display message when fallback theme is used (#99)
1115
* Fixing info window highlight and encoding issues
1216
* Making Station editor window size aware
1317
* Fixing -a command line parameter functionality
1418
* Build script accepts --user (for user only installation) on linux
15-
* Build script will clean up previous installation files (not on Windows)
16-
* Fixing volume saving on Windows
19+
* Build script will clean up previous installation files
20+
* Fixing volume saving on Windows (mplayer)
1721

1822
Implemented in 0.8.8-beta1
1923
* Connection timeout counter
@@ -22,8 +26,8 @@
2226
* Fixing playback restart when encoding changed
2327

2428
Not implemented yet
25-
* /p - Select playlist/register to paste station
26-
* /n - Create new playlist
29+
* \p - Select playlist/register to paste station
30+
* \n - Create new playlist
2731

2832
2020-03-16 s-n-g
2933
* Version 0.8.7.2

devel/build_install_pyradio.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ python2 -m site --user-site 2>nul >>dirs
160160
python3 -m site --user-site 2>nul >>dirs
161161
python devel\windirs.py
162162
echo DEL dirs >>pyremove.bat
163-
echo echo Pyradio successfully uninstalled! >>pyremove.bat
163+
echo echo PyRadio successfully uninstalled! >>pyremove.bat
164164

165165
echo echo. >>pyremove.bat
166166
echo echo ********************************************************* >>pyremove.bat

pyradio.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
4-
.TH PYRADIO 1 "September 2020"
4+
.TH PYRADIO 1 "October 2020"
55

66
.SH NAME
77
.PP

pyradio/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,10 @@ def find_history_by_station_title(self, a_title):
915915

916916
class PyRadioConfig(PyRadioStations):
917917

918+
fallback_theme = ''
919+
918920
theme_not_supported = False
921+
theme_has_error = False
919922
theme_not_supported_notification_shown = False
920923

921924
opts = collections.OrderedDict()

pyradio/radio.py

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ def setup(self, stdscr):
379379
else:
380380
self._theme_name = ret_theme_name
381381
self._cnf.theme_not_supported = True
382+
self._cnf.theme_has_error = True if ret == -1 else False
382383

383384
self.log = Log()
384385
# For the time being, supported players are mpv, mplayer and vlc.
@@ -1315,7 +1316,18 @@ def closeHistoryEmptyNotification(self):
13151316
def _show_theme_not_supported(self):
13161317
if self._cnf.theme_not_supported_notification_shown:
13171318
return
1318-
txt = 'Error loading selected theme!\n____Using fallback theme.'
1319+
if self._cnf.theme_has_error:
1320+
txt = '|Error loading selected theme!|\n____Using |fallback| theme.'
1321+
else:
1322+
tmp = ['', '', '']
1323+
tmp[0] = '|Theme not supported!|'
1324+
tmp[1] = 'This terminal supports up to |{}| colors...'.format(curses.COLORS)
1325+
tmp[2] = 'Using |fallback| theme.'
1326+
while len(tmp[0]) < len(tmp[1]) -2:
1327+
tmp[0] = '_' + tmp[0] + '_'
1328+
while len(tmp[2]) < len(tmp[1]):
1329+
tmp[2] = '_' + tmp[2] + '_'
1330+
txt = '\n'.join(tmp)
13191331
self._show_help(txt, mode_to_set=self.ws.operation_mode, caption='',
13201332
prompt='', is_message=True)
13211333
# start 1750 ms counter
@@ -2723,8 +2735,8 @@ def to_time(secs):
27232735
return str(hour) + ':' + str(min)
27242736

27252737
check_days = 10
2726-
if logger.isEnabledFor(logging.DEBUG):
2727-
logger.debug('detectUpdateThread: starting...')
2738+
if logger.isEnabledFor(logging.INFO):
2739+
logger.info('detectUpdateThread: Starting...')
27282740
##################
27292741
#delay(5, stop)
27302742
from pyradio import version as my_version, app_state as my_app_state
@@ -2734,8 +2746,8 @@ def to_time(secs):
27342746
this_version=my_version+'-'+my_app_state
27352747
connection_fail_count = 0
27362748
ran=random.randint(25, 45)
2737-
if logger.isEnabledFor(logging.DEBUG):
2738-
logger.debug('detectUpdateThread: Will check in {} seconds'.format(ran))
2749+
if logger.isEnabledFor(logging.INFO):
2750+
logger.info('detectUpdateThread: Will check in {} seconds'.format(ran))
27392751
delay(ran, stop)
27402752
if stop():
27412753
if logger.isEnabledFor(logging.DEBUG):
@@ -2757,15 +2769,15 @@ def to_time(secs):
27572769
#delta=check_days
27582770
if delta < check_days:
27592771
clean_date_files(files)
2760-
if logger.isEnabledFor(logging.DEBUG):
2772+
if logger.isEnabledFor(logging.INFO):
27612773
if check_days - delta == 1:
2762-
logger.debug('detectUpdateThread: Will check again tomorrow...')
2774+
logger.info('detectUpdateThread: Will check again tomorrow...')
27632775
else:
2764-
logger.debug('detectUpdateThread: Will check again in {} days...'.format(check_days - delta))
2776+
logger.info('detectUpdateThread: Will check again in {} days...'.format(check_days - delta))
27652777
return
27662778

2767-
if logger.isEnabledFor(logging.DEBUG):
2768-
logger.debug('detectUpdateThread: checking for updates')
2779+
if logger.isEnabledFor(logging.INFO):
2780+
logger.info('detectUpdateThread: Checking for updates')
27692781
url = 'https://api.github.com/repos/coderholic/pyradio/tags'
27702782
while True:
27712783
if stop():
@@ -2795,13 +2807,13 @@ def to_time(secs):
27952807
# PROGRAM DEBUG: set last github tag's version
27962808
# to check display functionality
27972809
#last_tag = '0.8.8-RC1'
2798-
if logger.isEnabledFor(logging.DEBUG):
2799-
logger.debug('detectUpdateThread: Upstream version found: {}'.format(last_tag))
2810+
if logger.isEnabledFor(logging.INFO):
2811+
logger.info('detectUpdateThread: Upstream version found: {}'.format(last_tag))
28002812
if this_version == last_tag:
28012813
clean_date_files(files, -1)
28022814
create_tadays_date_file(a_path)
2803-
if logger.isEnabledFor(logging.DEBUG):
2804-
logger.debug('detectUpdateThread: No update found. Will check again in {} days. Exiting...'.format(check_days))
2815+
if logger.isEnabledFor(logging.INFO):
2816+
logger.info('detectUpdateThread: No update found. Will check again in {} days. Exiting...'.format(check_days))
28052817
break
28062818
else:
28072819
# PROGRAM DEBUG: set program's version
@@ -2831,7 +2843,7 @@ def to_time(secs):
28312843
logger.info('detectUpdateThread: Update available: {}'.format(last_tag))
28322844
a_lock.acquire()
28332845
if logger.isEnabledFor(logging.DEBUG):
2834-
logger.debug('notification sent!!!')
2846+
logger.debug('detectUpdateThread: Update notification sent!!!')
28352847
self._update_version = last_tag
28362848
a_lock.release()
28372849
while True:
@@ -2861,12 +2873,12 @@ def to_time(secs):
28612873
break
28622874

28632875
else:
2864-
if logger.isEnabledFor(logging.DEBUG):
2865-
logger.debug('detectUpdateThread: Error: Cannot get upstream version!!!')
2876+
if logger.isEnabledFor(logging.ERROR):
2877+
logger.error('detectUpdateThread: Error: Cannot get upstream version!!!')
28662878
connection_fail_count += 1
28672879
if connection_fail_count > 4:
2868-
if logger.isEnabledFor(logging.DEBUG):
2869-
logger.debug('detectUpdateThread: Error: Too many connection failures. Exiting...')
2880+
if logger.isEnabledFor(logging.ERROR):
2881+
logger.error('detectUpdateThread: Error: Too many connection failures. Exiting...')
28702882
break
28712883
delay(60, stop)
28722884

@@ -3521,6 +3533,7 @@ def keypress(self, char):
35213533
self._theme_name = self._cnf.theme
35223534
else:
35233535
self._theme_name = ret_theme_name
3536+
self._cnf.theme_has_error = True if ret == -1 else False
35243537
self._cnf.theme_not_supported = True
35253538
curses.doupdate()
35263539
# make sure config is not saved
@@ -3835,6 +3848,7 @@ def keypress(self, char):
38353848
char not in self._chars_to_bypass and \
38363849
char not in self._chars_to_bypass_for_search and \
38373850
char not in (ord('T'),)):
3851+
logger.error('DE \n\nExiting theme selector?\n\n')
38383852
theme_id, save_theme = self._theme_selector.keypress(char)
38393853

38403854
#if self._cnf.theme_not_supported:
@@ -3867,9 +3881,10 @@ def keypress(self, char):
38673881
theme_path=self._theme_selector._themes[theme_id][1])
38683882
if isinstance(ret, tuple):
38693883
ret = ret[0]
3870-
if ret == -1:
3884+
if ret < 0:
38713885
self._theme_name = ret_theme_name
38723886
self._cnf.theme_not_supported = True
3887+
self._cnf.theme_has_error = True if ret == -1 else False
38733888
self._cnf.theme_not_supported_notification_shown = False
38743889
self._show_theme_not_supported()
38753890
#self.refreshBody()

pyradio/stations.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Downtempo (Secret Agent - SomaFM),http://somafm.com/secretagent.pls
1010
Dub Step (Dub Step Beyond - SomaFM),http://somafm.com/dubstep.pls
1111
Electronic/Dance (Electronic Culture),http://www.shouted.fm/tunein/electro-dsl.m3u
1212
Folk (Folk Forward - SomaFM),http://somafm.com/folkfwd.pls
13+
Hip Hop (Hot 97 NYC),http://playerservices.streamtheworld.com/pls/WQHTAAC.pls
1314
Hip Hop (Power 1051 NYC),http://c11.prod.playlists.ihrhls.com/1481/playlist.m3u8
1415
House (Beat Blender - SomaFM),http://somafm.com/startstream=beatblender.pls
1516
Indie Pop (Indie Pop Rocks! - SomaFM),http://somafm.com/indiepop130.pls
@@ -22,7 +23,10 @@ Progressive (Tags Trance Trip - SomaFM),http://somafm.com/tagstrance.pls
2223
Public Radio (WNYC - Public Radio from New York to the World),http://wnyc-iheart.streamguys.com/wnycfm-iheart.aac
2324
Reggae Dancehall (Ragga Kings),http://www.raggakings.net/listen.m3u
2425
Rock (Digitalis - SomaFM),http://somafm.com/digitalis.pls
26+
Vox Noctem: Rock-Goth, http://r2d2.voxnoctem.de:8000/voxnoctem.mp3
2527
Beyond Metal (Progressive - Symphonic),http://streamingV2.shoutcast.com/BeyondMetal
28+
DanceUK,https://www.internet-radio.com/servers/tools/playlistgenerator/?u=http://uk2.internet-radio.com:8024/listen.pls&t=.pls
29+
JazzGroove,https://www.internet-radio.com/servers/tools/playlistgenerator/?u=http://199.180.72.2:8015/listen.pls?sid=1&t=.pls
2630
Radio Paradise - Main Mix,http://stream.radioparadise.com/aac-128
2731
Radio Paradise - Mellow Mix,http://stream.radioparadise.com/mellow-128
2832
Radio Paradise - Rock Mix,http://stream.radioparadise.com/rock-128

pyradio/themes.py

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def _do_init_pairs(self):
5656
curses.init_pair(8, self._active_colors[THEME_ITEMS[7][0]][FOREGROUND()], self._active_colors[THEME_ITEMS[7][0]][BACKGROUND()])
5757
# cursor when playing
5858
curses.init_pair(9, self._active_colors[THEME_ITEMS[6][0]][FOREGROUND()], self._active_colors[THEME_ITEMS[6][0]][BACKGROUND()])
59-
logger.error('DE _do_init_pairs:\n{}'.format(self._active_colors))
59+
if logger.isEnabledFor(logging.DEBUG):
60+
logger.debug('_do_init_pairs: {}'.format(self._active_colors))
6061

6162
def restoreActiveTheme(self):
6263
self._active_colors = deepcopy(self._read_colors)
@@ -68,9 +69,13 @@ def readAndApplyTheme(self, a_theme, **kwargs):
6869
""" Read a theme and apply it
6970
7071
Returns:
71-
-1: theme not supported (default theme loaded)
72+
-2: theme not supported (default theme loaded)
73+
-1: theme has error (default theme loaded)
7274
0: all ok
7375
"""
76+
self._cnf.theme_has_error = False
77+
self._cnf.theme_not_supported = False
78+
self._cnf.theme_not_supported_notification_shown = False
7479
result = 0
7580
use_transparency = None
7681
theme_path = ''
@@ -80,10 +85,12 @@ def readAndApplyTheme(self, a_theme, **kwargs):
8085
elif name == 'theme_path':
8186
theme_path = value
8287
ret = self.open_theme(a_theme, theme_path)
83-
if ret < 0 or self._applied_theme_max_colors > curses.COLORS:
84-
# TODO: return error
88+
if ret < 0:
8589
self._load_default_theme(self.applied_theme_name)
8690
result = -1, self.applied_theme_name
91+
elif self._applied_theme_max_colors > curses.COLORS:
92+
self._load_default_theme(self.applied_theme_name)
93+
result = -2, self.applied_theme_name
8794
else:
8895
self.applied_theme_name = a_theme
8996

@@ -100,16 +107,16 @@ def readAndApplyTheme(self, a_theme, **kwargs):
100107
return result, self.applied_theme_name
101108

102109
def _load_default_theme(self, a_theme):
103-
logger.error('DE a_theme = {}'.format(a_theme))
104-
self.applied_theme_name = 'dark'
105-
self._applied_theme_max_colors = 8
106-
try_theme = a_theme.replace('_16_colors', '')
107-
if try_theme == 'light':
108-
self.applied_theme_name = try_theme
109-
elif self._cnf.theme.replace('_16_colors', '') == 'light':
110-
self.applied_theme_name = 'light'
110+
if self._cnf.fallback_theme :
111+
self.applied_theme_name = self._cnf.fallback_theme
112+
else:
113+
self.applied_theme_name = 'dark'
114+
self._applied_theme_max_colors = 8
115+
if a_theme.startswith('light'):
116+
self.applied_theme_name = 'light'
117+
self._cnf.fallback_theme = self.applied_theme_name
111118
if logger.isEnabledFor(logging.INFO):
112-
logger.info('Applying default theme: {}'.format(self.applied_theme_name))
119+
logger.info('Applying fallback theme: "{0}" instead of: "{1}"'.format(self.applied_theme_name, a_theme))
113120
self.open_theme(self.applied_theme_name)
114121

115122
def open_theme(self, a_theme = '', a_path=''):
@@ -454,19 +461,27 @@ def __init__(self, parent, config, theme,
454461
self._themes = []
455462

456463
def show(self):
457-
self._themes = []
458464
self._themes = [ [ 'dark', 'dark' ] ]
459-
if curses.COLORS >= 16:
460-
self._themes.append([ 'dark_16_colors', '' ])
461-
self._items += 1
465+
#if curses.COLORS >= 16:
466+
# self._themes.append([ 'dark_16_colors', '' ])
467+
# self._items += 1
468+
#self._themes.append([ 'light', '' ])
469+
#if curses.COLORS >= 16:
470+
# self._themes.append([ 'light_16_colors', '' ])
471+
# self._items += 1
472+
#if curses.COLORS == 256:
473+
# self._themes.append([ 'black_on_white', '' ])
474+
# self._themes.append([ 'white_on_black', '' ])
475+
# self._items += 2
476+
477+
self._themes.append([ 'dark_16_colors', '' ])
478+
self._items += 1
462479
self._themes.append([ 'light', '' ])
463-
if curses.COLORS >= 16:
464-
self._themes.append([ 'light_16_colors', '' ])
465-
self._items += 1
466-
if curses.COLORS == 256:
467-
self._themes.append([ 'black_on_white', '' ])
468-
self._themes.append([ 'white_on_black', '' ])
469-
self._items += 2
480+
self._themes.append([ 'light_16_colors', '' ])
481+
self._items += 1
482+
self._themes.append([ 'black_on_white', '' ])
483+
self._themes.append([ 'white_on_black', '' ])
484+
self._items += 2
470485
# scan for package and user themes
471486
themes_to_add = self._scan_for_theme_files(self._cnf.stations_dir)
472487
#themes_to_add = self._scan_for_theme_files(self._cnf.stations_dir)
@@ -875,6 +890,9 @@ def keypress(self, char):
875890
else:
876891
self._applied_theme_name = ret_theme_name
877892
self._cnf.theme_not_supported = True
893+
self._cnf.theme_has_error = True if ret == -1 else False
894+
# avoid showing extra notification when exiting theme selector
895+
self._cnf.theme_not_supported_notification_shown = True
878896
self.selection = -1
879897
return -1, False
880898
return -3, False

0 commit comments

Comments
 (0)