Cleaned code to make pylint and pep8 compliant

pylint -> changed from base exception to standard exception.