THRIFT-4370: build generated code before running static code analysis;
fix E722 flake8 issues identified in python code

This closes #1399
diff --git a/test/py/TestSocket.py b/test/py/TestSocket.py
index ae3160f..619eb10 100755
--- a/test/py/TestSocket.py
+++ b/test/py/TestSocket.py
@@ -36,7 +36,7 @@
                 self.listen_sock.bind(('localhost', self.port))
                 self.listen_sock.listen(5)
                 break
-            except:
+            except Exception:
                 if i == 49:
                     raise
 
@@ -50,7 +50,7 @@
                 socket.setTimeout(10)
                 socket.open()
                 leaky.append(socket)
-        except:
+        except Exception:
             self.assert_(time.time() - starttime < 5.0)
 
     def testWriteTimeout(self):
@@ -64,7 +64,7 @@
             while True:
                 lsock.write("hi" * 100)
 
-        except:
+        except Exception:
             self.assert_(time.time() - starttime < 5.0)