Skip to content

Commit e73dbf0

Browse files
committed
- fixing #239 - Pyradio doesn't remember warning message was already shown
- fixing loading saved and default config options in Config Window Recording Dir is excluded from change - adding confirmation messages responses to -px command
1 parent b617610 commit e73dbf0

File tree

9 files changed

+176
-43
lines changed

9 files changed

+176
-43
lines changed

devel/build_install_pyradio

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ then
458458
[ -e setup.py.orig ] && cp setup.py.orig setup.py
459459
else
460460
# pipx installation
461-
# MacOS will always permorm a fully isolated installation
461+
# MacOS will always perform a fully isolated installation
462462
if [ $(uname -s) == "Darwin" ] || [ $(uname -s) == "darwin" ]
463463
then
464464
PIPX_ISOLATE=1

devel/pre-commit

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
11
#!/usr/bin/env bash
22
cReset=""
33
cBold=""
4-
colorGreen=2
4+
colorBlack=0
55
colorRed=1
6+
colorGreen=2
67
colorYellow=3
78
colorBlue=4
9+
colorMagenta=5
10+
colorCyan=6
11+
colorWhite=7
12+
colorDefault=9
813
cGreen="[0;3${colorGreen}m"${cBold}
914
cRed="[1;3${colorRed}m"${cBold}
1015
cYellow="[1;3${colorYellow}m"${cBold}
1116
cBlue="[1;3${colorBlue}m"${cBold}
17+
cMagenta="[1;3${colorMagenta}m"${cBold}
18+
19+
function update_brew_link(){
20+
local INSERT
21+
local MACOS_FILE
22+
echo -n 'Updating brew link ... '
23+
INSERT=$(curl -s https://brew.sh/ | grep '<figure class="highlight"><pre>' | sed '2,$d' | sed 's/<[^>]*>//g')
24+
25+
# Check if INSERT is not empty
26+
if [ -z "$INSERT" ]; then
27+
echo -e "${cRed}failed${cReset}"
28+
else
29+
# Define the MACOS file path
30+
MACOS_FILE="macos.md"
31+
32+
# Use
33+
awk -v insert="$INSERT" '
34+
/<!-- START OF BREW LINK -->/ {
35+
print;
36+
print "```";
37+
getline;
38+
print insert;
39+
while (getline > 0 && !/<!-- END OF BREW LINK -->/) {}
40+
print "```";
41+
print
42+
next
43+
}
44+
{print}
45+
' "$MACOS_FILE" > "$MACOS_FILE.tmp" && \
46+
mv "$MACOS_FILE.tmp" "$MACOS_FILE" && \
47+
echo -e "${cGreen}done${cReset}"
48+
# sed -i '/<!-- START OF BREW LINK -->/ a \
49+
# ```' "$MACOS_FILE"
50+
fi
51+
}
1252

1353
function images_to_links(){
1454
awk '{if($0 ~ /img src=/){
@@ -31,6 +71,18 @@ awk '{if($0 ~ /img src=/){
3171
print $0}' "$1" | sed 's/<figcaption.*figcaption>//' | sed '/figure>$/d' > "$1".tmp && mv "$1".tmp "$1"
3272
}
3373

74+
while getopts ":ah" opt; do
75+
case ${opt} in
76+
a )
77+
RUN_ALL_PROGRAMS=1
78+
;;
79+
h )
80+
echo "Usage: $0 [-a/-h]"
81+
exit
82+
;;
83+
esac
84+
done
85+
3486
mkdir pyradio/__pycache__ 2>/dev/null
3587
rm -rf pyradio/__pycache__/*
3688
echo "This directory is here for pep 517 integration...
@@ -62,7 +114,14 @@ fi
62114
sed -i 's/\t/ /g' Changelog
63115

64116

117+
[ -z "$RUN_ALL_PROGRAMS" ] || ./devel/update_win_players
118+
65119
cd docs
120+
# update brew link in macos.md
121+
[ -z "$RUN_ALL_PROGRAMS" ] || update_brew_link
122+
123+
echo -ne "Updating files ... "
124+
66125
# Create HTML file from md files
67126
for afile in index.md \
68127
build.md windows.md \
@@ -71,7 +130,8 @@ for afile in index.md \
71130
radio-browser.md \
72131
desktop-notification.md \
73132
server.md linux.md \
74-
linux-pipx.md macos.md \
133+
linux-pipx.md \
134+
macos.md \
75135
pip-error.md \
76136
recording.md \
77137
packaging.md \
@@ -251,10 +311,12 @@ cd ..
251311
# git add devel/update_win_mplayer
252312
# }
253313

314+
echo -e "${cGreen}done${sReset}
315+
"
254316

255317
echo -e "${cBlue}Version:${cReset}"
256318
AVER=$(grep version pyproject.toml | sed -e 's/"//'g -e 's/version = //')
257-
echo -en " pyproject.toml: ${cGreen}"
319+
echo -en "${cBlue} pyproject.toml${cReset}: ${cGreen}"
258320
echo "version = \"$AVER\""
259321

260322
# update version string in __init__.py
@@ -264,19 +326,19 @@ sed -i "s/version_info =.*/version_info = ($XVER)/" pyradio/__init__.py
264326
# update version in install.py
265327
sed -i "s/PyRadioInstallPyReleaseVersion = .*/PyRadioInstallPyReleaseVersion = '$AVER'/" pyradio/install.py
266328

267-
echo -en "${cReset} __init__.py: ${cRed}"
329+
echo -en "${cMagenta} __init__.py${cReset}: ${cRed}"
268330
grep '^version_info ' pyradio/__init__.py
269-
echo -en "${cReset} install.py: ${cYellow}"
331+
echo -en "${cMagenta} install.py${cReset}: ${cYellow}"
270332
grep '^PyRadioInstallPyReleaseVersion ' pyradio/install.py
271333

272334
echo -e "${cReset}To change the version, just change the version in ${cGreen}pyproject.toml${cReset}
273335
and all version strings will be updated automatically."
274336

275-
276-
echo -e "${cReset}
337+
if [ -z "$RUN_ALL_PROGRAMS" ]
338+
then
339+
echo -e "${cReset}
277340
You should also run
278-
${cGreen}devel/update_win_players${cReset}
279-
at this point, if you are ready to
280-
publish a new release"
281-
341+
${cGreen}${0} -a${cReset}
342+
when you are ready to publish a new release"
343+
fi
282344

devel/update_win_players

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
#!/bin/bash
2+
cReset=""
3+
cBold=""
4+
colorBlack=0
5+
colorRed=1
6+
colorGreen=2
7+
colorYellow=3
8+
colorBlue=4
9+
colorMagenta=5
10+
colorCyan=6
11+
colorWhite=7
12+
colorDefault=9
13+
cGreen="[0;3${colorGreen}m"${cBold}
14+
cRed="[1;3${colorRed}m"${cBold}
15+
cYellow="[1;3${colorYellow}m"${cBold}
16+
cBlue="[1;3${colorBlue}m"${cBold}
17+
cMagenta="[1;3${colorMagenta}m"${cBold}
18+
219
function get_mplayer(){
320
local EXISTING
421
local FOUND
522
local TO_USE
6-
echo '>>> MPlayer'
7-
echo -n " Reading in file MPlayer version ... "
23+
echo -e ">>> ${cMagenta}MPlayer${cReset}"
24+
echo -en " Reading in file ${cMagenta}MPlayer${cReset} version ... "
825
EXISTING=$(sed -n '/svn-[0-9]/p' pyradio/win.py | sed -e 's/.*svn-//' -e 's/-.*//')
926

10-
echo r${EXISTING}
27+
echo -e "${cYellow}r${EXISTING}${cReset}"
1128

12-
echo -n " Reading published MPlayer versions ... "
29+
echo -en " Reading published ${cMagenta}MPlayer${cReset} versions ... "
1330

1431
FOUND=$(curl -s -L 'https://sourceforge.net/projects/mplayerwin/files/MPlayer-MEncoder' 2>/dev/null | grep '<tr title' | sed -e 's/<tr title="//' -e 's/".*//'|grep -e '^r')
1532

16-
if [ $? -eq 0 ]
33+
if [ $? -ne 0 ]
1734
then
18-
echo "$FOUND" | sed '2,$d'
19-
else
2035
echo -e '\n Error accessing SourceForge...'
2136
exit 1
2237
fi
@@ -29,9 +44,11 @@ function get_mplayer(){
2944
then
3045
if [ r"${EXISTING}" = "$n" ]
3146
then
32-
echo "Latest MPlayer version already used..."
47+
echo -e "$FOUND" | sed -e '2,$d' -e "s/.*/${cYellow}&${cReset}/"
48+
echo -e "Latest ${cMagenta}MPlayer${cReset} version already used..."
3349
return
3450
else
51+
echo -e "$FOUND" | sed -e '2,$d' -e "s/.*/${cRes}&${cReset}/"
3552
TO_USE="${n/r/}"
3653
break
3754
fi
@@ -44,22 +61,22 @@ function get_mplayer(){
4461
echo "Version to use: ${TO_USE}"
4562
fi
4663

47-
echo -n " Updating in file MPlayer version ... "
64+
echo -en " Updating in file ${cMagenta}MPlayer${cReset} version ... "
4865
sed -i "/MPlayer-MEncoder/s/$EXISTING/$TO_USE/g" pyradio/win.py
49-
echo "done"
66+
echo -e "${cGreen}done"${cReset}
5067
}
5168

5269
function get_mpv(){
5370
local EXISTING
5471
local FOUND
5572
local TO_USE
56-
echo '>>> MPV'
57-
echo -n ' Reading in file MPV version ... '
73+
echo -e ">>> ${cMagenta}MPV${cReset}"
74+
echo -en " Reading in file ${cMagenta}MPV${cReset} version ... "
5875
EXISTING=$(grep mpv-player-windows pyradio/win.py | grep download | grep -v latest | sed -e "s/.*'h/h/" -e "s/',//")
5976
EXISTING=$(basename $(dirname "$EXISTING"))
60-
echo "$EXISTING"
77+
echo -e "${cYellow}$EXISTING${cReset}"
6178

62-
echo -n ' Reading latest MPV version ... '
79+
echo -en " Reading latest ${cMagenta}MPV${cReset} version ... "
6380
FOUND=$(curl -s -L https://sourceforge.net/projects/mpv-player-windows/files/64bit/ 2>/dev/null | grep '"url":"/projects' | sed 's/"url":/\n&/g' |grep '^"url"' | sed '2,$d' | sed -e 's/"url":"//' -e 's|/","full_path":".*||')
6481

6582
if [ $? -ne 0 ]
@@ -68,19 +85,21 @@ function get_mpv(){
6885
exit 1
6986
fi
7087
FOUND=$(basename "$FOUND")
71-
echo "$FOUND"
7288

7389
if [ "$FOUND" != "$EXISTING" ]
7490
then
75-
echo -n " Updating in file MPV version ... "
91+
echo "${cRed}$FOUND"
92+
echo -ne " Updating in file ${cMagenta}MPV${cReset} version ... "
7693
sed -i "s/$EXISTING/$FOUND/" pyradio/win.py
77-
echo "done"
94+
echo -e "${cGreen}done${cReset}"
7895
else
79-
echo "Latest MPV version already used..."
96+
echo "${cYellow}$FOUND${cReset}"
97+
echo -e "Latest ${cMagenta}MPV${cReset} version already used..."
8098
fi
8199
}
82100

83-
echo "Working on pyradio/win.py"
101+
echo -e "Updating ${cBlue}Windows Players Links${cReset}"
102+
echo -e "Working on ${cGreen}pyradio/win.py${cReset}"
84103
get_mpv
85104
get_mplayer
86105
exit 0

docs/macos.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ <h2 id="preparation">Preparation <span style="padding-left: 10px;"><sup style="f
7070
<h3 id="homebrew-installation">Homebrew installation</h3>
7171
<p>This is the method <a target="_blank" href="https://brew.sh">Homebrew</a> recommends, so we just go with it.</p>
7272
<p>Open a terminal and execute:</p>
73-
<!-- START OF BREW LINK-->
73+
<!-- START OF BREW LINK -->
7474
<pre>/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;</pre>
75-
<!-- END OF BREW LINK-->
75+
<!-- END OF BREW LINK -->
7676
<h3 id="python-installation">Python Installation</h3>
7777
<p>Your system comes with a pre-installed version of Python, but it would be better to install the one provided by <strong>Homebrew</strong>.</p>
7878
<pre>brew install python3</pre>

docs/macos.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ This is the method [Homebrew](https://brew.sh) recommends, so we just go with it
3939

4040
Open a terminal and execute:
4141

42-
<!-- START OF BREW LINK-->
42+
<!-- START OF BREW LINK -->
4343
```
4444
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
4545
```
46-
<!-- END OF BREW LINK-->
46+
<!-- END OF BREW LINK -->
4747

4848
### Python Installation
4949

pyradio/config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,21 @@ def _get_sting_to_save(self, theme, trnsp, calcf, rec_dir):
24982498
chk = self._validate_config_key(n, theme, trnsp, calcf, rec_dir)
24992499
if chk:
25002500
out.append(chk)
2501+
if not self.show_no_themes_message:
2502+
out.append('#')
2503+
out.append('# User option (response to a message window)')
2504+
out.append('# Show a message if themes are disabled')
2505+
out.append('#')
2506+
out.append('# Default value: True')
2507+
out.append('show_no_themes_message = False')
2508+
if not self.show_recording_start_message:
2509+
out.append('#')
2510+
out.append('# User option (response to a message window)')
2511+
out.append('# Show a message when recording is enabled')
2512+
out.append('#')
2513+
out.append('# Default value: True')
2514+
out.append('show_recording_message = False')
2515+
25012516
if out:
25022517
out.reverse()
25032518
out.append('#')

pyradio/config_window.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ def __init__(self, parent, config,
173173
self._reset_parameters_function = reset_parameters_function
174174
self._saved_config_options = deepcopy(config.opts)
175175
self._config_options = deepcopy(config.opts)
176+
self._default_config_opts = config.config_opts
177+
178+
self._orig_redording_dir = self._config_options['recording_dir'][1]
179+
# for n in self._default_config_opts, self._saved_config_options, self._config_options:
180+
# logger.info('=============')
181+
# for k in n.keys():
182+
# logger.info('{}: {}'.format(k, n[k]))
183+
176184
self._old_theme = self._config_options['theme'][1]
177185
if logger.isEnabledFor(logging.INFO):
178186
if self._saved_config_options == self._config_options:
@@ -523,8 +531,9 @@ def _load_default_values(self):
523531
self._config_options['enable_mouse'][1] = 'False'
524532
self._config_options['enable_notifications'][1] = '-1'
525533
self._config_options['use_station_icon'][1] = 'True'
526-
self._config_options['recording_dir'][1] = path.join(path.expanduser('~'), 'pyradio-recordings')
527-
opts['resource_opener'] = ['Resource Opener: ', 'auto']
534+
''' exclude recording dir from getting its default value '''
535+
# self._config_options['recording_dir'][1] = path.join(path.expanduser('~'), 'pyradio-recordings')
536+
self._config_options['resource_opener'] = ['Resource Opener: ', 'auto']
528537
self._config_options['connection_timeout'][1] = '10'
529538
self._config_options['theme_title'][1] = ''
530539
''' Transparency '''
@@ -626,10 +635,11 @@ def _go_default(self):
626635
logger.info('Default options loaded')
627636

628637
def _go_saved(self):
638+
old_theme = self._config_options['theme'][1]
639+
old_transparency = self._config_options['use_transparency'][1]
640+
self._config_options = deepcopy(self._saved_config_options)
641+
self._config_options['recording_dir'][1] = self._orig_redording_dir
629642
if self._cnf.use_themes:
630-
old_theme = self._config_options['theme'][1]
631-
old_transparency = self._config_options['use_transparency'][1]
632-
self._config_options = deepcopy(self._saved_config_options)
633643
self._port_line_editor.string = self._config_options['remote_control_server_port'][1]
634644
''' Transparency '''
635645
self._config_options['use_transparency'][1] = self._old_use_transparency
@@ -643,10 +653,21 @@ def _go_saved(self):
643653
self._config_options['theme'][1] = self._old_theme
644654
self._saved_config_options['theme'][1] = self._old_theme
645655
self._apply_a_theme(self._config_options['theme'][1], self._old_use_transparency)
656+
else:
657+
self._config_options['use_transparency'][1] = False
658+
self._config_options['force_transparency'][1] = False
659+
self._config_options['theme'][1] = 'dark'
660+
self._config_options['auto_update_theme'][1] = False
661+
self._config_options['calculated_color_factor'][1] = "0"
662+
646663
self._reset_parameters_function()
647664
self.refresh_selection()
648-
if logger.isEnabledFor(logging.INFO):
649-
logger.info('Saved options loaded')
665+
if self._cnf.use_themes:
666+
if logger.isEnabledFor(logging.INFO):
667+
logger.info('Saved options loaded')
668+
else:
669+
if logger.isEnabledFor(logging.INFO):
670+
logger.info('No themes saved options loaded')
650671

651672
def _go_exit(self):
652673
self._win.nodelay(True)

0 commit comments

Comments
 (0)