Skip to content

Commit

Permalink
Update folder location for playback files to be an environment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
menanteau committed May 10, 2024
1 parent c065112 commit dfe6bdb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/HeaderService/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__author__ = "LSST/Felipe Menanteau"
__version__ = "3.3.11"
__version__ = "3.3.12"
version = __version__

from . import hutils
Expand Down
22 changes: 21 additions & 1 deletion python/HeaderService/hslib_salobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ def end_collection_event_callback(self, myData):
# take care of updating data structures. We also write the header file.
asyncio.ensure_future(self.complete_tasks_END(imageName))

def get_playlist_dir(self):
"""Figure the location for the playlist folder"""
if 'HEADERSERVICE_PLAYLIST_DIR' in os.environ:
self.playlist_dir = os.path.join(os.environ['HEADERSERVICE_PLAYLIST_DIR'],
self.config.instrument)
else:
self.playlist_dir = os.path.join(HEADERSERVICE_DIR,
"etc/playback/lib", self.config.instrument)
# Make sure that the directory exists
if not os.path.exists(self.playlist_dir):
msg = f"Directory: {self.playlist_dir} not found"
self.log.error(msg)
raise FileNotFoundError(msg)
else:
self.log.info(f"Will use: {self.playlist_dir} for playback folder")

def get_tstand(self):
"""Figure the Test Stand in use"""
# Check if definced in self.config or the environment
Expand Down Expand Up @@ -490,6 +506,10 @@ def prepare(self):
# Get the TSTAND
self.get_tstand()

# Get the playlist directory
if self.config.playback:
self.get_playlist_dir()

# Create dictionaries keyed to imageName
self.create_dicts()

Expand Down Expand Up @@ -665,7 +685,7 @@ def update_header_emuimage(self, imageName):
"""
emuimage = self.metadata[imageName]['EMUIMAGE']
self.log.info(f"Playback mode emulatedImage: {emuimage}")
emuimage_file = os.path.join(HEADERSERVICE_DIR, "etc/playback/lib/ComCam", emuimage+".json")
emuimage_file = os.path.join(self.playlist_dir, emuimage+".json")
self.log.info(f"Reading json file: {emuimage_file}")
with open(emuimage_file) as f:
emuimage_dict = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# The main call
setup(name='HeaderService',
version='3.3.11',
version='3.3.12',
license="GPL",
description="LSST Meta-data aggregator for FITS header service",
author="LSST, Felipe Menanteau",
Expand Down

0 comments on commit dfe6bdb

Please sign in to comment.