Skip to content

Commit

Permalink
[snap] copy default snap.auxdta.properties to $HOME/.snap/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
johntruckenbrodt committed May 15, 2024
1 parent e796746 commit dead764
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pyroSAR/examine.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ class ExamineSnap(object):
and their existence is verified.
If this fails, a system check is performed to find relevant binaries in the system PATH variable and
additional files and folders relative to them.
Furthermore, a snap.auxdata.properties file is scanned for auxiliary data URLs and local storage location.
This is used by SNAP to manage data from e.g. the SRTM mission. In case SNAP is not installed, the respective
information is read from a default file delivered with pyroSAR. This has the advantage of using the SNAP download
URLs and local directory structure without having SNAP installed such that it can be adapted by other SAR software.
In case SNAP is not installed, a default `snap.auxdata.properties` file delivered with pyroSAR will be copied to
`$HOME/.snap/etc` so that SNAP download URLS and local directory structure can be adapted by other software.
SNAP configuration can be read and modified via the attribute `snap_properties` of type
:class:`~pyroSAR.examine.SnapProperties` or the properties :attr:`~pyroSAR.examine.ExamineSnap.userpath` and
Expand Down Expand Up @@ -73,6 +71,17 @@ def __init__(self):
log.debug('identifying SNAP')
self.__identify_snap()

# if SNAP cannot be identified, copy the snap.auxdata.properties file to $HOME/.snap/etc
if not self.__is_identified():
self.etc = os.path.join(os.path.expanduser('~'), '.snap', 'etc')
os.makedirs(self.etc, exist_ok=True)
dst = os.path.join(self.etc, 'snap.auxdata.properties')
if not os.path.isfile(dst):
dir_data = importlib.resources.files('pyroSAR') / 'snap' / 'data'
src = str(dir_data / 'snap.auxdata.properties')
log.debug(f'creating {dst}')
shutil.copyfile(src, dst)

# if the SNAP suffices attribute was not yet identified,
# point it to the default file delivered with pyroSAR
if not hasattr(self, '__suffices'):
Expand All @@ -93,7 +102,7 @@ def __getattr__(self, item):

def __is_identified(self):
"""
Check if SNAP has been properly identified, i.e. all paths in self.identifiers
Check if SNAP has been properly identified, i.e. all paths in `self.identifiers`
have been detected and confirmed.
Returns
Expand Down

0 comments on commit dead764

Please sign in to comment.