fix "AttributeError: 'str' object has no attribute 'get'" and happy lint

This addresses an issue uncovered in https://github.com/saltstack/salt/issues/14426#issuecomment-50383774

Rather than return a string with an error message, when the expected return type is something other than a string, raise an exception when python-apt is missing.

Also address a handful of the lint issues that were encountered along the way. The rest will require significant refactoring.
@kiorky, I decided to tidy this up a bit, but realized that I might be circumventing the wrong AttributeError. In https://github.com/saltstack/salt/pull/14546, were you experiencing a missing ```_cache``` attribute or ```packages``` attribute. The name of the intermediate variable leads me to believe the former, in which case I suppose the getattr ought to be for ```_cache```. Let me know and I'll fix if necessary.