Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- import sys
- import os
- import socket
- from ftrack import \
- ensureLocation, Location, DiskAccessor
- logger = logging.getLogger(__name__)
- # Get Frostburn-specific structure
- try:
- from stkToolkit_3dsmax.ftrackPlugin.event.structure.frostburnProjectStructure \
- import FrostburnProjectStructure
- except ImportError:
- logger.warning('# Unable to perform absolute import, continuing...')
- structurePath = os.path.join(
- os.path.dirname(
- os.path.dirname(
- os.path.abspath(__file__))), 'structure')
- sys.path.append(structurePath)
- # noinspection PyUnresolvedReferences
- from frostburnProjectStructure import FrostburnProjectStructure
- def register(registry, **kw):
- """
- This method registers the Location in the ftrack database.
- It is automatically called when this module is found in the
- ``FTRACK_LOCATION_PLUGIN_PATH``.
- :param registry:
- :param kw:
- :return:
- """
- # Check if location environment variable has been set,
- # if not, download to temporary directory
- locationDownloadsPath = os.environ.get('FTRACK_LOCAL_LOCATION_DIR',
- 'C:\\ftrackDownloads\\')
- # Create an identifier for this particular location
- # validate the machine's domain name
- machineName = socket.getfqdn()
- if '.frostburnstudios.com'in machineName:
- userName = os.environ.get('USER')
- userName = userName.replace('.', '-')
- """Register custom location."""
- locationName = 'local.location.{0}.{1}'.format(userName, machineName)
- # Ensure location is registered in the database.
- ensureLocation(locationName)
- # Create the new location plugin.
- location = Location(
- locationName,
- # Use Frostburn Studios-specific project structure
- structure=FrostburnProjectStructure(),
- # The location will be a local disk.
- accessor=DiskAccessor(prefix=locationDownloadsPath),
- # Set priority to below S3 Location
- priority=10
- )
- # Register the location plugin.
- registry.add(location)
- logger.debug('Location plugin registered: {0}'.format(os.path.abspath(__file__)))
- else:
- logger.warning('# Did not register local Location plugin since machine name is invalid!')
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement