Changeset 318 for py-tcpmultiplexer


Ignore:
Timestamp:
Jul 19, 2011, 3:41:33 PM (13 years ago)
Author:
Rick van der Zwet
Message:

First picture needs to valid for stream to be parsed correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • py-tcpmultiplexer/TCPMultiplexer.py

    r317 r318  
    7070            self.request.send("</ul><h3>Files</h3><ul>")
    7171            for root, dirs, files in os.walk(document_root):
     72              # Please do not show any hidden files or directories
     73              [dirs.remove(name) for name in dirs if name.startswith('.')]
     74              [files.remove(name) for name in files if name.startswith('.')]
    7275              for name in files:
    7376                self.request.send('<li><a href="%(item)s">%(item)s</li>' % { 'item' : os.path.join(root.replace(document_root,'',1),name) })
    74               # Please do not show any hidden file
    75               [dirs.remove(name) for name in dirs if name.startswith('.')]
    7677            self.request.send("</ul></body></html>")
    7778          elif urldata.has_key(urlid):
     
    120121
    121122      if datatype == 'wav':
     123        # WAV header
    122124        dataheader[urlid] = f.read(44)
    123125      elif datatype == 'mjeg':
    124         dataheader[urlid] = '\n'.join(f.read(100).split('\n')[0:2])
     126        # Get rid of Content-Length as not all pictures suits this setup
     127        headers = f.read(100).splitlines()[0:3]
     128        logger.info("Image headers %s", headers)
     129        valid_image = headers[0] + f.read(100000).split(headers[0])[1]
     130        dataheader[urlid] = valid_image + '\n'.join([h for h in headers if not h.startswith('Content-length:')]) + '\n'
    125131      else:
    126132        dataheader[urlid] = ''
     133
     134      logger.info("Using dataheader of length %s", len(dataheader[urlid]))
    127135
    128136      while running:
     
    156164  try:
    157165    import yaml
    158     streams = yaml.load(open(args.stream_cfg))
     166    streams.update(yaml.load(open(args.stream_cfg)))
    159167  except (ImportError, IOError) as e:
    160168    logging.warning("Stream config file '%s' not readable or parsable (%s)", args.stream_cfg, e)
Note: See TracChangeset for help on using the changeset viewer.