From c6ab8dcc48a21945eb0c58905e041fa042b60916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Wed, 27 Feb 2019 02:51:28 +0100 Subject: [PATCH] Fix permissions error on Windows --- anki/sound.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/anki/sound.py b/anki/sound.py index 8dc2223b5b2..147fe606cc6 100644 --- a/anki/sound.py +++ b/anki/sound.py @@ -149,16 +149,20 @@ def cleanupOldMplayerProcesses(): exeDir = os.path.dirname(os.path.abspath(sys.argv[0])) - for proc in psutil.process_iter(attrs=['pid', 'name', 'exe']): - if not proc.info['exe'] or proc.info['name'] != 'mplayer.exe': - continue + for proc in psutil.process_iter(): + try: + info = proc.as_dict(attrs=['pid', 'name', 'exe']) + if not info['exe'] or info['name'] != 'mplayer.exe': + continue - # not anki's bundled mplayer - if os.path.dirname(proc.info['exe']) != exeDir: - continue + # not anki's bundled mplayer + if os.path.dirname(info['exe']) != exeDir: + continue - print("terminating old mplayer process...") - proc.kill() + print("terminating old mplayer process...") + proc.kill() + except SystemError: + pass mplayerCmd = ["mplayer", "-really-quiet", "-noautosub"] if isWin: