[SPARK-2974] [SPARK-2975] Fix two bugs related to spark.local.dirs

This PR fixes two bugs related to `spark.local.dirs` and `SPARK_LOCAL_DIRS`, one where `Utils.getLocalDir()` might return an invalid directory (SPARK-2974) and another where the `SPARK_LOCAL_DIRS` override didn't affect the driver, which could cause problems when running tasks in local mode (SPARK-2975).

This patch fixes both issues: the new `Utils.getOrCreateLocalRootDirs(conf: SparkConf)` utility method manages the creation of local directories and handles the precedence among the different configuration options, so we should see the same behavior whether we're running in local mode or on a worker.

It's kind of a pain to mock out environment variables in tests (no easy way to mock System.getenv), so I added a `private[spark]` method to SparkConf for accessing environment variables (by default, it just delegates to System.getenv).  By subclassing SparkConf and overriding this method, we can mock out SPARK_LOCAL_DIRS in tests.

I also fixed a typo in PySpark where we used `SPARK_LOCAL_DIR` instead of `SPARK_LOCAL_DIRS` (I think this was technically innocuous, but it seemed worth fixing).
The changes look fine for yarn.  This way does have more logic to look it up and check for existence every time its called, but as long as this isn't called very many times it shouldn't be a problem.  I think its only called 3 times right now (DiskManager, Broadcast, and potentially on fetchfile).  I guess if you are fetching a lot of files and have a lot of disks (you can easily have systems with 12+ disks) it could be excessive to keep looking up and checking.

There is also logic in the ApplicationMaster and ExecutorLauncher (for both stable and alpha) for yarn for setting the spark.local.dir. I think we can also remove that code.