summaryrefslogtreecommitdiff
path: root/play.py
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2011-03-14 21:18:02 (GMT)
committerAdrian C. (anrxc) <anrxc@sysphere.org>2011-03-14 21:18:02 (GMT)
commite4d238b6080cd3bcae6de45cdcf6a4df2df9f494 (patch)
tree8e14d579b0ddfd74667c904095c3f697fc68175c /play.py
parent75be0e23b77900da37f143b75031fd00a8f7201b (diff)
downloadplay-e4d238b6080cd3bcae6de45cdcf6a4df2df9f494.tar.xz
play: unlink mplayer FIFO on exit
Diffstat (limited to 'play.py')
-rwxr-xr-xplay.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/play.py b/play.py
index 99b8304..d21ff18 100755
--- a/play.py
+++ b/play.py
@@ -1309,14 +1309,18 @@ class TimeOffsetPlayerMplayer(Player):
re_progress = re.compile("^A:.*?(\d+)\.\d \([^)]+\) of (\d+)\.\d")
def play(self):
- if os.path.exists(CONTROL_FIFO + "-mplayer"):
- os.unlink(CONTROL_FIFO + "-mplayer")
- os.mkfifo(CONTROL_FIFO + "-mplayer", 0600)
- Player.play(self)
- fifo = open(CONTROL_FIFO + "-mplayer", 'w')
- fifo.write("seek %d\n" % self.offset)
- fifo.flush()
- fifo.close()
+ self.fd = None
+ try:
+ if os.path.exists(CONTROL_FIFO + "-mplayer"):
+ os.unlink(CONTROL_FIFO + "-mplayer")
+ os.mkfifo(CONTROL_FIFO + "-mplayer", 0600)
+ Player.play(self)
+ self.fd = open(CONTROL_FIFO + "-mplayer", "w")
+ self.fd.write("seek %d\n" % self.offset)
+ self.fd.flush()
+ self.fd.close()
+ except IOError:
+ return
def parse_buf(self):
match = self.re_progress.search(self.buf)
@@ -1480,7 +1484,10 @@ class Application:
tty and tty.tcsetattr(sys.stdin.fileno(), tty.TCSADRAIN, self.tcattr)
print
try:
- if os.path.exists(CONTROL_FIFO): os.unlink(CONTROL_FIFO)
+ if os.path.exists(CONTROL_FIFO):
+ os.unlink(CONTROL_FIFO)
+ if os.path.exists(CONTROL_FIFO + "-mplayer"):
+ os.unlink(CONTROL_FIFO + "-mplayer")
except IOError:
pass