From 55252ae7263d6b8eef80db9603a0019cb9acd432 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sat, 8 Nov 2008 14:09:30 -0800 Subject: [PATCH] detect when media isn't a directory and report it... I did this once and it causes some weird errors in the cds... [git-p4: depot-paths = "//depot/": change = 1230] --- pymediaserv | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pymediaserv b/pymediaserv index e0df823..c9a24d6 100755 --- a/pymediaserv +++ b/pymediaserv @@ -104,7 +104,16 @@ class RootDevice(static.Data): root = WebServer() debug.insertnamespace('root', root) content = resource.Resource() -cds = ContentDirectoryServer('My Media Server', klass = FSDirectory, path = 'media', urlbase = os.path.join(urlbase, 'content'), webbase = content) # This sets up the root to be the media dir so we don't have to enumerate the directory +mediapath = 'media' +if not os.path.isdir(mediapath): + print >>sys.stderr, \ + 'Sorry, %s is not a directory, no content to serve.' % `mediapath` + sys.exit(1) + +# This sets up the root to be the media dir so we don't have to +# enumerate the directory +cds = ContentDirectoryServer('My Media Server', klass=FSDirectory, + path=mediapath, urlbase=os.path.join(urlbase, 'content'), webbase=content) debug.insertnamespace('cds', cds) root.putChild('ContentDirectory', cds) cds = cds.control