detect.py: simplify detect_system code