diff --git a/Changelog b/Changelog index 058cca52..90511fcb 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,11 @@ +2023-06-14 s-n-g + * version 0.9.2.10 + * all PyRadio threads will terminate when Alt-F4 or the + close button is used to close the program + * adding a message about dateutil module missing + * fixing a Windows error that has made PyRadio unusable + on Windows + 2023-06-13 s-n-g * version 0.9.2.9 * fixing: Remote Control Server does not terminate when diff --git a/README.html b/README.html index ed2669b7..2ef29068 100644 --- a/README.html +++ b/README.html @@ -207,6 +207,14 @@
+2023-06-14 s-n-g + * version 0.9.2.10 + * all PyRadio threads will terminate when Alt-F4 or the + close button is used to close the program + * adding a message about dateutil module missing + * fixing a Windows error that has made PyRadio unusable + on Windows + 2023-06-13 s-n-g * version 0.9.2.9 * fixing: Remote Control Server does not terminate when diff --git a/pyproject.toml b/pyproject.toml index 1e768be9..d745fdbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pyradio" -version = "0.9.2.9" +version = "0.9.2.10" authors = [ { name="Ben Dowling", email="ben.m.dowling@gmail.com" }, { name="Spiros Georgaras", email="sng@hellug.gr" }, diff --git a/pyradio/__init__.py b/pyradio/__init__.py index e7a550f1..1238b0f6 100644 --- a/pyradio/__init__.py +++ b/pyradio/__init__.py @@ -1,6 +1,6 @@ " pyradio -- Console radio player. " -version_info = (0, 9, 2, 9) +version_info = (0, 9, 2, 10) # Set it to True if new stations have been # added to the package's stations.csv diff --git a/pyradio/config.py b/pyradio/config.py index b4a70527..a0ee9d0b 100644 --- a/pyradio/config.py +++ b/pyradio/config.py @@ -16,7 +16,7 @@ from subprocess import Popen from platform import system if system().lower() == 'windows': - from os import stastfile + from os import startfile from pyradio import version, stations_updated from .browser import PyRadioStationsBrowser, probeBrowsers diff --git a/pyradio/install.py b/pyradio/install.py index 32b18e60..b613abf7 100755 --- a/pyradio/install.py +++ b/pyradio/install.py @@ -15,7 +15,7 @@ ''' This is PyRadio version this install.py was released for ''' -PyRadioInstallPyReleaseVersion = '0.9.2.9' +PyRadioInstallPyReleaseVersion = '0.9.2.10' import locale locale.setlocale(locale.LC_ALL, "") diff --git a/pyradio/radio.py b/pyradio/radio.py index d718f1d8..c51a132e 100644 --- a/pyradio/radio.py +++ b/pyradio/radio.py @@ -1822,6 +1822,17 @@ def _give_me_a_search_class(self, operation_mode): def ctrl_c_handler(self, signum, frame, save_playlist=True): # ok + logger.error('signum = {}'.format(signum)) + logger.error('frame = {}'.format(frame)) + self.player.stop_update_notification_thread = True + self.player.stop_win_vlc_status_update_thread = True + if self.player: + # ok + self.detect_if_player_exited = False + self.stopPlayer( + show_message=False, + reset_playing=False + ) self._cls_update_stations = None self.detect_if_player_exited = False if self._cnf.dirty_playlist and save_playlist: @@ -1872,6 +1883,11 @@ def _wait_for_threads(self): except AttributeError: pass self.stop_update_notification_thread = True + try: + while self.log._desktop_notification_thread.is_alive(): + self.log._stop_desktop_notification_thread = True + except: + self.log._stop_desktop_notification_thread = True def _goto_playing_station(self, changing_playlist=False): ''' make sure playing station is visible ''' @@ -10047,12 +10063,32 @@ def _register_signals_handlers(self): def _linux_signal_handler(self, a_signal, a_frame): logger.error('DE ----==== _linux_signal_handler ====----') + + # self.ctrl_c_handler(0,0, True) + # for a_sig in self.handled_signals.keys(): + # try: + # signal.signal( + # self.handled_signals[a_sig], + # self.def_signal_handlers[a_sig] + # ) + # except: + # pass + # return + self._cls_update_stations = None + self.detect_if_player_exited = False self.log._stop_desktop_notification_thread = True + self.player.stop_update_notification_thread = True + self.player.stop_win_vlc_status_update_thread = True + if self.player: + # ok + self.detect_if_player_exited = False + self.stopPlayer( + show_message=False, + reset_playing=False + ) if self._system_asked_to_terminate: return self._system_asked_to_terminate = True - self.player.stop_update_notification_thread = True - self.player.stop_win_vlc_status_update_thread = True if logger.isEnabledFor(logging.INFO): # logger.info('System asked me to terminate (signal: {})!!!'.format(list(self.handled_signals.keys())[list(self.handled_signals.values()).index(a_signal)])) logger.info('My terminal got closed... Terminating...') @@ -10069,7 +10105,6 @@ def _linux_signal_handler(self, a_signal, a_frame): sel._cnf.online_browser = None self.player.close() self._cnf.save_config() - #self._wait_for_threads() self._cnf.remove_session_lock_file() for a_sig in self.handled_signals.keys(): try: @@ -10083,6 +10118,7 @@ def _linux_signal_handler(self, a_signal, a_frame): ret, _ = self._remote_control_server.close_server() if ret: self._remote_control_server = None + self._wait_for_threads() def _windows_signal_handler(self, event): ''' windows signal handler diff --git a/pyradio/simple_curses_widgets.py b/pyradio/simple_curses_widgets.py index 8d6c101e..34edb81f 100644 --- a/pyradio/simple_curses_widgets.py +++ b/pyradio/simple_curses_widgets.py @@ -1,8 +1,36 @@ # -*- coding: utf-8 -*- import curses import curses.ascii +from sys import exit from datetime import date, time, datetime, timedelta -from dateutil.relativedelta import relativedelta +try: + from dateutil.relativedelta import relativedelta +except: + print('''Error: Module "dateutil" not found! + +Please install the above module and try again. + +Debian based distros: +sudo apt install python3-dateutil + +Arch based distros: +sudo pacman install python-dateutil + +Fedora based distros: +sudo dnf install python-dateutil + +openSUSE based distros: +sudo zypper install python3-dateutil + +If everything else fails, try: +python -m pip install dateutil +or +python3 -m pip install dateutil +or even +python -m pip install --user dateutil + +''') + exit(1) import logging from sys import version_info, platform, version # try: