Skip to content

Commit

Permalink
Merge pull request #289 from dlon/psutil-permissions
Browse files Browse the repository at this point in the history
Fix permissions error on Windows
  • Loading branch information
dae authored Feb 27, 2019
2 parents d6915ff + c6ab8dc commit 47eab46
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions anki/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 47eab46

Please sign in to comment.