Skip to content

Commit 1306da8

Browse files
committed
- fixing potential update thread crash
- build_install_pyradio will report exit code
1 parent 6a123a2 commit 1306da8

File tree

6 files changed

+88
-36
lines changed

6 files changed

+88
-36
lines changed

Changelog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
2021-10-14 s-n-g
1+
2021-10-20 s-n-g
22
* adding check for -p parameter (int)
33
* keep looking for a station after playback failure when random is on
44
* trying to better VLC start of playback detection
55
* last opened playlist will restore station selection or resume playback
66
* trying to eliminate crashes when window width gets small
77
(like in tilling managers)
88
* show correct help page when in online browser
9+
* disabling theme editing per (#141)
910
* mplayer on Windows: do not fail to start a station
1011
after astop/start command
1112
* install.py will always use the requested python version
13+
* install.py will use special indication per command line
14+
(-sng for --sng-master and -sng-dev for --sng-devel)
1215
* Windows installation will fail if a dependency fails to install
1316
* updating docs (adding "Limited display" image")
1417

README.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,20 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
142142
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
143143
<pre style="height: 200px;">
144144

145-
2021-10-14 s-n-g
145+
2021-10-20 s-n-g
146146
* adding check for -p parameter (int)
147147
* keep looking for a station after playback failure when random is on
148148
* trying to better VLC start of playback detection
149149
* last opened playlist will restore station selection or resume playback
150150
* trying to eliminate crashes when window width gets small
151151
(like in tilling managers)
152152
* show correct help page when in online browser
153+
* disabling theme editing per (#141)
153154
* mplayer on Windows: do not fail to start a station
154155
after astop/start command
155156
* install.py will always use the requested python version
157+
* install.py will use special indication per command line
158+
(-sng for --sng-master and -sng-dev for --sng-devel)
156159
* Windows installation will fail if a dependency fails to install
157160
* updating docs (adding "Limited display" image")
158161

devel/build_install_pyradio

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ function do_dev(){
173173
fi
174174
}
175175

176+
function do_exit(){
177+
# remove instasllation directory
178+
if [ ! -z "$REMOVE_DIR" ];then
179+
if [ "$REMOVE_DIR" = "$HOME/pyradio" ] || \
180+
[ "$REMOVE_DIR" = "$HOME/tmp-pyradio" ] || \
181+
[ "$REMOVE_DIR" = "/tmp/pyradio" ] || \
182+
[ "$REMOVE_DIR" = "/tmp/tmp-pyradio" ];then
183+
sudo rm -fr "$REMOVE_DIR"
184+
fi
185+
fi
186+
}
187+
176188
TO_PYTHON=3
177189
TO_PYTHON_FROM_X=''
178190
NO_DEV=''
@@ -278,11 +290,15 @@ uninstall 1
278290
}
279291

280292
# build and install project
281-
python"${TO_PYTHON}" setup.py build && {
293+
python"${TO_PYTHON}" setup.py build
294+
if [ $? -eq 0 ]
295+
then
282296
[ -z "$TO_USER" ] && {
283297
echo "***** installing..."
284298
do_dev
285-
sudo python"${TO_PYTHON}" setup.py install && {
299+
sudo python"${TO_PYTHON}" setup.py install
300+
if [ $? -eq 0 ]
301+
then
286302
[ -z "${NO_DEV}" ] && mv pyradio/config.py.dev pyradio/config.py
287303
gzip -k pyradio.1
288304
sudo mv -f pyradio.1.gz /usr/share/man/man1 2>/dev/null || sudo mv -f pyradio.1.gz /usr/local/share/man/man1
@@ -306,11 +322,16 @@ python"${TO_PYTHON}" setup.py build && {
306322
else
307323
sudo cp LICENCE "$DOC"
308324
fi
309-
}
325+
else
326+
do_exit
327+
exit 1
328+
fi
310329
} || {
311330
echo "***** installing for user..."
312331
do_dev
313-
python"${TO_PYTHON}" setup.py install --user && {
332+
python"${TO_PYTHON}" setup.py install --user
333+
if [ $? -eq 0 ]
334+
then
314335
[ -z "${NO_DEV}" ] && mv pyradio/config.py.dev pyradio/config.py
315336
gzip -k pyradio.1
316337
gzip -k pyradio_rb.1
@@ -336,17 +357,15 @@ python"${TO_PYTHON}" setup.py build && {
336357
else
337358
cp LICENCE "$DOC"
338359
fi
339-
}
360+
else
361+
do_exit
362+
exit 1
363+
fi
340364
}
341-
}
342-
343-
# remove instasllation directory
344-
if [ ! -z "$REMOVE_DIR" ];then
345-
if [ "$REMOVE_DIR" = "$HOME/pyradio" ] || \
346-
[ "$REMOVE_DIR" = "$HOME/tmp-pyradio" ] || \
347-
[ "$REMOVE_DIR" = "/tmp/pyradio" ] || \
348-
[ "$REMOVE_DIR" = "/tmp/tmp-pyradio" ];then
349-
sudo rm -fr "$REMOVE_DIR"
350-
fi
365+
else
366+
do_exit
367+
exit 1
351368
fi
352369

370+
do_exit
371+
exit 0

devel/build_install_pyradio.bat

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,33 +127,42 @@ FOR /R .\... %%f in (*.pyc) DO DEL /q "%%~ff"
127127

128128

129129
IF "%NO_DEV%" == "1" (
130-
CD pyradio
131-
%PROGRAM% -c "from install import windows_put_devel_version; windows_put_devel_version()"
132-
cd ..
130+
CD pyradio
131+
%PROGRAM% -c "from install import windows_put_devel_version; windows_put_devel_version()"
132+
cd ..
133133
)
134134
%PROGRAM% setup.py build
135135
IF %ERRORLEVEL% == 0 GOTO install
136+
ECHO.
137+
ECHO.
138+
ECHO ###############################################
139+
ECHO # The installation has failed! #
140+
ECHO # #
141+
ECHO # Please make sure your internet connection #
142+
ECHO # is working and try again. #
143+
ECHO ###############################################
136144
GOTO endofscript
137145

138146
:install
139147
%PROGRAM% setup.py install
140148
IF %ERRORLEVEL% == 0 GOTO installhtml
149+
:installationerror
141150
ECHO.
142151
ECHO.
143152
ECHO ###############################################
144153
ECHO # The installation has failed! #
145154
ECHO # #
146155
ECHO # This is probably because PyRadio is already #
147-
ECHO # running, so files canNOT be overwritten. #
156+
ECHO # running, so files cannot be overwritten. #
148157
ECHO # Please terminate PyRadio and try again. #
149158
ECHO ###############################################
150159
GOTO endofscript
151160

152161
:installhtml
153162
IF "%NO_DEV%"=="1" (
154163
DEL DEV
155-
cd pyradio
156-
DELETE config.py
164+
CD pyradio
165+
DEL config.py
157166
RENAME config.py.dev config.py
158167
CD ..
159168
)
@@ -176,11 +185,15 @@ GOTO toend
176185
CLS
177186
ECHO The installation has failed
178187
ECHO.
179-
ECHO One of PyRadio's dependencies has not been found
188+
ECHO This means that either you internet connection
189+
ECHO has failed (in which case you should fix it and
190+
ECHO try again), or that
191+
ECHO.
192+
ECHO one of PyRadio's dependencies has not been found
180193
ECHO( package: !ERRPKG!
181194
ECHO.
182-
ECHO This means that packagers have not yet produced a
183-
ECHO package for this version of python (it was
195+
ECHO If this is the case, packagers have not yet produced
196+
ECHO a package for this version of python (it was
184197
ECHO probably released recently).
185198
ECHO.
186199
ECHO What can you do?

pyradio/install.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,21 @@ def version_string_to_list(this_version):
111111
while len(a_l) < 4:
112112
a_l.append('0')
113113
a_n_l = []
114-
for n in a_l:
114+
# logger.error('DE a_n_l = "{}"'.format(a_n_l))
115+
for i, n in enumerate(a_l):
115116
if 'beta' in n:
116117
a_n_l.append(-200+int(a_l[-1].replace('beta', '')))
117118
elif 'rc' in n:
118119
a_n_l.append(-100+int(a_l[-1].replace('rc', '')))
119120
elif 'r' in n:
120121
pass
121122
else:
122-
a_n_l.append(int(n))
123+
if len(n) < 4 and i > 0:
124+
try:
125+
a_n_l.append(int(n))
126+
except ValueError:
127+
pass
128+
# logger.error('DE a_n_l = "{}"'.format(a_n_l))
123129
return a_n_l
124130

125131
def get_github_long_description(
@@ -492,7 +498,6 @@ def update_or_uninstall_on_windows(self, mode='update'):
492498
sys.exit(1)
493499

494500
if mode.endswith('-open'):
495-
print('---------------------')
496501
os.startfile(self._dir)
497502

498503
def open_windows_dir(self):
@@ -599,10 +604,20 @@ def _download_pyradio(self):
599604
get new install.py, copy.py (any py)
600605
into downloaded directory
601606
'''
602-
# from shutil import copyfile
603-
# cur_dir = os.getcwd()
604-
# copyfile('/home/spiros/projects/my-gits/pyradio/pyradio/install.py', os.path.join(cur_dir, 'install.py'))
605-
# copyfile('/home/spiros/projects/my-gits/pyradio/pyradio/config.py', os.path.join(cur_dir, 'config.py'))
607+
'''
608+
from shutil import copyfile
609+
cur_dir = os.getcwd()
610+
print('\n\n{}\n\n'.format(os.path.join(self._dir, self.ZIP_DIR[self._package])))
611+
print(cur_dir)
612+
copyfile('/home/spiros/projects/my-gits/pyradio/pyradio/install.py',
613+
os.path.join(cur_dir, 'install.py'))
614+
copyfile('/home/spiros/projects/my-gits/pyradio/devel/build_install_pyradio', \
615+
os.path.join(os.path.join(self._dir, self.ZIP_DIR[self._package],
616+
'devel', 'build_install_pyradio'))
617+
)
618+
# copyfile('/home/spiros/projects/my-gits/pyradio/pyradio/config.py',
619+
# os.path.join(self._dir, self.ZIP_DIR[self._package], 'pyradio', 'config.py'))
620+
'''
606621

607622
def _mkdir(self, name, dir_exist_function=None, _permission_error_function=None):
608623
if os.path.isdir(name):

pyradio/radio.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,10 +3797,10 @@ def to_time(secs):
37973797
logger.debug('detectUpdateThread: Asked to stop. Stoping...')
37983798
break
37993799

3800-
logger.error('DE last_tag = "{}"'.format(last_tag))
3800+
# logger.error('DE last_tag = "{}"'.format(last_tag))
38013801
if self._force_update:
38023802
last_tag = self._force_update
3803-
logger.error('DE last_tag = "{}"'.format(last_tag))
3803+
# logger.error('DE last_tag = "{}"'.format(last_tag))
38043804

38053805
if last_tag:
38063806
connection_fail_count = 0
@@ -3813,7 +3813,6 @@ def to_time(secs):
38133813
logger.info('detectUpdateThread: No update found. Will check again in {} days. Terminating...'.format(check_days))
38143814
break
38153815
else:
3816-
logger.error('DE 1 this_version = {}'.format(this_version))
38173816
existing_version = version_string_to_list(this_version)
38183817
new_version = version_string_to_list(last_tag)
38193818
if logger.isEnabledFor(logging.DEBUG):

0 commit comments

Comments
 (0)