summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-04-15 16:38:38 (GMT)
committerGuido van Rossum <guido@python.org>1992-04-15 16:38:38 (GMT)
commitf4be726da206ed1c34817a7b63a0c6e0281879ee (patch)
treebe32ede6bc9c34d69a023da5b33f6b8d49e9c3c0
parentb108e976a409982aeadf52b5742de2cbba55542e (diff)
downloadcpython-f4be726da206ed1c34817a7b63a0c6e0281879ee.zip
cpython-f4be726da206ed1c34817a7b63a0c6e0281879ee.tar.gz
cpython-f4be726da206ed1c34817a7b63a0c6e0281879ee.tar.bz2
Changed status format; added host argument; documented arguments;
fixed code for missing frame argument.
-rwxr-xr-xDemo/sgi/cd/sendcd.py51
1 files changed, 30 insertions, 21 deletions
diff --git a/Demo/sgi/cd/sendcd.py b/Demo/sgi/cd/sendcd.py
index 49900004..850f6a5 100755
--- a/Demo/sgi/cd/sendcd.py
+++ b/Demo/sgi/cd/sendcd.py
@@ -1,15 +1,23 @@
# Read CD audio data from the SCSI CD player and send it as UDP
-# packets to "readcd.py" on another host.
-# Option:
-# "-l" lists track info and quits.
-# "-s" displays status and quits.
+# packets to "recvcd.py" on another host.
+#
+# Usage: python sendcd.py [options] host [track | minutes seconds [frames]]
+#
+# Options:
+# "-l" list track info and quit.
+# "-s" display status and quit.
+#
+# Arguments:
+# host host to send the audio data to (required unless -l or -s).
+# track track number where to start; alternatively,
+# min sec [frames] absolute address where to start;
+# default is continue at current point according to status.
import cd
import sys
from socket import *
import getopt
-HOST = 'voorn.cwi.nl' # The host where readcd.py is run
PORT = 50505 # Must match the port in readcd.py
def main():
@@ -31,10 +39,15 @@ def main():
prstatus(player)
return
+ if not args:
+ sys.stderr.write('usage: ' + sys.argv[0] + ' host [track]\n')
+ sys.exit(2)
+ host, args = args[0], args[1:]
+
sys.stdout.write('waiting for socket... ')
sys.stdout.flush()
port = socket(AF_INET, SOCK_DGRAM)
- port.connect(HOST, PORT)
+ port.connect(host, PORT)
print 'socket connected'
parser = cd.createparser()
@@ -52,7 +65,7 @@ def main():
[min, sec, frame] = args[:3]
else:
[min, sec] = args
- frame = 0
+ frame = '0'
min, sec, frame = eval(min), eval(sec), eval(frame)
print 'Seek to', triple(min, sec, frame)
dummy = player.seek(min, sec, frame)
@@ -61,7 +74,7 @@ def main():
print 'Seek to track', track
dummy = player.seektrack(track)
else:
- min, sec, frame = player.getstatus()[5:8]
+ min, sec, frame = player.getstatus()[3]
print 'Try to seek back to', triple(min, sec, frame)
try:
player.seek(min, sec, frame)
@@ -87,11 +100,8 @@ def prtrackinfo(player):
except RuntimeError:
break
for i in range(len(info)):
- start_min, start_sec, start_frame, \
- total_min, total_sec, total_frame = info[i]
- print 'Track', zfill(i+1), \
- triple(start_min, start_sec, start_frame), \
- triple(total_min, total_sec, total_frame)
+ start, total = info[i]
+ print 'Track', zfill(i+1), triple(start), triple(total)
def audiocallback(port, type, data):
## sys.stdout.write('#')
@@ -117,25 +127,24 @@ def controlcallback(arg, type, data):
statedict = ['ERROR', 'NODISK', 'READY', 'PLAYING', 'PAUSED', 'STILL']
def prstatus(player):
- state, track, min, sec, frame, abs_min, abs_sec, abs_frame, \
- total_min, total_sec, total_frame, first, last, scsi_audio, \
- cur_block, dum1, dum2, dum3 = player.getstatus()
+ state, track, curtime, abstime, totaltime, first, last, \
+ scsi_audio, cur_block, dummy = player.getstatus()
print 'Status:',
if 0 <= state < len(statedict):
print statedict[state]
else:
print state
print 'Track: ', track
- print 'Time: ', triple(min, sec, frame)
- print 'Abs: ', triple(abs_min, abs_sec, abs_frame)
- print 'Total: ', triple(total_min, total_sec, total_frame)
+ print 'Time: ', triple(curtime)
+ print 'Abs: ', triple(abstime)
+ print 'Total: ', triple(totaltime)
print 'First: ', first
print 'Last: ', last
print 'SCSI: ', scsi_audio
print 'Block: ', cur_block
- print 'Future:', (dum1, dum2, dum3)
+ print 'Future:', dummy
-def triple(a, b, c):
+def triple((a, b, c)):
return zfill(a) + ':' + zfill(b) + ':' + zfill(c)
def zfill(n):