From 1e0d18c9324945c6c1342a2ce9066c8bd92d2b14 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 13 Sep 2006 00:16:55 -0800 Subject: [PATCH] add dependencies to the README, and include a couple patches... [git-p4: depot-paths = "//depot/": change = 887] --- README | 11 +++ patches/twisted.internet.tcp.py.patch | 34 ++++++++++ patches/twisted.web.static.py.patch | 98 +++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 patches/twisted.internet.tcp.py.patch create mode 100644 patches/twisted.web.static.py.patch diff --git a/README b/README index 0d5648e..839b8b9 100644 --- a/README +++ b/README @@ -20,6 +20,15 @@ Either make a directory media and put the files there, or make a symlink named media to your media files. Either will work. Run it as: ./pymediaserv [ ] +The following packages are required to run the media server: + * Twisted (only core and web necessary), Optional: patch to handle byte servering + * ElementTree + * SOAPpy available from Python Web Services + * fpconst (required by SOAPpy) + +For more information, check out the software page at: +http://resnet.uoregon.edu/~gurney_j/jmpc/pymeds.html + Good Luck! John-Mark Gurney @@ -39,6 +48,8 @@ Ideas for future improvements: Finish support for playing DVD stream. v0.x: + Include some patches for twisted in the distro, in the directory + patches. Look inside MPEG-TS for TVCT and/or PAT and if there is more than one program, make it a container w/ the different programs. diff --git a/patches/twisted.internet.tcp.py.patch b/patches/twisted.internet.tcp.py.patch new file mode 100644 index 0000000..31cfbb6 --- /dev/null +++ b/patches/twisted.internet.tcp.py.patch @@ -0,0 +1,34 @@ +--- Twisted-2.1.0/twisted/internet/tcp.py Sat Oct 8 21:10:44 2005 ++++ /usr/local/lib/python2.4/site-packages/twisted/internet/tcp.py Tue Sep 5 23:33:41 2006 +@@ -43,6 +43,7 @@ + from errno import WSAEINPROGRESS as EINPROGRESS + from errno import WSAEALREADY as EALREADY + from errno import WSAECONNRESET as ECONNRESET ++ from errno import WSAECONNRESET as ECONNABORTED + from errno import WSAEISCONN as EISCONN + from errno import WSAENOTCONN as ENOTCONN + from errno import WSAEINTR as EINTR +@@ -55,6 +56,7 @@ + from errno import EINPROGRESS + from errno import EALREADY + from errno import ECONNRESET ++ from errno import ECONNABORTED + from errno import EISCONN + from errno import ENOTCONN + from errno import EINTR +@@ -752,10 +754,13 @@ + try: + skt, addr = self.socket.accept() + except socket.error, e: +- if e.args[0] in (EWOULDBLOCK, EAGAIN): ++ errno = e.args[0] ++ if not isinstance(errno, type(EAGAIN)): ++ errno = errno[0] ++ if errno in (EWOULDBLOCK, EAGAIN, ECONNABORTED): + self.numberAccepts = i + break +- elif e.args[0] == EPERM: ++ elif errno == EPERM: + continue + raise + diff --git a/patches/twisted.web.static.py.patch b/patches/twisted.web.static.py.patch new file mode 100644 index 0000000..e34d1dc --- /dev/null +++ b/patches/twisted.web.static.py.patch @@ -0,0 +1,98 @@ +--- TwistedWeb-0.5.0/twisted/web/static.py Sun Jan 2 15:33:41 2005 ++++ /usr/local/lib/python2.4/site-packages/twisted/web/static.py Fri Feb 17 23:55:04 2006 +@@ -306,7 +306,7 @@ + #for content-length + fsize = size = self.getFileSize() + +-# request.setHeader('accept-ranges','bytes') ++ request.setHeader('accept-ranges','bytes') + + if self.type: + request.setHeader('content-type', self.type) +@@ -325,39 +325,59 @@ + if request.setLastModified(self.getmtime()) is http.CACHED: + return '' + ++ trans = True + # Commented out because it's totally broken. --jknight 11/29/04 +-# try: +-# range = request.getHeader('range') +-# +-# if range is not None: +-# # This is a request for partial data... +-# bytesrange = string.split(range, '=') +-# assert bytesrange[0] == 'bytes',\ +-# "Syntactically invalid http range header!" +-# start, end = string.split(bytesrange[1],'-') +-# if start: +-# f.seek(int(start)) +-# if end: +-# end = int(end) +-# size = end +-# else: +-# end = size +-# request.setResponseCode(http.PARTIAL_CONTENT) +-# request.setHeader('content-range',"bytes %s-%s/%s " % ( +-# str(start), str(end), str(size))) +-# #content-length should be the actual size of the stuff we're +-# #sending, not the full size of the on-server entity. +-# fsize = end - int(start) +-# +-# request.setHeader('content-length', str(fsize)) +-# except: +-# traceback.print_exc(file=log.logfile) ++# XXX - fixed? jmg 2/17/06 ++ try: ++ range = request.getHeader('range') ++ ++ tsize = size ++ if range is not None: ++ # This is a request for partial data... ++ bytesrange = string.split(range, '=') ++ assert bytesrange[0] == 'bytes',\ ++ "Syntactically invalid http range header!" ++ start, end = string.split(bytesrange[1],'-', 1) ++ if start: ++ f.seek(int(start)) ++ if end: ++ end = int(end) ++ else: ++ end = size - 1 ++ else: ++ lastbytes = int(end) ++ if size < lastbytes: ++ lastbytes = size ++ start = size - lastbytes ++ f.seek(start) ++ fsize = lastbytes ++ end = size - 1 ++ size = end + 1 ++ fsize = end - int(start) + 1 ++ # start is the byte offset to begin, and end is the byte offset ++ # to end.. fsize is size to send, tsize is the real size of ++ # the file, and size is the byte position to stop sending. ++ ++ if fsize <= 0: ++ request.setResponseCode(http.REQUESTED_RANGE_NOT_SATISFIABLE) ++ fsize = tsize ++ trans = False ++ else: ++ request.setResponseCode(http.PARTIAL_CONTENT) ++ request.setHeader('content-range',"bytes %s-%s/%s " % ( ++ str(start), str(end), str(tsize))) ++ except: ++ traceback.print_exc(file=log.logfile) + + request.setHeader('content-length', str(fsize)) +- if request.method == 'HEAD': ++ if request.method == 'HEAD' or trans == False: ++ # pretend we're a HEAD request, so content-length ++ # won't be overwritten. ++ request.method = 'HEAD' + return '' + + # return data ++ # size is the byte position to stop sending, not how many bytes to send + FileTransfer(f, size, request) + # and make sure the connection doesn't get closed + return server.NOT_DONE_YET