1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-19 18:31:16 +00:00
AdvLabDB/copy_admin_templates.py

38 lines
1 KiB
Python
Raw Normal View History

2021-05-17 16:49:56 +00:00
from os.path import exists
from shutil import copytree, rmtree
2021-06-02 21:43:41 +00:00
2021-05-17 16:49:56 +00:00
from flask_admin import __file__ as flaskAdminPath
2021-05-17 20:36:24 +00:00
2021-05-17 16:49:56 +00:00
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:
2021-06-02 21:43:41 +00:00
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()
2021-05-17 16:49:56 +00:00
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
2021-05-17 20:36:24 +00:00
2021-05-17 16:49:56 +00:00
if __name__ == "__main__":
if copyAdminTemplates():
print("Done!")
else:
print("Did not copy!")