def __init__(self, source_path, dest_path, nommer, job_options, unique_id=None, job_state='PENDING', job_state_details=None, notify_url=None, creation_dtime=None, last_modified_dtime=None): """ :param str source_path: The URI to the source media to encode. :param str dest_path: The URI to upload the encoded media to. :param dict job_options: The job options to pass to the Nommer in key/value format. See each Nommer's documentation for details on accepted options. :keyword str unique_id: The unique hash ID for this job. If :py:meth:`save` is called and this value is ``None``, an ID will be generated for this job. :keyword str job_state: The state that the job is in. :keyword str job_state_details: Any details to go along with whatever job state this job is in. For example, if job_state is `ERROR`, this keyword might contain an error message. :keyword str notify_url: The URL to hit when this job has finished. :keyword datetime.datetime creation_dtime: The time when this job was created. :keyword datetime.datetime last_modified_dtime: The time when this job was last modified. """ self.source_path = source_path self.dest_path = dest_path # __import__ doesn't like unicode, cast this to a str. self.nommer = import_class_from_module_string(str(nommer))(self) self.job_options = job_options self.unique_id = unique_id self.job_state = job_state self.job_state_details = job_state_details self.notify_url = notify_url self.creation_dtime = creation_dtime if not self.creation_dtime: self.creation_dtime = datetime.datetime.now() self.last_modified_dtime = last_modified_dtime if not self.last_modified_dtime: self.last_modified_dtime = datetime.datetime.now() if isinstance(self.job_options, basestring): # If job_options is a string, it is JSON. De-code it and make it # a Python dict. self.job_options = json.loads(self.job_options) self.job_state = job_state # SimpleDB doesn't store datetime objects. We need to do some # massaging to make this work. self.creation_dtime = self._get_dtime_from_string(self.creation_dtime) self.last_modified_dtime = self._get_dtime_from_string( self.last_modified_dtime)
def get_backend_for_protocol(protocol): """ Given a protocol string, return the storage backend that has been tasked with serving said protocol. :param str protocol: A protocol string like 'http', 'ftp', or 's3'. :returns: A storage backend for the specified protocol. """ backend_class_fqpn = settings.STORAGE_BACKENDS[protocol] return import_class_from_module_string(backend_class_fqpn)
def get_backend_for_protocol(protocol): """ Given a protocol string, return the storage backend that has been tasked with serving said protocol. :param str protocol: A protocol string like 'http', 'ftp', or 's3'. :returns: A storage backend for the specified protocol. """ backend_class_fqpn = settings.STORAGE_BACKENDS[protocol] return import_class_from_module_string(backend_class_fqpn)
def __init__(self, source_path, dest_path, nommer, job_options, unique_id=None, job_state='PENDING', job_state_details=None, notify_url=None, creation_dtime=None, last_modified_dtime=None): """ :param str source_path: The URI to the source media to encode. :param str dest_path: The URI to upload the encoded media to. :param dict job_options: The job options to pass to the Nommer in key/value format. See each Nommer's documentation for details on accepted options. :keyword str unique_id: The unique hash ID for this job. If :py:meth:`save` is called and this value is ``None``, an ID will be generated for this job. :keyword str job_state: The state that the job is in. :keyword str job_state_details: Any details to go along with whatever job state this job is in. For example, if job_state is `ERROR`, this keyword might contain an error message. :keyword str notify_url: The URL to hit when this job has finished. :keyword datetime.datetime creation_dtime: The time when this job was created. :keyword datetime.datetime last_modified_dtime: The time when this job was last modified. """ self.source_path = source_path self.dest_path = dest_path # __import__ doesn't like unicode, cast this to a str. self.nommer = import_class_from_module_string(str(nommer))(self) self.job_options = job_options self.unique_id = unique_id self.job_state = job_state self.job_state_details = job_state_details self.notify_url = notify_url self.creation_dtime = creation_dtime if not self.creation_dtime: self.creation_dtime = datetime.datetime.now() self.last_modified_dtime = last_modified_dtime if not self.last_modified_dtime: self.last_modified_dtime = datetime.datetime.now() if isinstance(self.job_options, basestring): # If job_options is a string, it is JSON. De-code it and make it # a Python dict. self.job_options = json.loads(self.job_options) self.job_state = job_state # SimpleDB doesn't store datetime objects. We need to do some # massaging to make this work. self.creation_dtime = self._get_dtime_from_string(self.creation_dtime) self.last_modified_dtime = self._get_dtime_from_string(self.last_modified_dtime)
def test_valid_import(self): """ Test an import that should be valid. """ import_class_from_module_string( 'media_nommer.client.api.APIConnection')
def test_valid_import(self): """ Test an import that should be valid. """ import_class_from_module_string('media_nommer.client.api.APIConnection')