Merge pull request #1156 from CLIP-HPC/fix_server_log

Fix Read-Only filesystem permission issue for log file
pull/1162/head
Min RK 2022-06-08 11:15:55 +02:00 zatwierdzone przez GitHub
commit e7524a7b4b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -30,17 +30,21 @@ def main():
# 2. current working directory: "." # 2. current working directory: "."
# 3. default temp directory for the OS (e.g. /tmp for linux) # 3. default temp directory for the OS (e.g. /tmp for linux)
log_dirs = [".", tempfile.gettempdir()] log_dirs = [".", tempfile.gettempdir()]
log_file = None
if "REPO_DIR" in os.environ: if "REPO_DIR" in os.environ:
log_dirs.insert(0, os.environ["REPO_DIR"]) log_dirs.insert(0, os.environ["REPO_DIR"])
for d in log_dirs: for d in log_dirs:
log_path = os.path.join(d, ".jupyter-server-log.txt") log_path = os.path.join(d, ".jupyter-server-log.txt")
try: try:
log_file = open(log_path, "ab") log_file = open(log_path, "ab")
except PermissionError: except Exception:
continue continue
else: else:
# success # success
break break
# raise Exception if log_file could not be set
if log_file is None:
raise Exception("Could not open '.jupyter-server-log.txt' log file " )
# build the command # build the command
# like `exec "$@"` # like `exec "$@"`