Exemplo n.º 1
0
def init_indexes(index_folder):
    index_path = os.path.join(index_folder, "assets")
    asset_index = None
    if not os.path.exists(index_path):
        fs.mkdir_p(index_path)
        asset_index = indexing.create_index(index_path, asset_schema)
    person_index_path = os.path.join(index_folder, "persons")
    person_index = None
    if not os.path.exists(person_index_path):
        fs.mkdir_p(person_index_path)
        person_index = indexing.create_index(person_index_path, person_schema)
    return (asset_index, person_index)
Exemplo n.º 2
0
    def test_generate_preview_variants(self):
        preview_id = "123413-12312"
        file_path_fixture = self.get_fixture_file_path("thumbnails/th01.png")
        file_name = thumbnail.get_file_name(preview_id)
        folder_path = thumbnail.get_preview_folder_name(
            "originals", preview_id)
        fs.mkdir_p(folder_path)
        fs.copyfile(file_path_fixture, os.path.join(folder_path, file_name))
        thumbnail.generate_preview_variants(preview_id)

        file_path = thumbnail.get_preview_file_path("previews", preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.PREVIEW_SIZE)

        folder_path = thumbnail.get_preview_folder_name(
            "thumbnails", preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.RECTANGLE_SIZE)

        folder_path = thumbnail.get_preview_folder_name(
            "thumbnails-square", preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.SQUARE_SIZE)
Exemplo n.º 3
0
def create_folder(subfolder):
    thumbnail_folder = get_folder_name(subfolder)
    fs.mkdir_p(thumbnail_folder)
    return thumbnail_folder
Exemplo n.º 4
0
def create_type_folder(data_type):
    thumbnail_folder = get_folder_name(data_type)
    fs.mkdir_p(thumbnail_folder)
    return thumbnail_folder
Exemplo n.º 5
0
 def test_mkdirp(self):
     folder = "one/two/three"
     fs.mkdir_p(folder)
     self.assertTrue(os.path.exists(folder))
     fs.rm_rf("one")
     self.assertTrue(not os.path.exists(folder))
Exemplo n.º 6
0
 def setUp(self):
     super(ThumbnailTestCase, self).setUp()
     fs.mkdir_p(TEST_FOLDER)
     self.folder_name = os.path.join(TEST_FOLDER, "persons")