Code Duplication    Length = 18-21 lines in 3 locations

myems-api/core/microgrid.py 1 location

@@ 5178-5196 (lines=19) @@
5175
        cursor.close()
5176
        cnx.close()
5177
5178
        if row is None:
5179
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
5180
                                   description='API.MICROGRID_NOT_FOUND')
5181
        else:
5182
            meta_result = {"id": row[0],
5183
                           "name": row[1],
5184
                           "uuid": row[2],
5185
                           "address": row[3],
5186
                           "postal_code": row[4],
5187
                           "latitude": row[5],
5188
                           "longitude": row[6],
5189
                           "rated_capacity": row[7],
5190
                           "rated_power": row[8],
5191
                           "contact": contact_dict.get(row[9], None),
5192
                           "cost_center": cost_center_dict.get(row[10], None),
5193
                           "serial_number": row[11],
5194
                           "svg": row[12],
5195
                           "is_cost_data_displayed": bool(row[13]),
5196
                           "description": row[14]}
5197
5198
        resp.text = json.dumps(meta_result)
5199

myems-api/core/photovoltaicpowerstation.py 1 location

@@ 656-673 (lines=18) @@
653
        cursor.close()
654
        cnx.close()
655
656
        if row is None:
657
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
658
                                   description='API.PHOTOVOLTAIC_POWER_STATION_NOT_FOUND')
659
        else:
660
            meta_result = {"name": row[1],
661
                           "uuid": row[2],
662
                           "station_code": row[3],
663
                           "address": row[4],
664
                           "latitude": row[5],
665
                           "longitude": row[6],
666
                           "rated_capacity": row[7],
667
                           "rated_power": row[8],
668
                           "contact": contact_dict.get(row[9], None),
669
                           "cost_center": cost_center_dict.get(row[10], None),
670
                           "svg": svg_dict.get(row[11], None),
671
                           "is_cost_data_displayed": bool(row[12]),
672
                           "phase_of_lifecycle": row[13],
673
                           "description": row[14]}
674
675
        resp.text = json.dumps(meta_result)
676

myems-api/reports/energystoragepowerstationdetails.py 1 location

@@ 128-148 (lines=21) @@
125
            cursor_system.execute(query, (energy_storage_power_station_uuid,))
126
            row = cursor_system.fetchone()
127
128
        if row is None:
129
            cursor_system.close()
130
            cnx_system.close()
131
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
132
                                   description='API.ENERGY_STORAGE_POWER_STATION_NOT_FOUND')
133
        else:
134
            energy_storage_power_station_id = row[0]
135
            meta_result = {"id": row[0],
136
                           "name": row[1],
137
                           "uuid": row[2],
138
                           "address": row[3],
139
                           "latitude": row[4],
140
                           "longitude": row[5],
141
                           "rated_capacity": row[6],
142
                           "rated_power": row[7],
143
                           "contact": contact_dict.get(row[8], None),
144
                           "cost_center": cost_center_dict.get(row[9], None),
145
                           "svg": row[10],
146
                           "description": row[11],
147
                           "phase_of_lifecycle": row[12],
148
                           "qrcode": 'energystoragepowerstation:' + row[2]}
149
150
        point_list = list()
151
        meter_list = list()