scripts: handle BrokenPipeError for python scripts