Fix subprocess.call; isolate log analysis in a separate function