[bug 1015788] Add flake8 linting

* adds flake8_lint.sh script
* fixes all flake8 issues in existing python files
* adds flake8_lint.pre-commit script which creates the git pre-commit
  hook

This is all cosmetic changes plus the flake8 pre-commit stuff.

r?