Fix pyflakes and pep8 in prep for flake8.

Change-Id: Ifc8c876760f8402fc3293326972b9286fb1635c9
Migrate to flake8.

Closes bug 1172444

Change-Id: I4831946d01f05c2a10264745a07b53fa48be44c8
Merge "Fix pyflakes and pep8 in prep for flake8."
Merge "Migrate to flake8."