data-wa-gov-au / Hodor

Hodor: A command line interface for Google Maps Engine.
Other
16 stars 2 forks source link

Minor error checking issue during processing #20

Closed keithmoss closed 10 years ago

keithmoss commented 10 years ago

Had this issue with my version of hodor. (minor error checking bug during processing). I guess the error exception catch is needed during the polling of the DS status.

athodor

keithmoss commented 10 years ago

AT added a try/catch block.

If you think it better in the long run I can contribute to hodor code.
When you have a moment can you show us the basic in’s\out of github

  while processingStatus == "processing":
        get_authenticated_service(RO_SCOPE)
        try:
            response = resource.get(id=response['id']).execute()
            logger.info("Status of asset %s is '%s'." % (response['id'], response["processingStatus"]))

            if response["processingStatus"] == "complete":
                logger.info("Processing complete and took ~%s minutes" % (round((time.time() - start_time) / 60, 2)))
                return response
            elif response["processingStatus"] == "failed":
                logger.info("Processing failed and took ~%s minutes" % (round((time.time() - start_time) / 60, 2)))
                raise Exception("Asset failed to process in time.")
            else:
                if time.time() - start_time >= ASSET_PROCESSING_TIMEOUT:
                    raise Exception("\nGiving up waiting on '%s'" % (response['id']))
                else:
                    time.sleep(60)
        except HttpError, err:
             logger.error("HttpError %s err %s (sleeping 60 seconds)" % (HttpError, err))
             time.sleep(60)
keithmoss commented 10 years ago

My Hodor should work around this one now.