def grok_environment_error(exc, prefix='error: '):
 if (hasattr(exc, 'filename') and hasattr(exc, 'strerror')):
  if exc.filename:
   error = (prefix + ('%s: %s' % (exc.filename, exc.strerror)))
  else:
   error = (prefix + ('%s' % exc.strerror))
 else:
  error = (prefix + str(exc[(-1)]))
 return error

def grok_environment_error ( exc , prefix = 'error: ' ) : if ( hasattr ( exc , 'filename' ) and hasattr ( exc , 'strerror' ) ) : if exc . filename : error = ( prefix + ( '%s: %s' % ( exc . filename , exc . strerror ) ) ) else : error = ( prefix + ( '%s' % exc . strerror ) ) else : error = ( prefix + str ( exc [ ( - 1 ) ] ) ) return error
generate a useful error message from an environmenterror exception object .