# Path: mfr/server/settings.py
# STATIC_PATH = config.get('STATIC_PATH', os.path.join(os.path.dirname(__file__), 'static'))
# ADDRESS = config.get('ADDRESS', 'localhost')
# PORT = config.get('PORT', 7778)
# DEBUG = config.get_bool('DEBUG', False)
# SSL_CERT_FILE = config.get_nullable('SSL_CERT_FILE', None)
# SSL_KEY_FILE = config.get_nullable('SSL_KEY_FILE', None)
# XHEADERS = config.get_bool('XHEADERS', False)
# CORS_ALLOW_ORIGIN = config.get('CORS_ALLOW_ORIGIN', '*')
# CHUNK_SIZE = int(config.get('CHUNK_SIZE', 65536))  # 64KB
# MAX_BUFFER_SIZE = int(config.get('MAX_BUFFER_SIZE', 1024 * 1024 * 100))  # 100MB
# PROVIDER_NAME = config.get('PROVIDER_NAME', 'osf')
# CACHE_ENABLED = config.get_bool('CACHE_ENABLED', False)
# CACHE_PROVIDER_NAME = config.get('CACHE_PROVIDER_NAME', 'filesystem')
# CACHE_PROVIDER_SETTINGS = config.get_object('CACHE_PROVIDER_SETTINGS', {'folder': '/tmp/mfr/'})
# CACHE_PROVIDER_CREDENTIALS = config.get_object('CACHE_PROVIDER_CREDENTIALS', {})
# LOCAL_CACHE_PROVIDER_SETTINGS = config.get_object('LOCAL_CACHE_PROVIDER_SETTINGS', {'folder': '/tmp/mfrlocalcache/'})
# ALLOWED_PROVIDER_DOMAINS = config.get('ALLOWED_PROVIDER_DOMAINS', 'http://localhost:5000/ http://localhost:7777/').split(' ')
# ALLOWED_PROVIDER_NETLOCS = []
# KEEN_API_BASE_URL = keen_config.get('API_BASE_URL', 'https://api.keen.io')
# KEEN_API_VERSION = keen_config.get('API_VERSION', '3.0')
# KEEN_ENABLE_LOGGING = keen_config.get_bool('ENABLE_LOGGING', True)
# KEEN_PRIVATE_PROJECT_ID = keen_private_config.get_nullable('PROJECT_ID', None)
# KEEN_PRIVATE_WRITE_KEY = keen_private_config.get_nullable('WRITE_KEY', None)
# KEEN_PRIVATE_LOG_VIEWS = keen_private_config.get_bool('LOG_VIEWS', True)
# KEEN_PRIVATE_LOG_ERRORS = keen_private_config.get_bool('LOG_ERRORS', True)
# KEEN_PUBLIC_PROJECT_ID = keen_public_config.get_nullable('PROJECT_ID', None)
# KEEN_PUBLIC_WRITE_KEY = keen_public_config.get_nullable('WRITE_KEY', None)
# KEEN_PUBLIC_LOG_VIEWS = keen_public_config.get_bool('LOG_VIEWS', True)


import asyncio
import logging
import os
import waterbutler.core.streams
from waterbutler.core.exceptions import InvalidParameters, DownloadError
from mfr.core import utils
from mfr.server import settings
from mfr.server.handlers import core
        else:
            cache_file_path_str = '/export/{}'.format(self.cache_file_id)
        self.cache_file_path = await self.cache_provider.validate_path(cache_file_path_str)

        self.source_file_path = await self.local_cache_provider.validate_path(
            '/export/{}'.format(self.source_file_id)
        )

        self.output_file_id = '{}.{}'.format(self.source_file_path.name, self.format)
        self.output_file_path = await self.local_cache_provider.validate_path(
            '/export/{}'.format(self.output_file_id)
        )
        self.metrics.merge({
            'output_file': {
                'id': self.output_file_id,
                'path': str(self.output_file_path),
                'provider': self.local_cache_provider.NAME,
            }
        })

    async def get(self):
        """Export a file to the format specified via the associated extension library"""

        # File is already in the requested format
        if self.metadata.ext.lower() == ".{}".format(self.format.lower()):
            await self.write_stream(await self.provider.download())
            logger.info('Exported {} with no conversion.'.format(self.format))
            self.metrics.add('export.conversion', 'noop')
            return


# Path: mfr/server/settings.py
# STATIC_PATH = config.get('STATIC_PATH', os.path.join(os.path.dirname(__file__), 'static'))
# ADDRESS = config.get('ADDRESS', 'localhost')
# PORT = config.get('PORT', 7778)
# DEBUG = config.get_bool('DEBUG', False)
# SSL_CERT_FILE = config.get_nullable('SSL_CERT_FILE', None)
# SSL_KEY_FILE = config.get_nullable('SSL_KEY_FILE', None)
# XHEADERS = config.get_bool('XHEADERS', False)
# CORS_ALLOW_ORIGIN = config.get('CORS_ALLOW_ORIGIN', '*')
# CHUNK_SIZE = int(config.get('CHUNK_SIZE', 65536))  # 64KB
# MAX_BUFFER_SIZE = int(config.get('MAX_BUFFER_SIZE', 1024 * 1024 * 100))  # 100MB
# PROVIDER_NAME = config.get('PROVIDER_NAME', 'osf')
# CACHE_ENABLED = config.get_bool('CACHE_ENABLED', False)
# CACHE_PROVIDER_NAME = config.get('CACHE_PROVIDER_NAME', 'filesystem')
# CACHE_PROVIDER_SETTINGS = config.get_object('CACHE_PROVIDER_SETTINGS', {'folder': '/tmp/mfr/'})
# CACHE_PROVIDER_CREDENTIALS = config.get_object('CACHE_PROVIDER_CREDENTIALS', {})
# LOCAL_CACHE_PROVIDER_SETTINGS = config.get_object('LOCAL_CACHE_PROVIDER_SETTINGS', {'folder': '/tmp/mfrlocalcache/'})
# ALLOWED_PROVIDER_DOMAINS = config.get('ALLOWED_PROVIDER_DOMAINS', 'http://localhost:5000/ http://localhost:7777/').split(' ')
# ALLOWED_PROVIDER_NETLOCS = []
# KEEN_API_BASE_URL = keen_config.get('API_BASE_URL', 'https://api.keen.io')
# KEEN_API_VERSION = keen_config.get('API_VERSION', '3.0')
# KEEN_ENABLE_LOGGING = keen_config.get_bool('ENABLE_LOGGING', True)
# KEEN_PRIVATE_PROJECT_ID = keen_private_config.get_nullable('PROJECT_ID', None)
# KEEN_PRIVATE_WRITE_KEY = keen_private_config.get_nullable('WRITE_KEY', None)
# KEEN_PRIVATE_LOG_VIEWS = keen_private_config.get_bool('LOG_VIEWS', True)
# KEEN_PRIVATE_LOG_ERRORS = keen_private_config.get_bool('LOG_ERRORS', True)
# KEEN_PUBLIC_PROJECT_ID = keen_public_config.get_nullable('PROJECT_ID', None)
# KEEN_PUBLIC_WRITE_KEY = keen_public_config.get_nullable('WRITE_KEY', None)
# KEEN_PUBLIC_LOG_VIEWS = keen_public_config.get_bool('LOG_VIEWS', True)


# Path: mfr/server/handlers/export.py
import asyncio
import logging
import os
import waterbutler.core.streams
from waterbutler.core.exceptions import InvalidParameters, DownloadError
from mfr.core import utils
from mfr.server import settings
from mfr.server.handlers import core

        else:
            cache_file_path_str = '/export/{}'.format(self.cache_file_id)
        self.cache_file_path = await self.cache_provider.validate_path(cache_file_path_str)

        self.source_file_path = await self.local_cache_provider.validate_path(
            '/export/{}'.format(self.source_file_id)
        )

        self.output_file_id = '{}.{}'.format(self.source_file_path.name, self.format)
        self.output_file_path = await self.local_cache_provider.validate_path(
            '/export/{}'.format(self.output_file_id)
        )
        self.metrics.merge({
            'output_file': {
                'id': self.output_file_id,
                'path': str(self.output_file_path),
                'provider': self.local_cache_provider.NAME,
            }
        })

    async def get(self):
        """Export a file to the format specified via the associated extension library"""

        # File is already in the requested format
        if self.metadata.ext.lower() == ".{}".format(self.format.lower()):
            await self.write_stream(await self.provider.download())
            logger.info('Exported {} with no conversion.'.format(self.format))
            self.metrics.add('export.conversion', 'noop')
            return


        if settings.CACHE_ENABLED: