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

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