Ejemplo n.º 1
0
    def get_status(job_id):
        access_token = GetAccessToken()
        if access_token:
            res = GetJobs(access_token)
            if res["success"]:
                for job in res["jobs"]:
                    if job["id"] == job_id:
                        return FaxStatus.from_string(job["status"])

        return None
Ejemplo n.º 2
0
    def get_status(job_id):
        access_token = GetAccessToken()
        if access_token:
            res = GetJobs(access_token)
            if res["success"]:
                for job in res["jobs"]:
                    if job["id"] == job_id:
                        return FaxStatus.from_string(job["status"])

        return None
Ejemplo n.º 3
0
def check_print_job_status(job_id,
                           title,
                           ride_id,
                           html,
                           counter=1,
                           backend=None):
    try:
        status = get_status(job_id, backend=backend)

        logging.info("check_print_job_status(%s): '%s'" %
                     (job_id, FaxStatus.get_name(status)))

        if status != FaxStatus.DONE:
            if counter > PRINT_COMPLETE_TIMEOUT:
                logging.info("print failure: title=%s" % title)
                ride = SharedRide.by_id(ride_id)
                if ride.station.fax_number:
                    email_devs(
                        u"Ride voucher did not print after %d minutes: %s. (sending fax)"
                        % (PRINT_COMPLETE_TIMEOUT, title))
                    fax_voucher(ride.station.fax_number, html, title, ride_id)
                else:
                    send_ride_in_risk_notification(
                        u"Ride voucher did not print after %d minutes: %s.\nNo fax number defined!."
                        % (PRINT_COMPLETE_TIMEOUT, title), ride_id)
            else:
                logging.info("print still not done: counter=%s, title=%s" %
                             (counter, title))
                deferred.defer(check_print_job_status,
                               job_id,
                               title,
                               ride_id,
                               html,
                               counter=counter + 1,
                               backend=backend,
                               _countdown=60)
    except Exception, e:
        trace = traceback.format_exc()
        logging.error("check_print_job_status failed with exception: %s" %
                      trace)
        deferred.defer(check_print_job_status,
                       job_id,
                       title,
                       ride_id,
                       html,
                       counter=counter + 1,
                       backend=backend,
                       _countdown=60)
Ejemplo n.º 4
0
def check_fax_job_status(fax_id, title, ride_id, html, counter=1, backend=None):
    try:
        status = get_status(fax_id, backend=backend)

        logging.info("check_fax_job_status(%s): '%s'" % (fax_id, FaxStatus.get_name(status)))

        if status != FaxStatus.DONE:
            if counter > FAX_ARRIVE_TIMEOUT:
                logging.info("fax failure: title=%s" % title)
                send_ride_in_risk_notification(u"Ride voucher fax did not arrive after %d minutes: %s." % (FAX_ARRIVE_TIMEOUT, title), ride_id)
            else:
                logging.info("fax still not done: counter=%s, title=%s" % (counter, title))
                deferred.defer(check_fax_job_status, fax_id, title, ride_id, html, counter=counter + 1, backend=backend,
                               _countdown=60)
    except Exception, e:
        trace = traceback.format_exc()
        logging.error("check_fax_job_status failed with exception: %s" % trace)
        deferred.defer(check_fax_job_status, fax_id, title, ride_id, html, counter=counter + 1, backend=backend, _countdown=60)
Ejemplo n.º 5
0
def check_fax_job_status(fax_id,
                         title,
                         ride_id,
                         html,
                         counter=1,
                         backend=None):
    try:
        status = get_status(fax_id, backend=backend)

        logging.info("check_fax_job_status(%s): '%s'" %
                     (fax_id, FaxStatus.get_name(status)))

        if status != FaxStatus.DONE:
            if counter > FAX_ARRIVE_TIMEOUT:
                logging.info("fax failure: title=%s" % title)
                send_ride_in_risk_notification(
                    u"Ride voucher fax did not arrive after %d minutes: %s." %
                    (FAX_ARRIVE_TIMEOUT, title), ride_id)
            else:
                logging.info("fax still not done: counter=%s, title=%s" %
                             (counter, title))
                deferred.defer(check_fax_job_status,
                               fax_id,
                               title,
                               ride_id,
                               html,
                               counter=counter + 1,
                               backend=backend,
                               _countdown=60)
    except Exception, e:
        trace = traceback.format_exc()
        logging.error("check_fax_job_status failed with exception: %s" % trace)
        deferred.defer(check_fax_job_status,
                       fax_id,
                       title,
                       ride_id,
                       html,
                       counter=counter + 1,
                       backend=backend,
                       _countdown=60)
Ejemplo n.º 6
0
def check_print_job_status(job_id, title, ride_id, html, counter=1, backend=None):
    try:
        status = get_status(job_id, backend=backend)

        logging.info("check_print_job_status(%s): '%s'" % (job_id, FaxStatus.get_name(status)))

        if status != FaxStatus.DONE:
            if counter > PRINT_COMPLETE_TIMEOUT:
                logging.info("print failure: title=%s" % title)
                ride = SharedRide.by_id(ride_id)
                if ride.station.fax_number:
                    email_devs(u"Ride voucher did not print after %d minutes: %s. (sending fax)" % (PRINT_COMPLETE_TIMEOUT, title))
                    fax_voucher(ride.station.fax_number, html, title, ride_id)
                else:
                    send_ride_in_risk_notification(u"Ride voucher did not print after %d minutes: %s.\nNo fax number defined!." % (PRINT_COMPLETE_TIMEOUT, title), ride_id)
            else:
                logging.info("print still not done: counter=%s, title=%s" % (counter, title))
                deferred.defer(check_print_job_status, job_id, title, ride_id, html, counter=counter + 1, backend=backend,
                               _countdown=60)
    except Exception, e:
        trace = traceback.format_exc()
        logging.error("check_print_job_status failed with exception: %s" % trace)
        deferred.defer(check_print_job_status, job_id, title, ride_id, html, counter=counter + 1, backend=backend, _countdown=60)