Commit 38245e79 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Better logging

parent 24be5636
......@@ -57,8 +57,16 @@ class DataFile(Publisher):
def unsubscribe(self, who):
super(DataFile, self).unsubscribe(who)
if self.local_status == LocalStatus.READY and not self.suscribers:
os.remove(self.local_file)
self._clean_local()
def _clean_local(self):
if self.local_status != LocalStatus.READY or len(self.suscribers) > 0 or self.upload_required():
return
Log.debug('File {0} no longer needed. Deleting from scratch...'.format(self.remote_file))
os.remove(self.local_file)
Log.debug('File {0} deleted from scratch'.format(self.remote_file))
self.local_file = None
self.local_status = LocalStatus.PENDING
def upload_required(self):
return self.local_status == LocalStatus.READY and self.storage_status == StorageStatus.PENDING
......@@ -155,6 +163,7 @@ class DataFile(Publisher):
except Exception as ex:
Log.warning('Link for file {0} can not be created: {1}', self.remote_file, ex)
self.storage_status = StorageStatus.READY
self._clean_local()
def set_local_file(self, local_file, diagnostic=None, rename_var=''):
if diagnostic in self._modifiers:
......@@ -429,6 +438,7 @@ class NetCDFFile(DataFile):
def download(self):
try:
self.local_status = LocalStatus.DOWNLOADING
Log.debug('Downloading file {0}...', self.remote_file)
if not self.local_file:
self.local_file = TempFile.get()
Utils.get_file_hash(self.remote_file, use_stored=True, save=True)
......
......@@ -353,6 +353,7 @@ class THREDDSSubset(DataFile):
def download(self):
try:
Log.debug('Downloading thredds subset {0}...', self)
iris.FUTURE.netcdf_promote = True
iris.FUTURE.netcdf_no_unlimited = True
with iris.FUTURE.context(cell_datetime_objects=True):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment