Skip to content

Commit b213f48

Browse files
committed
- version 0.8.9.13 (0.9-beta10)
- fixing #148 - fixing a potential psutil crash
1 parent 6bafa23 commit b213f48

File tree

4 files changed

+65
-15
lines changed

4 files changed

+65
-15
lines changed

Changelog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2022-0213 s-n-g
2+
* version 0.8.9.13 (0.9-beta10)
3+
* fixing #148
4+
* fixing a potential psutil crash
5+
16
2022-01-26 s-n-g
27
* version 0.8.9.12 (0.9-beta9)
38
* Fixing install.py

README.html

+5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
143143
<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>
144144
<pre style="height: 200px;">
145145

146+
2022-0213 s-n-g
147+
* version 0.8.9.13 (0.9-beta10)
148+
* fixing #148
149+
* fixing a potential psutil crash
150+
146151
2022-01-26 s-n-g
147152
* version 0.8.9.12 (0.9-beta9)
148153
* Fixing install.py

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 8, 9, 12)
3+
version_info = (0, 8, 9, 13)
44

55
# Application state:
66
# New stable version: ''

pyradio/player.py

+54-14
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
pass
1818
if platform.startswith('win'):
1919
import win32pipe, win32file, pywintypes
20-
2120
try:
2221
from urllib import unquote
2322
except:
2423
from urllib.parse import unquote
25-
from .cjkwrap import wrap
26-
from .encodings import get_encodings
24+
25+
''' In case of import from win.py '''
26+
try:
27+
from .cjkwrap import wrap
28+
except:
29+
pass
30+
''' In case of import from win.py '''
31+
try:
32+
from .encodings import get_encodings
33+
except:
34+
pass
2735

2836
logger = logging.getLogger(__name__)
2937

@@ -120,6 +128,25 @@ def find_vlc_on_windows(config_dir=None):
120128
# result.append(os.path.join(root, name))
121129
#return result
122130

131+
def find_mpv_on_windows():
132+
for a_path in (
133+
os.path.join(os.getenv('APPDATA'), 'pyradio', 'mpv', 'mpv.exe'),
134+
os.path.join(os.getenv('APPDATA'), 'mpv', 'mpv.exe'),
135+
os.path.join(expanduser("~"), 'mpv', 'mpv.exe')
136+
):
137+
if os.path.exists(a_path):
138+
return a_path
139+
return 'mpv'
140+
141+
def find_mplayer_on_windows():
142+
for a_path in (
143+
os.path.join(os.getenv('APPDATA'), 'pyradio', 'mplayer', 'mplayer.exe'),
144+
os.path.join(os.getenv('APPDATA'), 'mplayer', 'mplayer.exe'),
145+
os.path.join(expanduser("~"), 'mplayer', 'mplayer.exe')
146+
):
147+
if os.path.exists(a_path):
148+
return a_path
149+
return 'mplayer'
123150

124151
def info_dict_to_list(info, fix_highlight, max_width):
125152
max_len = 0
@@ -620,7 +647,7 @@ def updateStatus(self, *args):
620647
self.GET_AUDIO_CODEC_NAME):
621648
response = self._send_mpv_command( a_cmd, return_response=True)
622649
if response:
623-
self._get_mpv_metadata(response, lambda: False)
650+
self._get_mpv_metadata(response, lambda: False, enable_crash_detection_function)
624651
self.info_display_handler()
625652
else:
626653
if logger.isEnabledFor(logging.INFO):
@@ -787,7 +814,7 @@ def updateMPVStatus(self, *args):
787814
if a_data:
788815
all_data = a_data.split(b'\n')
789816
for n in all_data:
790-
if self._get_mpv_metadata(n, stop):
817+
if self._get_mpv_metadata(n, stop, enable_crash_detection_function):
791818
self._request_mpv_info_data(sock)
792819
else:
793820
try:
@@ -1094,7 +1121,7 @@ def _get_mpv_metadata(self, *args):
10941121

10951122
a_data = args[0]
10961123
stop = args[1]
1097-
1124+
enable_crash_detection_function = [2]
10981125
if b'"icy-title":"' in a_data:
10991126
if version_info > (3, 0):
11001127
title = a_data.split(b'"icy-title":"')[1].split(b'"}')[0]
@@ -1421,18 +1448,21 @@ def _kill_process_tree(self, pid):
14211448
if logger.isEnabledFor(logging.DEBUG):
14221449
logger.debug('PID {} does not exist...'.format(pid))
14231450
return
1424-
children = parent.children(recursive=True)
14251451
try:
1426-
os.kill(parent.pid, 9)
1427-
except:
1428-
pass
1429-
for child in children:
1452+
children = parent.children(recursive=True)
14301453
try:
1431-
os.kill(child.pid, 9)
1454+
os.kill(parent.pid, 9)
14321455
except:
14331456
pass
1434-
if logger.isEnabledFor(logging.DEBUG):
1435-
logger.debug('PID {} (and its children) killed...'.format(pid))
1457+
for child in children:
1458+
try:
1459+
os.kill(child.pid, 9)
1460+
except:
1461+
pass
1462+
if logger.isEnabledFor(logging.DEBUG):
1463+
logger.debug('PID {} (and its children) killed...'.format(pid))
1464+
except psutil.NoSuchProcess:
1465+
pass
14361466

14371467
def _killall(self, name):
14381468
if name:
@@ -1524,6 +1554,11 @@ class MpvPlayer(Player):
15241554

15251555
PLAYER_NAME = 'mpv'
15261556
PLAYER_CMD = 'mpv'
1557+
WIN = False
1558+
if platform.startswith('win'):
1559+
WIN = True
1560+
if WIN:
1561+
PLAYER_CMD = find_mpv_on_windows()
15271562
NEW_PROFILE_STRING = 'volume=50\n\n'
15281563
if pywhich(PLAYER_CMD):
15291564
executable_found = True
@@ -1951,6 +1986,11 @@ class MpPlayer(Player):
19511986

19521987
PLAYER_NAME = 'mplayer'
19531988
PLAYER_CMD = 'mplayer'
1989+
WIN = False
1990+
if platform.startswith('win'):
1991+
WIN = True
1992+
if WIN:
1993+
PLAYER_CMD = find_mplayer_on_windows()
19541994
NEW_PROFILE_STRING = 'softvol=1\nsoftvol-max=300\nvolstep=1\nvolume=50\n\n'
19551995
if pywhich(PLAYER_CMD):
19561996
executable_found = True

0 commit comments

Comments
 (0)