Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc committed Nov 22, 2023
1 parent eda512a commit 6ae9068
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 573 deletions.
3 changes: 1 addition & 2 deletions src/fprime_gds/common/files/uplinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class FileUplinker(fprime_gds.common.handlers.DataHandler):

CHUNK_SIZE = 256

def __init__(self, file_store, file_encoder, chunk=CHUNK_SIZE, timeout=20):
def __init__(self, file_encoder, chunk=CHUNK_SIZE, timeout=20):
"""
Constructor to build the file uplinker.
"""
Expand All @@ -157,7 +157,6 @@ def __init__(self, file_store, file_encoder, chunk=CHUNK_SIZE, timeout=20):
self.sequence = 0
self.chunk = chunk
self.file_encoder = file_encoder
self.file_store = file_store
self.__destination_dir = "/"
self.__expected = []
self.__timeout = Timeout()
Expand Down
8 changes: 4 additions & 4 deletions src/fprime_gds/common/pipeline/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ def __init__(self):
self.__downlinker = None

def setup_file_handling(
self, file_store, file_encoder, file_decoder, distributor, log_dir
self, down_store, file_encoder, file_decoder, distributor, log_dir
):
"""
Sets up the file handling (uplink and downlink) from a pair of encoders and decoders
:param file_store: uplink/downlink storage directory
:param down_store: downlink storage directory
:param file_encoder: file encoder for uplink
:param file_decoder: file decoder for downlink
:param distributor: data distributor to register handshaking to
:param log_dir: log directory to output downlink logs
"""
self.__uplinker = fprime_gds.common.files.uplinker.FileUplinker(
file_store, file_encoder # maybe not here after all??
file_encoder
)
self.__downlinker = fprime_gds.common.files.downlinker.FileDownlinker(
file_store, log_dir=log_dir
down_store, log_dir=log_dir
)
file_decoder.register(self.__downlinker)
distributor.register("FW_PACKET_HAND", self.__uplinker)
Expand Down
9 changes: 7 additions & 2 deletions src/fprime_gds/common/pipeline/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def __init__(self):
self.client_socket = None
self.logger = None
self.dictionary_path = None
self.up_store = None
self.down_store = None


self.__dictionaries = dictionaries.Dictionaries()
self.__coders = encoding.EncodingDecoding()
Expand All @@ -65,6 +68,9 @@ def setup(
:param packet_spec: location of packetized telemetry XML specification.
"""
assert dictionary is not None and Path(dictionary).is_file(), f"Dictionary {dictionary} does not exist"
# File storage configuration for uplink and downlink
self.up_store = Path(file_store) / "fprime-uplink"
self.down_store = Path(file_store) / "fprime-downlink"
self.dictionary_path = Path(dictionary)
# Loads the distributor and client socket
self.distributor = fprime_gds.common.distributor.distributor.Distributor(config)
Expand All @@ -76,8 +82,7 @@ def setup(
)
self.histories.setup_histories(self.coders)
self.files.setup_file_handling(
# here
file_store,
self.down_store,
self.coders.file_encoder,
self.coders.file_decoder,
self.distributor,
Expand Down
10 changes: 5 additions & 5 deletions src/fprime_gds/executables/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,18 @@ def get_arguments(self) -> Dict[Tuple[str, ...], Dict[str, Any]]:

return {
("--file-storage-directory",): {
"dest": "files_directory",
"dest": "files_storage_directory",
"action": "store",
"default": "/tmp/" + username + "/fprime-downlink/",
"default": "/tmp/" + username,
"required": False,
"type": str,
"help": "File to store uplink and downlink files. Default: %(default)s",
"help": "Directory to store uplink and downlink files. Default: %(default)s",
}
}

def handle_arguments(self, args, **kwargs):
"""Handle arguments as parsed"""
os.makedirs(args.files_directory, exist_ok=True)
os.makedirs(args.files_storage_directory, exist_ok=True)
return args


Expand All @@ -572,7 +572,7 @@ def pipeline_factory(args_ns, pipeline=None) -> StandardPipeline:
pipeline_arguments = {
"config": ConfigManager(),
"dictionary": args_ns.dictionary,
"file_store": args_ns.files_directory,
"file_store": args_ns.files_storage_directory,
"packet_spec": args_ns.packet_spec,
"logging_prefix": args_ns.logs,
}
Expand Down
Loading

0 comments on commit 6ae9068

Please sign in to comment.