# Path: peekaboo/exceptions.py
# class PeekabooException(Exception):
#     """ General exception class for all custom exception classes of Peekaboo. """
#     pass


import datetime
import os
import logging
import threading
import requests
import schema
import urllib3.util.retry
from peekaboo.exceptions import PeekabooException
        """ Resubmit a sample to the job queue after the report became
        available. Retrieves the report from Cuckoo.

        @param job_id: ID of job which has finished.
        @type job_id: int

        @returns: None """
        logger.debug("Analysis done for task #%d", job_id)

        sample = self.deregister_running_job(job_id)
        if sample is None:
            logger.debug('No sample found for job ID %d', job_id)
            return None

        logger.debug('%d: Requesting Cuckoo report', sample.id)
        report_path = "tasks/report/%d" % job_id
        report = self.__get(report_path)
        if report is None:
            # mark analysis as failed if we could not get the report e.g.
            # because it was corrupted or the API connection failed.
            sample.mark_cuckoo_failure()
        else:
            try:
                reportobj = CuckooReport(report, self.request_url(report_path))
                sample.register_cuckoo_report(reportobj)
            except schema.SchemaError as err:
                logger.warning('Report returned from Cuckoo contained '
                               'invalid data: %s', err)
                sample.mark_cuckoo_failure()


# Path: peekaboo/exceptions.py
# class PeekabooException(Exception):
#     """ General exception class for all custom exception classes of Peekaboo. """
#     pass


# Path: peekaboo/toolbox/cuckoo.py
import datetime
import os
import logging
import threading
import requests
import schema
import urllib3.util.retry
from peekaboo.exceptions import PeekabooException

        """ Resubmit a sample to the job queue after the report became
        available. Retrieves the report from Cuckoo.

        @param job_id: ID of job which has finished.
        @type job_id: int

        @returns: None """
        logger.debug("Analysis done for task #%d", job_id)

        sample = self.deregister_running_job(job_id)
        if sample is None:
            logger.debug('No sample found for job ID %d', job_id)
            return None

        logger.debug('%d: Requesting Cuckoo report', sample.id)
        report_path = "tasks/report/%d" % job_id
        report = self.__get(report_path)
        if report is None:
            # mark analysis as failed if we could not get the report e.g.
            # because it was corrupted or the API connection failed.
            sample.mark_cuckoo_failure()
        else:
            try:
                reportobj = CuckooReport(report, self.request_url(report_path))
                sample.register_cuckoo_report(reportobj)
            except schema.SchemaError as err:
                logger.warning('Report returned from Cuckoo contained '
                               'invalid data: %s', err)
                sample.mark_cuckoo_failure()


        self.job_queue.submit(sample)