Esempio n. 1
0
    def run(self, name, cache_key,
            local_path, remote_path,
            local_options, remote_options, **kwargs):
        """
        The main work horse of the transfer task. Calls the transfer
        method with the local and remote storage backends as given
        with the parameters.

        :param name: name of the file to transfer
        :type name: str
        :param local_path: local storage class to transfer from
        :type local_path: dotted import path
        :param local_options: options of the local storage class
        :type local_options: dict
        :param remote_path: remote storage class to transfer to
        :type remote_path: dotted import path
        :param remote_options: options of the remote storage class
        :type remote_options: dict
        :param cache_key: cache key to set after a successful transfer
        :type cache_key: str
        :rtype: task result
        """
        local = import_attribute(local_path)(**local_options)
        remote = import_attribute(remote_path)(**remote_options)
        result = self.transfer(name, local, remote, **kwargs)

        if result is True:
            cache.set(cache_key, True)
        elif result is False:
            self.retry(name, cache_key, local_path, remote_path,
                       local_options, remote_options, **kwargs)
        else:
            raise ValueError("Task '%s' did not return True/False but %s" %
                             (self.__class__, result))
        return result
Esempio n. 2
0
    def run(self, name, cache_key, local_path, remote_path, local_options,
            remote_options, **kwargs):
        """
        The main work horse of the transfer task. Calls the transfer
        method with the local and remote storage backends as given
        with the parameters.

        :param name: name of the file to transfer
        :type name: str
        :param local_path: local storage class to transfer from
        :type local_path: dotted import path
        :param local_options: options of the local storage class
        :type local_options: dict
        :param remote_path: remote storage class to transfer to
        :type remote_path: dotted import path
        :param remote_options: options of the remote storage class
        :type remote_options: dict
        :param cache_key: cache key to set after a successful transfer
        :type cache_key: str
        :rtype: task result
        """
        local = import_attribute(local_path)(**local_options)
        remote = import_attribute(remote_path)(**remote_options)
        result = self.transfer(name, local, remote, **kwargs)

        if result is True:
            cache.set(cache_key, True)
        elif result is False:
            self.retry(name, cache_key, local_path, remote_path, local_options,
                       remote_options, **kwargs)
        else:
            raise ValueError("Task '%s' did not return True/False but %s" %
                             (self.__class__, result))
        return result
Esempio n. 3
0
    def __init__(self, local=None, readonly=False, cache_prefix=None,
                 cache_timeout=300):

        self.local = local
        self.readonly = readonly
        self.cache_prefix = cache_prefix
        self.cache_timeout = cache_timeout

        if not self.cache_prefix:
            self.cache_prefix = 'OpenSurfacesStorage'

        if not self.local:
            self.local = import_attribute(settings.OPENSURFACES_LOCAL_STORAGE)()

        self.remote = ReadOnlyHttpStorage(prefix=settings.OPENSURFACES_REMOTE_STORAGE_URL)
Esempio n. 4
0
    def __init__(self,
                 local=None,
                 readonly=False,
                 cache_prefix=None,
                 cache_timeout=300):

        self.local = local
        self.readonly = readonly
        self.cache_prefix = cache_prefix
        self.cache_timeout = cache_timeout

        if not self.cache_prefix:
            self.cache_prefix = 'OpenSurfacesStorage'

        if not self.local:
            self.local = import_attribute(
                settings.OPENSURFACES_LOCAL_STORAGE)()

        self.remote = ReadOnlyHttpStorage(
            prefix=settings.OPENSURFACES_REMOTE_STORAGE_URL)
Esempio n. 5
0
def test_task(name, cache_key,
              local_path, remote_path,
              local_options, remote_options):
    local = import_attribute(local_path)(**local_options)
    remote = import_attribute(remote_path)(**remote_options)
    remote.save(name, local.open(name))
Esempio n. 6
0
 def __init__(self, import_path, options):
     backend = import_attribute(import_path)
     super(LazyBackend, self).__init__(lambda: backend(**options))
Esempio n. 7
0
 def __init__(self, import_path, options):
     backend = import_attribute(import_path)
     super(LazyBackend, self).__init__(lambda: backend(**options))
Esempio n. 8
0
def get_opensurfaces_storage():
    return import_attribute(settings.OPENSURFACES_FILE_STORAGE)()
Esempio n. 9
0
 def __init__(self, import_path):
     cls = import_attribute(import_path)
     super(LazyBackend, self).__init__(lambda: cls())
Esempio n. 10
0
def test_task(name, cache_key, local_path, remote_path, local_options,
              remote_options):
    local = import_attribute(local_path)(**local_options)
    remote = import_attribute(remote_path)(**remote_options)
    remote.save(name, local.open(name))