# Path: media_nommer/utils/http.py
# class StringProducer(object):
#     """
#     This is useful for twisted.web.client.Agent, which must use a producer
#     to spoon feed the request over a period of time, instead of one big chunk.
# 
#     Check the Twisted documentation for an example of how this fits together::
# 
#         http://twistedmatrix.com/documents/current/web/howto/client.html
#     """
#     implements(IBodyProducer)
# 
#     def __init__(self, body):
#         """
#         :param str body: The body to be sent to the remote server.
#         """
#         self.body = body
#         self.length = len(body)
# 
#     def startProducing(self, consumer):
#         consumer.write(self.body)
#         return succeed(None)
# 
#     def pauseProducing(self):
#         pass
# 
#     def stopProducing(self):
#         pass
# 
# Path: media_nommer/utils/logger.py
# def debug(message):
# def info(message):
# def warning(message):
# def error(message_or_obj=None):


import urllib
from twisted.internet import reactor
from twisted.web.client import Agent
from twisted.web.http_headers import Headers
from media_nommer.utils.http import StringProducer
from media_nommer.utils import logger
"""
This module contains code that handles notifying external services of state
changes in EncodingJobs. For example, when the state changes from
PENDING to DOWNLOADING, or ENCODING to FINISHED.
"""


def cb_response_received(response, unique_id, req_url):
    """
    This is a callback function that is hit when a response comes back from
    the remote server given in EncodingJob.notify_url. We'll just log it here
    for troubleshooting purposes.

    :param str unique_id: The job's unique ID.
    :param str req_url: The URL that we notified.
    """
    # Shouldn't ever happen in this case, but...
    http_code = getattr(response, 'code', 'N/A')


# Path: media_nommer/utils/http.py
# class StringProducer(object):
#     """
#     This is useful for twisted.web.client.Agent, which must use a producer
#     to spoon feed the request over a period of time, instead of one big chunk.
# 
#     Check the Twisted documentation for an example of how this fits together::
# 
#         http://twistedmatrix.com/documents/current/web/howto/client.html
#     """
#     implements(IBodyProducer)
# 
#     def __init__(self, body):
#         """
#         :param str body: The body to be sent to the remote server.
#         """
#         self.body = body
#         self.length = len(body)
# 
#     def startProducing(self, consumer):
#         consumer.write(self.body)
#         return succeed(None)
# 
#     def pauseProducing(self):
#         pass
# 
#     def stopProducing(self):
#         pass
# 
# Path: media_nommer/utils/logger.py
# def debug(message):
# def info(message):
# def warning(message):
# def error(message_or_obj=None):


# Path: media_nommer/feederd/job_state_notifier.py
import urllib
from twisted.internet import reactor
from twisted.web.client import Agent
from twisted.web.http_headers import Headers
from media_nommer.utils.http import StringProducer
from media_nommer.utils import logger

"""
This module contains code that handles notifying external services of state
changes in EncodingJobs. For example, when the state changes from
PENDING to DOWNLOADING, or ENCODING to FINISHED.
"""


def cb_response_received(response, unique_id, req_url):
    """
    This is a callback function that is hit when a response comes back from
    the remote server given in EncodingJob.notify_url. We'll just log it here
    for troubleshooting purposes.

    :param str unique_id: The job's unique ID.
    :param str req_url: The URL that we notified.
    """
    # Shouldn't ever happen in this case, but...
    http_code = getattr(response, 'code', 'N/A')


    logger.info(