Code Duplication    Length = 19-19 lines in 2 locations

reports/dashboard.py 1 location

@@ 239-257 (lines=19) @@
236
                              " FROM tbl_energy_categories "
237
                              " ORDER BY id ", )
238
        rows_energy_categories = cursor_system.fetchall()
239
        if rows_energy_categories is None or len(rows_energy_categories) == 0:
240
            if cursor_system:
241
                cursor_system.close()
242
            if cnx_system:
243
                cnx_system.disconnect()
244
245
            if cursor_energy:
246
                cursor_energy.close()
247
            if cnx_energy:
248
                cnx_energy.disconnect()
249
250
            if cursor_billing:
251
                cursor_billing.close()
252
            if cnx_billing:
253
                cnx_billing.disconnect()
254
255
            raise falcon.HTTPError(falcon.HTTP_404,
256
                                   title='API.NOT_FOUND',
257
                                   description='API.ENERGY_CATEGORY_NOT_FOUND')
258
        energy_category_dict = dict()
259
        for row_energy_category in rows_energy_categories:
260
            if row_energy_category[0] in energy_category_set:

reports/tenantbill.py 1 location

@@ 150-168 (lines=19) @@
147
                              " FROM tbl_energy_categories "
148
                              " ORDER BY id ", )
149
        rows_energy_categories = cursor_system.fetchall()
150
        if rows_energy_categories is None or len(rows_energy_categories) == 0:
151
            if cursor_system:
152
                cursor_system.close()
153
            if cnx_system:
154
                cnx_system.disconnect()
155
156
            if cursor_energy:
157
                cursor_energy.close()
158
            if cnx_energy:
159
                cnx_energy.disconnect()
160
161
            if cursor_billing:
162
                cursor_billing.close()
163
            if cnx_billing:
164
                cnx_billing.disconnect()
165
166
            raise falcon.HTTPError(falcon.HTTP_404,
167
                                   title='API.NOT_FOUND',
168
                                   description='API.ENERGY_CATEGORY_NOT_FOUND')
169
        energy_category_dict = dict()
170
        for row_energy_category in rows_energy_categories:
171
            if row_energy_category[0] in energy_category_set: