Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- import os, sys
- import socket
- from ftrack import \
- ensureLocation, Location, DiskAccessor
- rootConnectPath = os.path.dirname(
- os.path.dirname(
- os.path.dirname(
- os.path.abspath(__file__))))
- if not rootConnectPath in sys.path:
- sys.path.append(rootConnectPath)
- # Get Frostburn-specific structure
- from event.structure.frostburnProjectStructure import FrostburnProjectStructure
- logger = logging.getLogger(__name__)
- 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.getenv('FTRACK_LOCAL_LOCATION_DIR',
- os.path.join(
- os.path.expanduser('~'),
- 'ftrackLocalLocation')
- )
- # validate the machine's domain name
- machineName = socket.getfqdn()
- # add identifier for intranet machines
- if '.frostburnstudios.com'in machineName:
- machineName = 'lan.'+ machineName
- else:
- machineName = 'wan.' + machineName
- logger.debug('Local machine identifier resolved to: {0}'.format(machineName))
- # Create an identifier for this particular location
- userName = os.environ.get('USER')
- userName = userName.replace('.', '-')
- locationName = 'local.{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('Local Location plugin registered: {0}\n File path for Local Location: {1}'
- .format(os.path.abspath(__file__), locationDownloadsPath))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement