Skip to content

Commit

Permalink
Merge pull request #104 from gisce/fix_4771_description
Browse files Browse the repository at this point in the history
Substation code field fix
  • Loading branch information
guilleJB committed Sep 9, 2015
2 parents a2267a3 + 32e9691 commit e738029
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions libcnmc/res_4771/POS.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ def get_sequence(self):
return self.connection.GiscedataCtsSubestacionsPosicio.search(
search_params, 0, 0, False, {'active_test': False})

def get_description(self, pos_id):
o = self.connection
pos = o.GiscedataCtsSubestacionsPosicio.read(pos_id, ['subestacio_id'])
descripcio = ''
if pos:
sub_id = pos['subestacio_id'][0]
sub = o.GiscedataCtsSubestacions.read(sub_id, ['descripcio'])
if sub:
descripcio = sub['descripcio']
return descripcio

def consumer(self):
O = self.connection
fields_to_read = ['name', 'cini', 'data_pm', 'subestacio_id',
Expand All @@ -48,7 +59,7 @@ def consumer(self):
try:
item = self.input_q.get()
self.progress_q.put(item)

o_sub = ''
sub = O.GiscedataCtsSubestacionsPosicio.read(
item, fields_to_read)
if not sub:
Expand Down Expand Up @@ -93,9 +104,10 @@ def consumer(self):
id_comunitat[0], ['codi'])
if comunitat_vals:
comunitat = comunitat_vals['codi']
o_sub = self.get_description(sub['subestacio_id'][0])

output = [
'%s' % sub['name'],
o_sub,
sub['cini'] or '',
cts['name'] or '',
codi,
Expand Down

0 comments on commit e738029

Please sign in to comment.