detect.py: fix most pep8 and pylint reports