Esempio n. 1
0
def on_post_processing():
    # Create a lock so that the scheduler also doesn't try to run.
    nzb.lock_reset(SCRIPT_NAME)

    status = nzb.get_nzb_status()

    if status != 'FAILURE/HEALTH':
        nzb.log_detail('Nothing to do, status was %s.' % status)
        nzb.exit(nzb.PROCESS_SUCCESS)

    try:
        nzbid = nzb.get_nzb_id()
        nzbname = nzb.get_nzb_name()

        nzb.log_detail('Performing health check on %s (%s).' %
                       (nzbname, status))

        check_limit_age(nzbid, nzbname)
        check_limit_retries(nzbid, nzbname)

        # Stop all other post-processing because we need to requeue the file.
        nzb.log_warning('Pausing %s due to status of %s.' % (nzbname, status))
        proxy = nzb.proxy()

        # Pause the file group.
        if not proxy.editqueue('GroupPause', 0, '', [nzbid]):
            reason = 'Failed to pause %s (%s).' % (nzbname, nzbid)
            nzb.exit(nzb.PROCESS_FAIL_PROXY, reason)

        # Send the file back to the queue.
        if not proxy.editqueue('HistoryReturn', 0, '', [nzbid]):
            reason = 'Failed to requeue %s (%s).' % (nzbname, nzbid)
            nzb.exit(nzb.PROCESS_FAIL_PROXY, reason)
    except Exception as e:
        traceback.print_exc()
        nzb.exit(nzb.PROCESS_ERROR, e)
    finally:
        nzb.lock_release(SCRIPT_NAME)
        clean_up()
Esempio n. 2
0
def on_post_processing():
    # Create a lock so that the scheduler also doesn't try to run.
    nzb.lock_reset(SCRIPT_NAME)

    status = nzb.get_nzb_status()

    if status != "FAILURE/HEALTH":
        nzb.log_detail("Nothing to do, status was %s." % status)
        nzb.exit(nzb.PROCESS_SUCCESS)

    try:
        nzbid = nzb.get_nzb_id()
        nzbname = nzb.get_nzb_name()

        nzb.log_detail("Performing health check on %s (%s)." % (nzbname, status))

        check_limit_age(nzbid, nzbname)
        check_limit_retries(nzbid, nzbname)

        # Stop all other post-processing because we need to requeue the file.
        nzb.log_warning("Pausing %s due to status of %s." % (nzbname, status))
        proxy = nzb.proxy()

        # Pause the file group.
        if not proxy.editqueue("GroupPause", 0, "", [nzbid]):
            reason = "Failed to pause %s (%s)." % (nzbname, nzbid)
            nzb.exit(nzb.PROCESS_FAIL_PROXY, reason)

        # Send the file back to the queue.
        if not proxy.editqueue("HistoryReturn", 0, "", [nzbid]):
            reason = "Failed to requeue %s (%s)." % (nzbname, nzbid)
            nzb.exit(nzb.PROCESS_FAIL_PROXY, reason)
    except Exception as e:
        traceback.print_exc()
        nzb.exit(nzb.PROCESS_ERROR, e)
    finally:
        nzb.lock_release(SCRIPT_NAME)
        clean_up()
Esempio n. 3
0
def reject(reason):
    nzbid = nzb.get_nzb_id()
    nzbname = nzb.get_nzb_name()
    nzb.log_error('Rejecting %s. %s.' % (nzbname, reason))

    response = None

    if REJECT_ACTION == 'Pause':
        nzb.log_error('File %s was rejected, pausing download.' % nzbname)
        response = nzb.proxy().editqueue('GroupPause', 0, '', [nzbid])
    elif REJECT_ACTION == 'Bad':
        nzb.log_error('File %s was rejected, marking as bad.' % nzbname)
        nzb.set_nzb_bad()
        response = True
    elif REJECT_ACTION == 'Fail':
        nzb.log_error('File %s was rejected, marking as failed.' % nzbname)
        response = nzb.set_nzb_fail(nzbid)

    if not response:
        nzb.log_error('Failed to apply the reject action.')
        nzb.exit(nzb.PROCESS_ERROR)

    nzb.exit(nzb.PROCESS_ERROR)
Esempio n. 4
0
def reject(reason):
    nzbid = nzb.get_nzb_id()
    nzbname = nzb.get_nzb_name()
    nzb.log_error('Rejecting %s. %s.' % (nzbname, reason))

    response = None

    if REJECT_ACTION == 'Pause':
        nzb.log_error('File %s was rejected, pausing download.' % nzbname)
        response = nzb.proxy().editqueue('GroupPause', 0, '', [nzbid])
    elif REJECT_ACTION == 'Bad':
        nzb.log_error('File %s was rejected, marking as bad.' % nzbname)
        nzb.set_nzb_bad()
        response = True
    elif REJECT_ACTION == 'Fail':
        nzb.log_error('File %s was rejected, marking as failed.' % nzbname)
        response = nzb.set_nzb_fail(nzbid)

    if not response:
        nzb.log_error('Failed to apply the reject action.')
        nzb.exit(nzb.PROCESS_ERROR)

    nzb.exit(nzb.PROCESS_ERROR)