Skip to content

Commit

Permalink
[DEMHandler] only lock VRT if path is writable
Browse files Browse the repository at this point in the history
  • Loading branch information
johntruckenbrodt committed Sep 17, 2024
1 parent 6122ff9 commit 4a99280
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions pyroSAR/auxdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,21 @@ def __buildvrt(tiles, vrtfile, pattern, vsi, extent, src_nodata=None,
opts['VRTNodata'] = dst_nodata
opts['outputBounds'] = (extent['xmin'], extent['ymin'],
extent['xmax'], extent['ymax'])
with Lock(vrtfile, timeout=lock_timeout):
if not os.path.isfile(vrtfile):
gdalbuildvrt(src=locals, dst=vrtfile, **opts)
if dst_datatype is not None:
datatype = Dtype(dst_datatype).gdalstr
tree = etree.parse(source=vrtfile)
band = tree.find(path='VRTRasterBand')
band.attrib['dataType'] = datatype
tree.write(file=vrtfile, pretty_print=True,
xml_declaration=False, encoding='utf-8')
lock = None
if os.access(vrtfile, os.W_OK):
# lock only if writable, not e.g. vsimem
lock = Lock(vrtfile, timeout=lock_timeout)
if not os.path.isfile(vrtfile):
gdalbuildvrt(src=locals, dst=vrtfile, **opts)
if dst_datatype is not None:
datatype = Dtype(dst_datatype).gdalstr
tree = etree.parse(source=vrtfile)
band = tree.find(path='VRTRasterBand')
band.attrib['dataType'] = datatype
tree.write(file=vrtfile, pretty_print=True,
xml_declaration=False, encoding='utf-8')
if lock is not None:
lock.remove()

def __commonextent(self, buffer=None):
"""
Expand Down

0 comments on commit 4a99280

Please sign in to comment.