# Path: media_nommer/conf/settings.py
# AWS_ACCESS_KEY_ID = None
# AWS_SECRET_ACCESS_KEY = None
# CONFIG_S3_BUCKET = 'nommer_config'
# SQS_NEW_JOB_QUEUE_NAME = 'media_nommer'
# SQS_JOB_STATE_CHANGE_QUEUE_NAME = 'media_nommer_jstate'
# SIMPLEDB_JOB_STATE_DOMAIN = 'media_nommer'
# SIMPLEDB_EC2_NOMMER_STATE_DOMAIN = 'media_nommer_ec2nommer_state'
# EC2_KEY_NAME = None
# EC2_SECURITY_GROUPS = ['media_nommer']
# EC2_AMI_ID = 'ami-eb558182'
# EC2_INSTANCE_TYPE = 'm1.large'
# MAX_ENCODING_JOBS_PER_EC2_INSTANCE = 2
# MAX_NUM_EC2_INSTANCES = 3
# JOB_OVERFLOW_THRESH = 2
# FEEDERD_JOB_STATE_CHANGE_CHECK_INTERVAL = 60
# FEEDERD_PRUNE_JOBS_INTERVAL = 60 * 5
# FEEDERD_ALLOW_EC2_LAUNCHES = True
# FEEDERD_ABANDON_INACTIVE_JOBS_THRESH = 3600 * 9
# FEEDERD_AUTO_SCALE_INTERVAL = 60
# NOMMERD_TERMINATE_WHEN_IDLE = True
# NOMMERD_MAX_INACTIVITY = 60 * 10
# NOMMERD_HEARTBEAT_INTERVAL = 60
# NOMMERD_NEW_JOB_CHECK_INTERVAL = 60
# NOMMERD_QTFASTSTART_BIN_PATH = '/home/nom/.virtualenvs/media_nommer/bin/qtfaststart'
# STORAGE_BACKENDS = {
#     's3': 'media_nommer.core.storage_backends.s3.S3Backend',
#     'http': 'media_nommer.core.storage_backends.http.HTTPBackend',
#     'https': 'media_nommer.core.storage_backends.http.HTTPBackend',
#     'file': 'media_nommer.core.storage_backends.file.FileBackend',
# }
# 
# Path: media_nommer/utils/logger.py
# def debug(message):
# def info(message):
# def warning(message):
# def error(message_or_obj=None):
# 
# Path: media_nommer/utils/mod_importing.py
# def import_class_from_module_string(fqpn_str):
#     """
#     Given a FQPN for a class, import and return the class.
#     
#     :param str fqpn_str: The FQPN to the class to import.
#     :returns: The class given in the FQPN.
#     """
#     components = fqpn_str.split('.')
#     # Generate a FQPN with everything but the class name.
#     nom_module_str = '.'.join(components[:-1])
#     # Just the target module to import.
#     class_name = components[-1]
#     # Import the class's module and the class itself.
#     nommer = __import__(nom_module_str, globals(), locals(), [class_name])
# 
#     try:
#         return getattr(nommer, class_name)
#     except AttributeError:
#         raise ImportError('No class named %s' % class_name)


import random
import hashlib
import datetime
import json
import boto
from boto.sqs.message import Message
from media_nommer.conf import settings
from media_nommer.utils import logger
from media_nommer.utils.mod_importing import import_class_from_module_string
    __aws_sdb_connection = None
    __aws_sdb_job_state_domain = None
    __aws_sqs_connection = None
    __aws_sqs_new_job_queue = None
    __aws_sqs_state_change_queue = None

    @classmethod
    def _get_sdb_connection(cls):
        """
        Lazy - loading of the SimpleDB boto connection. Refer to this instead of
        referencing cls.__aws_sdb_connection directly.

        :returns: A boto connection to Amazon's SimpleDB interface.
        """
        if not cls.__aws_sdb_connection:
            cls.__aws_sdb_connection = boto.connect_sdb(
                settings.AWS_ACCESS_KEY_ID,
                settings.AWS_SECRET_ACCESS_KEY)
        return cls.__aws_sdb_connection

    @classmethod
    def _get_sdb_job_state_domain(cls):
        """
        Lazy-loading of the SimpleDB boto domain. Refer to this instead of
        referencing cls.__aws_sdb_job_state_domain directly.

        :returns: A boto SimpleDB domain for this workflow.
        """
        if not cls.__aws_sdb_job_state_domain:
            cls.__aws_sdb_job_state_domain = cls._get_sdb_connection().create_domain(

# Path: media_nommer/conf/settings.py
# AWS_ACCESS_KEY_ID = None
# AWS_SECRET_ACCESS_KEY = None
# CONFIG_S3_BUCKET = 'nommer_config'
# SQS_NEW_JOB_QUEUE_NAME = 'media_nommer'
# SQS_JOB_STATE_CHANGE_QUEUE_NAME = 'media_nommer_jstate'
# SIMPLEDB_JOB_STATE_DOMAIN = 'media_nommer'
# SIMPLEDB_EC2_NOMMER_STATE_DOMAIN = 'media_nommer_ec2nommer_state'
# EC2_KEY_NAME = None
# EC2_SECURITY_GROUPS = ['media_nommer']
# EC2_AMI_ID = 'ami-eb558182'
# EC2_INSTANCE_TYPE = 'm1.large'
# MAX_ENCODING_JOBS_PER_EC2_INSTANCE = 2
# MAX_NUM_EC2_INSTANCES = 3
# JOB_OVERFLOW_THRESH = 2
# FEEDERD_JOB_STATE_CHANGE_CHECK_INTERVAL = 60
# FEEDERD_PRUNE_JOBS_INTERVAL = 60 * 5
# FEEDERD_ALLOW_EC2_LAUNCHES = True
# FEEDERD_ABANDON_INACTIVE_JOBS_THRESH = 3600 * 9
# FEEDERD_AUTO_SCALE_INTERVAL = 60
# NOMMERD_TERMINATE_WHEN_IDLE = True
# NOMMERD_MAX_INACTIVITY = 60 * 10
# NOMMERD_HEARTBEAT_INTERVAL = 60
# NOMMERD_NEW_JOB_CHECK_INTERVAL = 60
# NOMMERD_QTFASTSTART_BIN_PATH = '/home/nom/.virtualenvs/media_nommer/bin/qtfaststart'
# STORAGE_BACKENDS = {
#     's3': 'media_nommer.core.storage_backends.s3.S3Backend',
#     'http': 'media_nommer.core.storage_backends.http.HTTPBackend',
#     'https': 'media_nommer.core.storage_backends.http.HTTPBackend',
#     'file': 'media_nommer.core.storage_backends.file.FileBackend',
# }
# 
# Path: media_nommer/utils/logger.py
# def debug(message):
# def info(message):
# def warning(message):
# def error(message_or_obj=None):
# 
# Path: media_nommer/utils/mod_importing.py
# def import_class_from_module_string(fqpn_str):
#     """
#     Given a FQPN for a class, import and return the class.
#     
#     :param str fqpn_str: The FQPN to the class to import.
#     :returns: The class given in the FQPN.
#     """
#     components = fqpn_str.split('.')
#     # Generate a FQPN with everything but the class name.
#     nom_module_str = '.'.join(components[:-1])
#     # Just the target module to import.
#     class_name = components[-1]
#     # Import the class's module and the class itself.
#     nommer = __import__(nom_module_str, globals(), locals(), [class_name])
# 
#     try:
#         return getattr(nommer, class_name)
#     except AttributeError:
#         raise ImportError('No class named %s' % class_name)


# Path: media_nommer/core/job_state_backend.py
import random
import hashlib
import datetime
import json
import boto
from boto.sqs.message import Message
from media_nommer.conf import settings
from media_nommer.utils import logger
from media_nommer.utils.mod_importing import import_class_from_module_string

    __aws_sdb_connection = None
    __aws_sdb_job_state_domain = None
    __aws_sqs_connection = None
    __aws_sqs_new_job_queue = None
    __aws_sqs_state_change_queue = None

    @classmethod
    def _get_sdb_connection(cls):
        """
        Lazy - loading of the SimpleDB boto connection. Refer to this instead of
        referencing cls.__aws_sdb_connection directly.

        :returns: A boto connection to Amazon's SimpleDB interface.
        """
        if not cls.__aws_sdb_connection:
            cls.__aws_sdb_connection = boto.connect_sdb(
                settings.AWS_ACCESS_KEY_ID,
                settings.AWS_SECRET_ACCESS_KEY)
        return cls.__aws_sdb_connection

    @classmethod
    def _get_sdb_job_state_domain(cls):
        """
        Lazy-loading of the SimpleDB boto domain. Refer to this instead of
        referencing cls.__aws_sdb_job_state_domain directly.

        :returns: A boto SimpleDB domain for this workflow.
        """
        if not cls.__aws_sdb_job_state_domain:
            cls.__aws_sdb_job_state_domain = cls._get_sdb_connection().create_domain(

                                        settings.SIMPLEDB_JOB_STATE_DOMAIN)