47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
import os
|
|
import shutil
|
|
|
|
def get_and_prepare_campaign_descriptor(num=1, initials='LI'):
|
|
"""
|
|
Prepares a campaign descriptor for use.
|
|
|
|
Args:
|
|
num (int): Campaign number. Options: 1, 2, 3
|
|
initials (str): Campaign initials. Options: 'LI', 'TBR', 'NG'
|
|
|
|
Returns:
|
|
str: Path to the prepared descriptor file
|
|
"""
|
|
# Define available options
|
|
options = {
|
|
1: 'LI',
|
|
2: 'TBR',
|
|
3: 'NG'
|
|
}
|
|
|
|
if num not in options or initials != options[num]:
|
|
raise ValueError(f"Invalid combination. Available options: {options}")
|
|
|
|
# Determine paths
|
|
descriptor_src = f'../dima/input_files/campaignDescriptor{num}_{initials}.yaml'
|
|
descriptor_dst = f'../data/campaignDescriptor{num}_{initials}.yaml'
|
|
|
|
# Copy descriptor to local folder
|
|
shutil.copyfile(descriptor_src, descriptor_dst)
|
|
|
|
# Decide network mount path
|
|
mount_path = '/mnt/network_mount' if os.path.exists('/mnt/network_mount') else '../data'
|
|
|
|
# Replace placeholder in descriptor
|
|
with open(descriptor_dst, 'r') as f:
|
|
content = f.read()
|
|
content = content.replace('${NETWORK_MOUNT}', mount_path)
|
|
with open(descriptor_dst, 'w') as f:
|
|
f.write(content)
|
|
|
|
print(f"Descriptor ready at {descriptor_dst} using mount {mount_path}")
|
|
return descriptor_dst
|
|
|
|
# Example usage:
|
|
# prepare_campaign_descriptor(1, 'LI')
|