def open_stream(stream):
 global stream_fd
 try:
  stream_fd = stream.open()
 except StreamError as err:
  raise StreamError('Could not open stream: {0}'.format(err))
 try:
  console.logger.debug('Pre-buffering 8192 bytes')
  prebuffer = stream_fd.read(8192)
 except IOError as err:
  raise StreamError('Failed to read data from stream: {0}'.format(err))
 if (not prebuffer):
  raise StreamError('No data returned from stream')
 return (stream_fd, prebuffer)

def open_stream ( stream ) : global stream_fd try : stream_fd = stream . open ( ) except StreamError as err : raise StreamError ( 'Could not open stream: {0}' . format ( err ) ) try : console . logger . debug ( 'Pre-buffering 8192 bytes' ) prebuffer = stream_fd . read ( 8192 ) except IOError as err : raise StreamError ( 'Failed to read data from stream: {0}' . format ( err ) ) if ( not prebuffer ) : raise StreamError ( 'No data returned from stream' ) return ( stream_fd , prebuffer )
opens a stream and reads 8192 bytes from it .