Browse Source

add support for interactive debugging via manhole.telnet... add some

modules and provide functions to add to the namespace...

drop the media server since we now serve all of our content though
content..

[git-p4: depot-paths = "//depot/": change = 838]
v0.3
John-Mark Gurney 18 years ago
parent
commit
d4e43188b9
2 changed files with 44 additions and 19 deletions
  1. +35
    -0
      debug.py
  2. +9
    -19
      pymediaserv

+ 35
- 0
debug.py View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python

from twisted.internet import reactor

__all__ = [ 'appendnamespace', 'insertnamespace', ]

appendnamespace = lambda k, v: []
insertnamespace = lambda k, v: None

def doDebugging(opt):
if not opt:
return

from twisted.manhole import telnet

class Debug(telnet.Shell):
def welcomeMessage(self):
data = [ '', 'PyMedS Debugging Console', '', '' ]
return '\r\n'.join(data)
sf = telnet.ShellFactory()
sf.protocol = Debug
reactor.listenTCP(56283, sf)

global insertnamespace, appendnamespace

def insertnamespace(k, v):
assert isinstance(k, basestring)
sf.namespace[k] = v

def appendnamespace(k, v):
try:
sf.namespace[k].append(v)
except KeyError:
sf.namespace[k] = [ v ]

+ 9
- 19
pymediaserv View File

@@ -13,6 +13,12 @@ import dvd
import shoutcast
import ZipStorage # w/ tarfile support, it will gobble up empty files!

import debug # my debugging module
debug.doDebugging(True) # open up debugging port
debug.insertnamespace('dvd', dvd)
debug.insertnamespace('shoutcast', shoutcast)
debug.insertnamespace('ZipStorage', ZipStorage)

from DIDLLite import TextItem, AudioItem, VideoItem, ImageItem, Resource, StorageFolder
from FSStorage import FSDirectory
import os
@@ -44,6 +50,7 @@ log.startLogging(sys.stdout)
from SSDP import SSDPServer, SSDP_PORT, SSDP_ADDR

s = SSDPServer()
debug.insertnamespace('s', s)

port = reactor.listenMulticast(SSDP_PORT, s)
port.joinGroup(SSDP_ADDR)
@@ -73,8 +80,10 @@ class RootDevice(static.Data):
static.Data.__init__(self, d, 'text/xml')

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
debug.insertnamespace('cds', cds)
root.putChild('ContentDirectory', cds)
cds = cds.control
root.putChild('ConnectionManager', ConnectionManagerServer())
@@ -82,25 +91,6 @@ root.putChild('root-device.xml', RootDevice())
root.putChild('content', content)


# Area of server to serve media files from

from MediaServer import MediaServer

medianode = static.File('media')
medianode.contentTypes.update( {
'.wmv': 'video/x-ms-wmv',
#'.ts': 'video/mp2t',
'.ts': 'video/mpeg', # we may want this instead of mp2t
'.m2t': 'video/mpeg',
#'.mp4': 'video/mp4',
'.mp4': 'video/mpeg',
'.dat': 'video/mpeg', # VCD tracks
'.ogm': 'application/ogg',
'.vob': 'video/mpeg',
#'.m4a': 'audio/mp4', # D-Link can't seem to play AAC files.
})
root.putChild('media', medianode)

site = server.Site(root)
reactor.listenTCP(listenPort, site)



Loading…
Cancel
Save