示例#1
0
    def __init__(self, location=None, base_url=None):
        """
            Initialize a Git repository or open an existing one.

            @param location: path where to create and open the repository
        """
        if not location:
            location = getattr(settings, 'GIT_STORAGE_ROOT', "")
            if not location:
                raise ImproperlyConfigured("GIT_STORAGE_ROOT is required")
        self.base_location = location
        self.location = abspathu(self.base_location)
        if base_url is None:
            try:
                base_url = settings.GIT_STORAGE_URL
            except AttributeError:
                base_url = None
        self.base_url = base_url

        # Create the repository as necessary
        if not os.path.exists(location):
            self._create()

        # Open the repository with our class
        self.repository = wrappers.Repository(self.location)
        assert self.repository.is_bare

        # Author of the following commits
        self.author_signature = self.repository.default_signature
示例#2
0
 def test_override_static_root(self):
     """
     Overriding the STATIC_ROOT setting should be reflected in the
     location attribute of
     django.contrib.staticfiles.storage.staticfiles_storage.
     """
     with self.settings(STATIC_ROOT='/tmp/test'):
         self.assertEqual(staticfiles_storage.location, abspathu('/tmp/test'))
示例#3
0
 def __init__(self, location=None, base_url=None):
     if location is None:
         location = settings.MEDIA_ROOT
     self.base_location = location
     self.location = abspathu(self.base_location)
     if base_url is None:
         base_url = settings.MEDIA_URL
     self.base_url = base_url
示例#4
0
 def __init__(self, location=None, base_url=None, media_root='', media_url=''):
     if location is None:
         location = media_root
     self.base_location = location
     self.location = abspathu(self.base_location)
     if base_url is None:
         base_url = media_url
     self.base_url = base_url
示例#5
0
def remove_missing_files():
    from django.utils._os import abspathu
    location = abspathu(UploadFileField.get_location())
    for (dirpath, dirnames, filenames) in os.walk(location):
        for name in filenames:
            fullpath = os.path.join(dirpath, name)
            if not UploadFile.objects.filter(
                    file=fullpath.replace(location + '/', '')).exists():
                os.remove(fullpath)
示例#6
0
 def __init__(self, location=None, base_url=None, file_permissions_mode=None):
     if location is None:
         location = settings.MEDIA_ROOT
     self.base_location = location
     self.location = abspathu(self.base_location)
     if base_url is None:
         base_url = settings.MEDIA_URL
     self.base_url = base_url
     self.file_permissions_mode = (
         file_permissions_mode if file_permissions_mode is not None
         else settings.FILE_UPLOAD_PERMISSIONS
     )
示例#7
0
    def __init__(self, root=None, base_url=None, file_permissions_mode=None,
            directory_permissions_mode=None):
        if root is None:
            root = settings.MEDIA_ROOT
        self.root = abspathu(root)
        if base_url is None:
            base_url = settings.MEDIA_URL
        self.base_url = base_url

        if file_permissions_mode is not None:
            self.file_permissions_mode = file_permissions_mode
        else:
            self.file_permissions_mode = settings.FILE_UPLOAD_PERMISSIONS
        if directory_permissions_mode is not None:
            self.directory_permissions_mode = directory_permissions_mode
        else:
            self.directory_permissions_mode = settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS
示例#8
0
 def __init__(self, location=None, base_url=None, file_permissions_mode=None,
         directory_permissions_mode=None):
     if location is None:
         location = settings.MEDIA_ROOT
     self.base_location = location
     self.location = abspathu(self.base_location)
     if base_url is None:
         base_url = settings.MEDIA_URL
     elif not base_url.endswith('/'):
         base_url += '/'
     self.base_url = base_url
     self.file_permissions_mode = (
         file_permissions_mode if file_permissions_mode is not None
         else settings.FILE_UPLOAD_PERMISSIONS
     )
     self.directory_permissions_mode = (
         directory_permissions_mode if directory_permissions_mode is not None
         else settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS
     )
示例#9
0
    def __init__(self, the_day, location=None, inst='ab', file_permissions_mode=None,
            directory_permissions_mode=None):
        if location is None:
            location = settings.FINANCE_ROOT
        if inst is not None:
            location =  os.path.join(location, inst)

        if isinstance(the_day, str):
            the_day = parser.parse(the_day)
        elif not isinstance(the_day, (datetime, date)):
            raise ValueError

        location = os.path.join(location, the_day.strftime('%Y%m%d'))

        self.base_location = location
        self.location = abspathu(self.base_location)
        self.file_permissions_mode = (None
        )
        self.directory_permissions_mode = (None
        )

        self.name = ''
示例#10
0
文件: storage.py 项目: isotoma/django
 def location(self):
     return abspathu(self.base_location)
示例#11
0
import errno
示例#12
0
 def path(self, name):
     self.location = abspathu(settings.ENHYDRIS_TIMESERIES_DATA_DIR)
     return super().path(name)
示例#13
0
    def __init__(self, location=None, base_url=None):
        """
            Initialize a Git repository or open an existing one.

            @param location: path where to create and open the repository
        """
        if not location:
            try:
                location = settings.GIT_STORAGE_ROOT
            except AttributeError:
                raise ImproperlyConfigured("GIT_STORAGE_ROOT is required")
        self.base_location = location
        self.location = abspathu(self.base_location)
        if base_url is None:
            try:
                base_url = settings.GIT_STORAGE_URL
            except AttributeError:
                base_url = None
        self.base_url = base_url

        # Reference (head)
        try:
            self.reference = settings.GIT_STORAGE_REFERENCE
        except AttributeError:
            self.reference = DEFAULT_REFERENCE

        # Author
        try:
            self.author_name, self.author_email = settings.GIT_STORAGE_AUTHOR
        except AttributeError:
            self.author_name, self.author_email = DEFAULT_AUTHOR

        # Committer
        try:
            self.committer_name, self.committer_email = settings.GIT_STORAGE_COMMITTER
        except AttributeError:
            self.committer_name, self.committer_email = DEFAULT_AUTHOR

        # Save message
        try:
            self.save_message = settings.GIT_STORAGE_SAVE_MESSAGE
        except AttributeError:
            self.save_message = DEFAULT_SAVE_MESSAGE

        # Delete message
        try:
            self.delete_message = settings.GIT_STORAGE_DELETE_MESSAGE
        except AttributeError:
            self.delete_message = DEFAULT_DELETE_MESSAGE

        # Create repository
        if not os.path.exists(location):
            repository = pygit2.init_repository(self.location, True)  # Bare
            # Initial commit
            author = utils.make_signature(self.author_name, self.author_email)
            committer = utils.make_signature(self.committer_name, self.committer_email)
            tree = repository.TreeBuilder().write()
            repository.create_commit(self.reference,
                                     author,
                                     committer,
                                     INITIAL_COMMIT_MESSAGE,
                                     tree,
                                     [])
            del repository

        # Open our repository instance
        self.repository = wrappers.Repository(self.location)
        assert self.repository.is_bare
示例#14
0
文件: models.py 项目: aptiko/enhydris
 def path(self, name):
     self.location = abspathu(settings.ENHYDRIS_TIMESERIES_DATA_DIR)
     return super(TimeseriesStorage, self).path(name)