restore write protection on directories

* @dagss originally put code in that didn't protect directories
* @certik introduced a non-portable fix to add directory protection
* I removed the non-portable code when introducing `develop` functionality.
  (see 9d9f0b728bfc88d4b435b691bd95e3171159f1af )

Now I'm re-adding portable directory protection to protect us from
further foot-shooting.

We also need to temporarily allow writing to the artifact directory
after it's been built to store things like the id and build log.  I've
added a context manager to file utils based on a suggestion by @dagss to
simplify this.
Update skeleton template to follow move to setuptools.
Merge pull request #227 from lanewittgen/master

Update skeleton template to follow move to setuptools.
Better Unicode handling

This fixes a long-standing issue on Cygwin where Unicode-encoded error
messages from stderr were unable to be written to the ASCII-encoded
build log.  The messages are now explicitly converted to ASCII with
untranslatable characters ignored.
Merge pull request #228 from hashdist/ahmadia/unicode_fixes

Better Unicode handling -- Fix #153
Handle case where encoding is not set
Merge pull request #229 from hashdist/ahmadia/fix_encoding_2

Handle case where encoding is not set
Improve support for hit develop -l copy

We use hit develop -l copy to build a complete profile in-place that is
suitable for archiving or redistribution.

This improves support for profiles that use launcher by silently
ignoring requests to launchify executables, and allowing copy requests
to work for directories as well.
Merge pull request #230 from hashdist/ahmadia/better_copy_support

Improve support for hit develop -l copy
Merge pull request #224 from hashdist/ahmadia/restore_path_protection

[WIP] restore write protection on directories
Fix iglob for paths without read permissions

We recurse into the path until we have a permission to list the directory.
Fixes #235.
Merge pull request #236 from hashdist/iglob

Fix iglob for paths without read permissions
Speedup profile creation

Use os.access() to test if the directory can be read. The `listdir` approach is
very slow.

Fixes #237.
Merge pull request #238 from hashdist/profile_speedup

Speedup profile creation
Improve the output of `hit fetch`

Previously:

    $ hit fetch http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz
    Downloading http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz...
    Downloading 'http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz'
    [=========================] 100.0% (1.3MB of 1.3MB) 2.418MB/s ETA 0s

    tar.gz:xwpsaatz6dvrt7bi5uwz2yd57u4ofz6z

Now:

    $ hit fetch http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz
    Downloading http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz...
    Downloading 'http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz'
    [=========================] 100.0% (1.3MB of 1.3MB) 3.022MB/s ETA 0s

    url: http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz
    key: tar.gz:xwpsaatz6dvrt7bi5uwz2yd57u4ofz6z

The output can now be copy & pasted into the package.yaml
Improve the output even further

Actually, it is even better to simply output the actual lines that you can copy
and paste, so now the output is:

    $ hit fetch http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz
    Downloading http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz...
    Downloading 'http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz'
    [=========================] 100.0% (1.3MB of 1.3MB) 3.523MB/s ETA 0s

    sources:
    - url: http://llvm.org/releases/3.4/libcxx-3.4.src.tar.gz
      key: tar.gz:xwpsaatz6dvrt7bi5uwz2yd57u4ofz6z
Merge pull request #239 from hashdist/fetch_output

Improve the output of `hit fetch`
Update README.rst
Update README.rst
Improve config.yaml validation

Add hit self-check command

This should automatically be run any time a configuration is loaded,
similar to the way init-home is always run the first time hit is used.