Update exception catching syntax

In order to support newer versions of Python, the old syntax needs to be
replaced. Sorry Python 2.5.
Update imports

`urlparse` has moved. Python 3 moved it to `urllib.parse`. A try/except
can be used to handle supporting both Python 2 and 3. This also changes
(and simplifies) how to get `parse_qs`.

Since bed739f killed supported for Python 2.5, the old `sha` import can
be removed, using only the newer import instead.