mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-27 13:42:14 +03:00
setup.py: Backup/restore monitor eddn-config.js if present
This commit is contained in:
parent
db698d70cf
commit
b81931fd3c
24
setup.py
24
setup.py
@ -3,6 +3,7 @@ import glob
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -170,6 +171,19 @@ print(
|
|||||||
Ensuring latest monitor files are in place...
|
Ensuring latest monitor files are in place...
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
# We need to preserve any js/eddn-config.js file
|
||||||
|
backup_fh, backup_filename = tempfile.mkstemp(prefix="eddn-config.js", dir=".")
|
||||||
|
os.close(backup_fh)
|
||||||
|
|
||||||
|
try:
|
||||||
|
shutil.copy2(
|
||||||
|
SHARE_EDDN_FILES / "monitor/js/eddn-config.js",
|
||||||
|
backup_filename,
|
||||||
|
)
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
backup_filename = None
|
||||||
|
|
||||||
# Copy the monitor (Web page) files
|
# Copy the monitor (Web page) files
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(SHARE_EDDN_FILES / "monitor")
|
shutil.rmtree(SHARE_EDDN_FILES / "monitor")
|
||||||
@ -182,6 +196,16 @@ shutil.copytree(
|
|||||||
SHARE_EDDN_FILES / "monitor",
|
SHARE_EDDN_FILES / "monitor",
|
||||||
copy_function=shutil.copyfile, # type: ignore
|
copy_function=shutil.copyfile, # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Restore the backed-up eddn-config.js
|
||||||
|
if backup_filename is not None:
|
||||||
|
shutil.copy2(
|
||||||
|
backup_filename,
|
||||||
|
SHARE_EDDN_FILES / "monitor/js/eddn-config.js",
|
||||||
|
)
|
||||||
|
|
||||||
|
os.unlink(backup_filename)
|
||||||
|
|
||||||
# And a copy of the schemas too
|
# And a copy of the schemas too
|
||||||
print(
|
print(
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user