Skip to content

Commit

Permalink
Fix permission check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc committed Jan 10, 2024
1 parent 16dd40c commit f960b61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/fprime_gds/common/pipeline/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@author mstarch
"""
import os
from pathlib import Path
import fprime_gds.common.files.downlinker
import fprime_gds.common.files.uplinker

Expand Down Expand Up @@ -43,10 +43,11 @@ def setup_file_handling(
)
file_decoder.register(self.__downlinker)
distributor.register("FW_PACKET_HAND", self.__uplinker)
if not os.access(down_store, os.W_OK):
try:
Path(down_store).mkdir(parents=True, exist_ok=True)
except PermissionError:
raise PermissionError(
f"{down_store} is not writable. Downlinker not be able to save files. "
"Fix permissions or change storage directory with --file-storage-directory."
f"{down_store} is not writable. Fix permissions or change storage directory with --file-storage-directory."
)

@property
Expand Down
7 changes: 7 additions & 0 deletions src/fprime_gds/common/pipeline/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ def setup(
# File storage configuration for uplink and downlink
self.up_store = Path(file_store) / "fprime-uplink"
self.down_store = Path(file_store) / "fprime-downlink"
try:
self.down_store.mkdir(parents=True, exist_ok=True)
self.up_store.mkdir(parents=True, exist_ok=True)
except PermissionError:
raise PermissionError(
f"{file_store} is not writable. Fix permissions or change storage directory with --file-storage-directory."
)
self.dictionary_path = Path(dictionary)
# Loads the distributor and client socket
self.distributor = fprime_gds.common.distributor.distributor.Distributor(config)
Expand Down

0 comments on commit f960b61

Please sign in to comment.