mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Added the copy_admin_templates script
This commit is contained in:
parent
868c1e2d4d
commit
718d7744d3
1 changed files with 32 additions and 0 deletions
32
copy_admin_templates.py
Normal file
32
copy_admin_templates.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from os.path import exists
|
||||||
|
from shutil import copytree, rmtree
|
||||||
|
from flask_admin import __file__ as flaskAdminPath
|
||||||
|
|
||||||
|
def copyAdminTemplates():
|
||||||
|
src = flaskAdminPath.removesuffix("__init__.py") + "templates/bootstrap3/admin"
|
||||||
|
if not exists(src):
|
||||||
|
print("Templates could not be found in", src)
|
||||||
|
print("You can also copy them manually.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
dist = "advlabdb/templates/admin"
|
||||||
|
if exists(dist):
|
||||||
|
while True:
|
||||||
|
ans = input(f"The directory {dist} already exists. Enter 'o' to override it and update the templates or enter 's' to stop the process: ").lower()
|
||||||
|
if ans == "s":
|
||||||
|
print("Process stopped!")
|
||||||
|
return False
|
||||||
|
elif ans == "o":
|
||||||
|
break
|
||||||
|
rmtree(dist)
|
||||||
|
print("Old templates deleted!")
|
||||||
|
|
||||||
|
copytree(src, dist)
|
||||||
|
print("Copied", src, "->", dist)
|
||||||
|
return True
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if copyAdminTemplates():
|
||||||
|
print("Done!")
|
||||||
|
else:
|
||||||
|
print("Did not copy!")
|
Loading…
Reference in a new issue