Example #1
0
    def __init__(self, path, size_min=4800, size_max=5200):
        # 1. Keep the path
        if not lfs.is_folder(path):
            error = '"%s" should be a folder, but it is not' % path
            raise ValueError, error

        folder = lfs.open(path)
        self.path = str(folder.path)

        # 2. Keep the path to the data
        self.path_data = '%s/database/' % self.path
        if not lfs.is_folder(self.path_data):
            error = '"%s" should be a folder, but it is not' % self.path_data
            raise ValueError, error

        # 3. Initialize the database, but chrooted
        self.fs = lfs.open(self.path_data)

        # 4. New interface to Git
        self.worktree = open_worktree(self.path_data)

        # 5. A mapping from key to handler
        self.cache = LRUCache(size_min, size_max, automatic=False)

        # 6. The git cache
        self.git_cache = LRUCache(900, 1100)
Example #2
0
    def __init__(self, path, size_min=4800, size_max=5200):
        # 1. Keep the path
        if not lfs.is_folder(path):
            error = '"%s" should be a folder, but it is not' % path
            raise ValueError, error

        folder = lfs.open(path)
        self.path = str(folder.path)

        # 2. Keep the path to the data
        self.path_data = '%s/database/' % self.path
        if not lfs.is_folder(self.path_data):
            error = '"%s" should be a folder, but it is not' % self.path_data
            raise ValueError, error

        # 3. Initialize the database, but chrooted
        self.fs = lfs.open(self.path_data)

        # 4. New interface to Git
        self.worktree = open_worktree(self.path_data)

        # 5. A mapping from key to handler
        self.cache = LRUCache(size_min, size_max, automatic=False)

        # 6. The git cache
        self.git_cache = LRUCache(900, 1100)
Example #3
0
 def __init__(self, path, fields, read_only=False):
     self.nb_transactions = 0
     self.last_transaction_dtime = None
     self.path = abspath(path) + '/'
     self.fields = fields
     self.read_only = read_only
     # Open database
     self.path_data = '%s/database/' % self.path
     # Check if is a folder
     self.path_data = '%s/database/' % self.path
     if not lfs.is_folder(self.path_data):
         error = '"{0}" should be a folder, but it is not'.format(self.path_data)
         raise ValueError(error)
     # New interface to Git
     self.worktree = open_worktree(self.path_data)
     # Initialize the database, but chrooted
     self.fs = lfs.open(self.path_data)
     # Static FS
     database_static_path = '{0}/database_static'.format(path)
     if not lfs.exists(database_static_path):
         self.init_backend_static(path)
     self.static_fs = lfs.open(database_static_path)
     # Patchs backend
     self.patchs_backend = PatchsBackend(path, self.fs, read_only)
     # Catalog
     self.catalog = self.get_catalog()
Example #4
0
 def __init__(self, path):
     self.path = abspath(path) + '/'
     # Open database
     self.path_data = '%s/database/' % self.path
     if not lfs.is_folder(self.path_data):
         error = '"%s" should be a folder, but it is not' % path
         raise ValueError, error
     # Open repository
     self.repo = Repository(self.path_data)
     # Read index
     try:
         tree = self.repo.head.peel(GIT_OBJ_TREE)
         self.repo.index.read_tree(tree.id)
     except:
         pass
     # Check git commiter
     try:
         _, _ = self.username, self.useremail
     except:
         print '========================================='
         print 'ERROR: Please configure GIT commiter via'
         print ' $ git config --global user.name'
         print ' $ git config --global user.email'
         print '========================================='
         raise
Example #5
0
File: git.py Project: Ramel/itools
 def __init__(self, path):
     self.nb_transactions = 0
     self.last_transaction_dtime = None
     self.path = abspath(path) + '/'
     # Open database
     self.path_data = '%s/database/' % self.path
     # Check if is a folder
     self.path_data = '%s/database/' % self.path
     if not lfs.is_folder(self.path_data):
         error = '"{0}" should be a folder, but it is not'.format(
             self.path_data)
         raise ValueError(error)
     # New interface to Git
     self.worktree = open_worktree(self.path_data)
     # Initialize the database, but chrooted
     self.fs = lfs.open(self.path_data)
     # Static FS
     database_static_path = '{0}/database_static'.format(path)
     if not lfs.exists(database_static_path):
         self.init_backend_static(path)
     self.static_fs = lfs.open(database_static_path)
Example #6
0
File: git.py Project: hforge/itools
 def __init__(self, path, fields, read_only=False):
     self.nb_transactions = 0
     self.last_transaction_dtime = None
     self.path = abspath(path) + '/'
     self.fields = fields
     self.read_only = read_only
     # Open database
     self.path_data = '%s/database/' % self.path
     # Check if is a folder
     self.path_data = '%s/database/' % self.path
     if not lfs.is_folder(self.path_data):
         error = '"{0}" should be a folder, but it is not'.format(self.path_data)
         raise ValueError(error)
     # New interface to Git
     self.worktree = open_worktree(self.path_data)
     # Initialize the database, but chrooted
     self.fs = lfs.open(self.path_data)
     # Static FS
     database_static_path = '{0}/database_static'.format(path)
     if not lfs.exists(database_static_path):
         self.init_backend_static(path)
     self.static_fs = lfs.open(database_static_path)
     # Catalog
     self.catalog = self.get_catalog()
Example #7
0
 def test_make_folder(self):
     lfs.make_folder('tests/folder')
     self.assertEqual(lfs.is_folder('tests/folder'), True)
     lfs.remove('tests/folder')
Example #8
0
 def test_is_folder(self):
     is_folder = lfs.is_folder('tests')
     self.assertEqual(is_folder, True)
Example #9
0
 def test_make_folder(self):
     lfs.make_folder('tests/folder')
     self.assertEqual(lfs.is_folder('tests/folder'), True)
     lfs.remove('tests/folder')
Example #10
0
 def test_is_folder(self):
     is_folder = lfs.is_folder('tests')
     self.assertEqual(is_folder, True)
Example #11
0
 def get_catalog(self):
     path = '{0}/catalog'.format(self.path)
     if not lfs.is_folder(path):
         return None
     return Catalog(path, self.fields, read_only=self.read_only)
Example #12
0
File: git.py Project: hforge/itools
 def get_catalog(self):
     path = '{0}/catalog'.format(self.path)
     if not lfs.is_folder(path):
         return None
     return Catalog(path, self.fields, read_only=self.read_only)