tools, scripts: refactor error-out statements of Python scripts