2018-06-15 11:41:06 -04:00
|
|
|
import glob
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
|
2018-06-15 14:49:46 -04:00
|
|
|
GXY_ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
|
2018-06-15 11:41:06 -04:00
|
|
|
|
|
|
|
|
|
2019-03-14 13:18:43 -04:00
|
|
|
def stage_static(f):
|
2018-06-15 11:41:06 -04:00
|
|
|
src = os.path.join(GXY_ROOT, "config/plugins", f)
|
|
|
|
|
dest = os.path.join(GXY_ROOT, "static/plugins", f)
|
2018-06-15 14:49:46 -04:00
|
|
|
dest_parent = os.path.abspath(os.path.join(dest, os.pardir))
|
2018-09-19 11:16:46 +01:00
|
|
|
if os.path.lexists(dest):
|
2018-06-15 12:48:02 -04:00
|
|
|
# We have to clear out the old staged or linked static to relink.
|
2018-06-15 11:41:06 -04:00
|
|
|
if os.path.islink(dest):
|
2018-09-19 11:16:46 +01:00
|
|
|
os.remove(dest)
|
2018-06-15 11:41:06 -04:00
|
|
|
else:
|
|
|
|
|
shutil.rmtree(dest)
|
|
|
|
|
elif not os.path.exists(dest_parent):
|
|
|
|
|
os.makedirs(dest_parent)
|
2018-09-19 11:16:46 +01:00
|
|
|
try:
|
2019-03-14 13:18:43 -04:00
|
|
|
if os.path.isdir(src):
|
|
|
|
|
shutil.copytree(src, dest)
|
|
|
|
|
else:
|
|
|
|
|
shutil.copy(src, dest)
|
2018-09-19 11:16:46 +01:00
|
|
|
except Exception:
|
2020-10-06 18:49:19 +01:00
|
|
|
print(f"Error copying '{src}' to '{dest}'")
|
2018-09-19 11:16:46 +01:00
|
|
|
raise
|
2018-06-15 11:41:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
# This is not awesome, but it's temporary, and it supports two-tier plugin static.
|
2018-06-15 12:48:02 -04:00
|
|
|
for f in glob.glob(os.path.join(GXY_ROOT, "config/plugins/*/*/static")) + glob.glob(
|
|
|
|
|
os.path.join(GXY_ROOT, "config/plugins/*/*/*/static")
|
|
|
|
|
):
|
2018-06-15 11:41:06 -04:00
|
|
|
f = os.path.relpath(f, os.path.join(GXY_ROOT, "config/plugins"))
|
2019-03-14 13:18:43 -04:00
|
|
|
stage_static(f)
|