Fix Read-Only filesystem permission issue for log file

pull/1156/head
Ümit Seren 2022-05-03 12:23:58 +02:00
rodzic 61247bec16
commit 3ee04e34a3
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -30,17 +30,21 @@ def main():
# 2. current working directory: "."
# 3. default temp directory for the OS (e.g. /tmp for linux)
log_dirs = [".", tempfile.gettempdir()]
log_file = None
if "REPO_DIR" in os.environ:
log_dirs.insert(0, os.environ["REPO_DIR"])
for d in log_dirs:
log_path = os.path.join(d, ".jupyter-server-log.txt")
try:
log_file = open(log_path, "ab")
except PermissionError:
except Exception:
continue
else:
# success
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
# like `exec "$@"`