Fix cloud-init Python syntax for Python < 2.6

The loguserdata.py file gets uploaded to the servers created by Heat to run
under cloud-init. Since the default versions of Python installed on the
user's server may be very old (e.g. RHEL 5 defaults to Python 2.4), avoid
using the octal syntax introduced for Python 3.0 and backported only as far
as Python 2.6. (Also avoid the old syntax, which will break on Python 3.x.)

Also remove use of the "with" statement from loguserdata.py and
part-handler.py. This statement is only available from Python 2.6 on (or in
Python 2.5 via "from __future__ import with_statement").

Finally, remove use of the "except ExceptionType as value" syntax for
catching exceptions. Again, this was only backported to Python 2.6.

Change-Id: I89e86d00993d51e2514b1e589503c6d966909403
Partial-Bug: #1375864
Merge "Fix cloud-init Python syntax for Python < 2.6"