mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
added lockfile function
This commit is contained in:
@@ -5,6 +5,7 @@ import urllib.parse
|
|||||||
import shutil
|
import shutil
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
from string import Template
|
from string import Template
|
||||||
|
from pathlib import Path
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm.auto import tqdm
|
from tqdm.auto import tqdm
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ _FOLDERICON = "https://www.svgrepo.com/show/400249/folder.svg"
|
|||||||
_ROOTTITLE = "Pictures"
|
_ROOTTITLE = "Pictures"
|
||||||
imgext = [".jpg", ".jpeg"]
|
imgext = [".jpg", ".jpeg"]
|
||||||
rawext = [".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"]
|
rawext = [".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"]
|
||||||
excludes = ["index.html", "Galleries", ".previews", "Archives", "Wallpaper"]
|
excludes = [".lock", "index.html", "Galleries", ".previews", "Archives", "Wallpaper"]
|
||||||
|
|
||||||
thumbnails: list[tuple[str, str]] = []
|
thumbnails: list[tuple[str, str]] = []
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ HTMLHEADER = """
|
|||||||
-ms-flex-wrap: wrap; /* IE10 */
|
-ms-flex-wrap: wrap; /* IE10 */
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.folders figure {
|
.folders figure {
|
||||||
@@ -65,6 +67,7 @@ HTMLHEADER = """
|
|||||||
|
|
||||||
.folders figcaption {
|
.folders figcaption {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
@@ -269,6 +272,12 @@ def main():
|
|||||||
if not os.path.exists(os.path.join(args.root, ".previews")):
|
if not os.path.exists(os.path.join(args.root, ".previews")):
|
||||||
os.mkdir(os.path.join(args.root, ".previews"))
|
os.mkdir(os.path.join(args.root, ".previews"))
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(args.root, ".lock")):
|
||||||
|
print("Another instance of this program is running.")
|
||||||
|
exit()
|
||||||
|
try:
|
||||||
|
Path(os.path.join(args.root, ".lock")).touch()
|
||||||
|
|
||||||
if args.non_interactive:
|
if args.non_interactive:
|
||||||
print("Generating html files...")
|
print("Generating html files...")
|
||||||
listfolder(args.root, _ROOTTITLE)
|
listfolder(args.root, _ROOTTITLE)
|
||||||
@@ -287,7 +296,9 @@ def main():
|
|||||||
|
|
||||||
with Pool(os.cpu_count()) as p:
|
with Pool(os.cpu_count()) as p:
|
||||||
for r in tqdm(p.imap_unordered(thumbnail_convert, thumbnails), total=len(thumbnails), desc="Generating thumbnails", unit=" files", ascii=True, dynamic_ncols=True):
|
for r in tqdm(p.imap_unordered(thumbnail_convert, thumbnails), total=len(thumbnails), desc="Generating thumbnails", unit=" files", ascii=True, dynamic_ncols=True):
|
||||||
...
|
pass
|
||||||
|
finally:
|
||||||
|
os.remove(os.path.join(args.root, ".lock"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user