def ReadDataFile(data_path, openfile=file):
 status = httplib.INTERNAL_SERVER_ERROR
 data = ''
 try:
  data_file = openfile(data_path, 'rb')
  try:
   data = data_file.read()
  finally:
   data_file.close()
   status = httplib.OK
 except (OSError, IOError) as e:
  logging.error('Error encountered reading file "%s":\n%s', data_path, e)
  if (e.errno in FILE_MISSING_EXCEPTIONS):
   status = httplib.NOT_FOUND
  else:
   status = httplib.FORBIDDEN
 return (status, data)

def ReadDataFile ( data_path , openfile = file ) : status = httplib . INTERNAL_SERVER_ERROR data = '' try : data_file = openfile ( data_path , 'rb' ) try : data = data_file . read ( ) finally : data_file . close ( ) status = httplib . OK except ( OSError , IOError ) as e : logging . error ( 'Error encountered reading file "%s":\n%s' , data_path , e ) if ( e . errno in FILE_MISSING_EXCEPTIONS ) : status = httplib . NOT_FOUND else : status = httplib . FORBIDDEN return ( status , data )
reads a file on disk .