Python Open Error Handling In Js