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

Fixed errors appearing when jobs failed

parent d2cbdc59
......@@ -57,7 +57,7 @@ class DataFile(Publisher):
def unsubscribe(self, who):
super(DataFile, self).unsubscribe(who)
if self.local_status == LocalStatus.READY and len(self.subscribers) == 0:
if self.local_status == LocalStatus.READY and not self.suscribers:
os.remove(self.local_file)
def upload_required(self):
......
......@@ -172,12 +172,16 @@ class Interpolate(Diagnostic):
nco.ncwa(input=temp, output=temp, options=('-O -h -a lev',))
else:
shutil.copy(input_file, temp)
weights_file = '/esnas/autosubmit/con_files/weigths/{0}/rmp_{0}_to_{1}_lev{2}.nc'.format(self.model_version,
self.grid, lev + 1)
if not os.path.isfile(weights_file):
raise Exception('Level {0} weights file does not exist for model {1} '
'and grid {2}'.format(lev+1, self.model_version, self.grid))
namelist_file = TempFile.get(suffix='')
scrip_use_in = open(namelist_file, 'w')
scrip_use_in.writelines("&remap_inputs\n")
scrip_use_in.writelines(" remap_wgt = '/esnas/autosubmit/con_files/"
"weigths/{0}/rmp_{0}_to_{1}_lev{2}.nc'\n".format(self.model_version, self.grid,
lev + 1))
scrip_use_in.writelines(" remap_wgt = '{0}'\n".format(weights_file))
scrip_use_in.writelines(" infile = '{0}'\n".format(temp))
scrip_use_in.writelines(" invertlat = FALSE\n")
scrip_use_in.writelines(" var = '{0}'\n".format(self.variable))
......@@ -186,7 +190,7 @@ class Interpolate(Diagnostic):
scrip_use_in.writelines("/\n")
scrip_use_in.close()
Utils.execute_shell_command('/home/Earth/jvegas/pyCharm/cfutools/interpolation/scrip_use '
'{0}'.format(namelist_file), Log.DEBUG)
'{0}'.format(namelist_file), Log.INFO)
os.remove(namelist_file)
nco.ncecat(input=temp, output=temp, options=("-O -h",))
shutil.move(temp, self._get_level_file(lev))
......
......@@ -37,10 +37,9 @@ class Publisher(object):
for subscriber, callback in self._subscribers.items():
callback(*args)
@property
def suscribers(self, *args):
"""
Notify update to all the suscribers
:param args: arguments to pass
List of suscribers of this publisher
"""
return self._subscribers.keys()
......@@ -10,14 +10,14 @@ class TestPublisher(TestCase):
suscriber = Mock()
pub = Publisher()
pub.subscribe(suscriber, callback=suscriber.callback)
self.assertIn(suscriber, pub.suscribers())
self.assertIn(suscriber, pub.suscribers)
def test_suscribe_default(self):
suscriber = Mock()
pub = Publisher()
pub.subscribe(suscriber)
self.assertTrue(hasattr(suscriber, 'update'))
self.assertIn(suscriber, pub.suscribers())
self.assertIn(suscriber, pub.suscribers)
def test_unsuscribe(self):
suscriber = Mock()
......@@ -25,7 +25,7 @@ class TestPublisher(TestCase):
pub.subscribe(suscriber, callback=suscriber.callback)
pub.unsubscribe(suscriber)
self.assertNotIn(suscriber, pub.suscribers())
self.assertNotIn(suscriber, pub.suscribers)
def test_dispatch(self):
suscriber = Mock()
......
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