Example #1
0
    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        ftp = kwargs['ftp']
        engine._data[FTP_SERVER] = ftp['server']
        engine._data[FTP_USERNAME] = ftp['user']
        engine._data[FTP_PASSWORD] = ftp['password']
        engine._data[FTP_UPLOAD_DIR] = ftp['upload_dir']
        engine._data[FTP_MAX_INTEGRITY_RETRIES] = ftp[
            'upload_integrity_retries']
        engine._data[HTTP_DOWNLOAD_URI] = ftp['http_download_uri']
        engine._data[RTMP_SERVER_URI] = ftp['rtmp_server_uri']
Example #2
0
 def display(self, value, **kwargs):
     """Display the form with default values from the engine param."""
     engine = kwargs["engine"]
     specifics = value.setdefault("specifics", {})
     specifics.setdefault("path", engine._data.get("path", None))
     specifics.setdefault("rtmp_server_uri", engine._data.get("rtmp_server_uri", None))
     return StorageForm.display(self, value, **kwargs)
Example #3
0
 def display(self, value, **kwargs):
     """Display the form with default values from the engine param."""
     engine = kwargs['engine']
     player_data = engine._data.get('player_params', {})
     player = value.setdefault('player', {})
     player.setdefault('nocookie', engine._data.get('nocookie', False))
     for x in self.player_params:
         player.setdefault(x, player_data.get(x, False))
     return StorageForm.display(self, value, **kwargs)
Example #4
0
    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        specifics = kwargs['specifics']
        engine._data['path'] = specifics['path'] or None
        engine._data['rtmp_server_uri'] = specifics['rtmp_server_uri'] or None
Example #5
0
    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        rtmp = kwargs.get('rtmp', {})
        rtmp_servers = rtmp.get('known_servers', ())
        engine._data['rtmp_server_uris'] = [x for x in rtmp_servers if x]
Example #6
0
    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        player = kwargs['player']
        engine._data['nocookie'] = player['nocookie']
        player_params = engine._data['player_params']
        for x in self.player_params:
            player_params[x] = player[x]
Example #7
0
 def display(self, value, **kwargs):
     """Display the form with default values from the engine param."""
     engine = kwargs['engine']
     data = engine._data
     ftp = value.setdefault('ftp', {})
     ftp.setdefault('server', data.get(FTP_SERVER, None))
     ftp.setdefault('user', data.get(FTP_USERNAME, None))
     ftp.setdefault('password', data.get(FTP_PASSWORD, None))
     ftp.setdefault('upload_dir', data.get(FTP_UPLOAD_DIR, None))
     ftp.setdefault('upload_integrity_retries', data.get(FTP_MAX_INTEGRITY_RETRIES, None))
     ftp.setdefault('http_download_uri', data.get(HTTP_DOWNLOAD_URI, None))
     ftp.setdefault('rtmp_server_uri', data.get(RTMP_SERVER_URI, None))
     return StorageForm.display(self, value, **kwargs)
Example #8
0
 def display(self, value, **kwargs):
     """Display the form with default values from the engine param."""
     engine = kwargs['engine']
     data = engine._data
     defaults = {'aws': {
         'aws_access_key': data.get('aws_access_key', ''),
         'aws_secret_key': data.get('aws_secret_key', ''),
         's3_bucket_name': data.get('s3_bucket_name', ''),
         's3_bucket_dir': data.get('s3_bucket_dir', ''),
         'cf_download_domain': data.get('cf_download_domain', ''),
         'cf_streaming_domain': data.get('cf_streaming_domain', ''),
     }}
     value = merge_dicts({}, defaults, value)
     return StorageForm.display(self, value, **kwargs)
Example #9
0
    def save_engine_params(self, engine, panda, s3, cloudfront, profiles, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        # The panda client library expects strings.
        for key in panda:
            if panda[key] is None:
                panda[key] = u''

        StorageForm.save_engine_params(self, engine, **kwargs)
        engine._data[PANDA_CLOUD_ID] = panda['cloud_id']
        engine._data[PANDA_ACCESS_KEY] = panda['access_key']
        engine._data[PANDA_SECRET_KEY] = panda['secret_key']
        engine._data[PANDA_API_HOST] = panda['api_host']
        engine._data[PANDA_PROFILES] = profiles
        engine._data[S3_BUCKET_NAME] = s3['bucket_name']
        engine._data[CLOUDFRONT_STREAMING_URI] = cloudfront['streaming_uri']
        engine._data[CLOUDFRONT_DOWNLOAD_URI] = cloudfront['download_uri']

        engine.panda_helper.cache.clear()
        try:
            engine.panda_helper().client.get_cloud()
        except PandaException, e:
            DBSession.rollback()
            # TODO: Display this error to the user.
            raise Invalid(str(e), None, None)
Example #10
0
    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        aws = kwargs['aws']
        data = engine._data
        data['aws_access_key'] = aws['aws_access_key']
        data['aws_secret_key'] = aws['aws_secret_key']
        data['s3_bucket_name'] = aws['s3_bucket_name']
        data['s3_bucket_dir'] = aws['s3_bucket_dir']
        data['cf_download_domain'] = aws['cf_download_domain']
        data['cf_streaming_domain'] = aws['cf_streaming_domain']
Example #11
0
    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediacore.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        ftp = kwargs['ftp']
        engine._data[FTP_SERVER] = ftp['server']
        engine._data[FTP_USERNAME] = ftp['user']
        engine._data[FTP_PASSWORD] = ftp['password']
        engine._data[FTP_UPLOAD_DIR] = ftp['upload_dir']
        engine._data[FTP_MAX_INTEGRITY_RETRIES] = ftp['upload_integrity_retries']
        engine._data[HTTP_DOWNLOAD_URI] = ftp['http_download_uri']
        engine._data[RTMP_SERVER_URI] = ftp['rtmp_server_uri']
Example #12
0
    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediacore.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass

        """
        rtmp = value.setdefault('rtmp', {})
        rtmp.setdefault('known_servers', engine._data.get('rtmp_server_uris', ()))
        return StorageForm.display(self, value, engine, **kwargs)
Example #13
0
    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediacore.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass

        """
        specifics = value.setdefault('specifics', {})
        specifics.setdefault('path', engine._data.get('path', None))
        specifics.setdefault('rtmp_server_uri', engine._data.get('rtmp_server_uri', None))
        return StorageForm.display(self, value, engine, **kwargs)
Example #14
0
    def display(self, value, engine, **kwargs):
        try:
            profiles = engine.panda_helper().client.get_profiles()
            cloud = engine.panda_helper().client.get_cloud()
        except PandaException:
            profiles = None
            cloud = None

        if not value:
            value = {}

        merged_value = {}
        merge_dicts(merged_value, {
            'panda': {
                'cloud_id': engine._data[PANDA_CLOUD_ID],
                'access_key': engine._data[PANDA_ACCESS_KEY],
                'secret_key': engine._data[PANDA_SECRET_KEY],
                'api_host': engine._data.get(PANDA_API_HOST),
            },
            's3': {
                'bucket_name': engine._data[S3_BUCKET_NAME],
            },
            'cloudfront': {
                'streaming_uri': engine._data[CLOUDFRONT_STREAMING_URI],
                'download_uri': engine._data[CLOUDFRONT_DOWNLOAD_URI],
            },
            'profiles': engine._data[PANDA_PROFILES],
        }, value)

        merged_kwargs = {}
        merge_dicts(merged_kwargs, {
            'cloud': cloud,
            'child_args': {
                'profiles': {'profiles': profiles},
            },
        }, kwargs)

        # kwargs are vars for the template, value is a dict of values for the form.
        return StorageForm.display(self, merged_value, engine, **merged_kwargs)
Example #15
0
    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediacore.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass

        """
        data = engine._data
        ftp = value.setdefault('ftp', {})
        ftp.setdefault('server', data.get(FTP_SERVER, None))
        ftp.setdefault('user', data.get(FTP_USERNAME, None))
        ftp.setdefault('password', data.get(FTP_PASSWORD, None))
        ftp.setdefault('upload_dir', data.get(FTP_UPLOAD_DIR, None))
        ftp.setdefault('upload_integrity_retries', data.get(FTP_MAX_INTEGRITY_RETRIES, None))
        ftp.setdefault('http_download_uri', data.get(HTTP_DOWNLOAD_URI, None))
        ftp.setdefault('rtmp_server_uri', data.get(RTMP_SERVER_URI, None))
        return StorageForm.display(self, value, engine, **kwargs)
Example #16
0
    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediacore.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediacore.lib.storage.StorageEngine` subclass

        """
        data = engine._data
        ftp = value.setdefault('ftp', {})
        ftp.setdefault('server', data.get(FTP_SERVER, None))
        ftp.setdefault('user', data.get(FTP_USERNAME, None))
        ftp.setdefault('password', data.get(FTP_PASSWORD, None))
        ftp.setdefault('upload_dir', data.get(FTP_UPLOAD_DIR, None))
        ftp.setdefault('upload_integrity_retries',
                       data.get(FTP_MAX_INTEGRITY_RETRIES, None))
        ftp.setdefault('http_download_uri', data.get(HTTP_DOWNLOAD_URI, None))
        ftp.setdefault('rtmp_server_uri', data.get(RTMP_SERVER_URI, None))
        return StorageForm.display(self, value, engine, **kwargs)
Example #17
0
 def display(self, value, **kwargs):
     """Display the form with default values from the engine param."""
     engine = kwargs['engine']
     rtmp = value.setdefault('rtmp', {})
     rtmp.setdefault('known_servers', engine._data.get('rtmp_server_uris', ()))
     return StorageForm.display(self, value, **kwargs)