fixed PEP8 warnings in API

pull/63/head
13621160019@163.com 2021-08-25 12:01:14 +08:00
parent f39ad7f039
commit b389887b50
17 changed files with 86 additions and 82 deletions

View File

@ -584,7 +584,8 @@ def worker(space):
energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict() energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict()
energy_category_id = row_value[1] energy_category_id = row_value[1]
actual_value = row_value[2] actual_value = row_value[2]
energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_category_id] = actual_value energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][
energy_category_id] = actual_value
except Exception as e: except Exception as e:
error_string = "Error in step 14 of space_energy_input_category.worker " + str(e) error_string = "Error in step 14 of space_energy_input_category.worker " + str(e)
if cursor_energy_db: if cursor_energy_db:
@ -769,7 +770,8 @@ def worker(space):
energy_child_space_hourly[child_space_id][current_datetime_utc] = dict() energy_child_space_hourly[child_space_id][current_datetime_utc] = dict()
energy_category_id = row_energy_value[1] energy_category_id = row_energy_value[1]
actual_value = row_energy_value[2] actual_value = row_energy_value[2]
energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] = actual_value energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] \
= actual_value
except Exception as e: except Exception as e:
error_string = "Error in step 19 of space_energy_input_category.worker " + str(e) error_string = "Error in step 19 of space_energy_input_category.worker " + str(e)
if cursor_energy_db: if cursor_energy_db:

View File

@ -587,7 +587,8 @@ def worker(space):
energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict() energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict()
energy_item_id = row_value[1] energy_item_id = row_value[1]
actual_value = row_value[2] actual_value = row_value[2]
energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_item_id] = actual_value energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_item_id] \
= actual_value
except Exception as e: except Exception as e:
error_string = "Error in step 14 of space_energy_input_item.worker " + str(e) error_string = "Error in step 14 of space_energy_input_item.worker " + str(e)
if cursor_energy_db: if cursor_energy_db:

View File

@ -286,8 +286,8 @@ def worker(space):
energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict() energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict()
energy_category_id = row_value[1] energy_category_id = row_value[1]
actual_value = row_value[2] actual_value = row_value[2]
energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_category_id] = \ energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][
actual_value energy_category_id] = actual_value
except Exception as e: except Exception as e:
error_string = "Error in step 5 of space_energy_output_category.worker " + str(e) error_string = "Error in step 5 of space_energy_output_category.worker " + str(e)
if cursor_energy_db: if cursor_energy_db:
@ -361,7 +361,8 @@ def worker(space):
energy_child_space_hourly[child_space_id][current_datetime_utc] = dict() energy_child_space_hourly[child_space_id][current_datetime_utc] = dict()
energy_category_id = row_energy_value[1] energy_category_id = row_energy_value[1]
actual_value = row_energy_value[2] actual_value = row_energy_value[2]
energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] = actual_value energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] \
= actual_value
except Exception as e: except Exception as e:
error_string = "Error in step 7 of space_energy_output_category.worker " + str(e) error_string = "Error in step 7 of space_energy_output_category.worker " + str(e)
if cursor_energy_db: if cursor_energy_db:

View File

@ -3,9 +3,9 @@ from falcon_cors import CORS
from falcon_multipart.middleware import MultipartMiddleware from falcon_multipart.middleware import MultipartMiddleware
from core import energyflowdiagram, privilege, textmessage, distributioncircuit, virtualmeter, \ from core import energyflowdiagram, privilege, textmessage, distributioncircuit, virtualmeter, \
costcenter, point, knowledgefile, meter, gsmmodem, tariff, user, storetype, timezone, \ costcenter, point, knowledgefile, meter, gsmmodem, tariff, user, storetype, timezone, \
costfile, offlinemeterfile, version, contact, emailserver, combinedequipment, datasource, equipment, tenant, shopfloor, \ costfile, offlinemeterfile, version, contact, emailserver, combinedequipment, datasource, equipment, tenant, \
webmessage, distributionsystem, store, emailmessage, tenanttype, wechatmessage, space, gateway, offlinemeter, \ shopfloor, webmessage, distributionsystem, store, emailmessage, tenanttype, wechatmessage, space, gateway, \
rule, energycategory, sensor, energyitem, notification, menu offlinemeter, rule, energycategory, sensor, energyitem, notification, menu
from reports import advancedreport from reports import advancedreport
from reports import distributionsystem as distributionsystemreport from reports import distributionsystem as distributionsystemreport
from reports import energyflowdiagram as energyflowdiagramreport from reports import energyflowdiagram as energyflowdiagramreport

View File

@ -89,8 +89,8 @@ class CombinedEquipmentCollection:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'description' in new_values['data'].keys() and \ if 'description' in new_values['data'].keys() and \
@ -307,8 +307,8 @@ class CombinedEquipmentItem:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'description' in new_values['data'].keys() and \ if 'description' in new_values['data'].keys() and \
@ -629,7 +629,7 @@ class CombinedEquipmentEquipmentItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, eid): def on_options(req, resp, id_, eid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, eid): def on_delete(req, resp, id_, eid):
@ -1503,7 +1503,7 @@ class CombinedEquipmentMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1692,7 +1692,7 @@ class CombinedEquipmentOfflineMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1881,7 +1881,7 @@ class CombinedEquipmentVirtualMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):

View File

@ -497,7 +497,7 @@ class DistributionCircuitPointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):

View File

@ -89,8 +89,8 @@ class EquipmentCollection:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'description' in new_values['data'].keys() and \ if 'description' in new_values['data'].keys() and \
@ -320,8 +320,8 @@ class EquipmentItem:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'description' in new_values['data'].keys() and \ if 'description' in new_values['data'].keys() and \
@ -1347,7 +1347,7 @@ class EquipmentMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1534,7 +1534,7 @@ class EquipmentOfflineMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1722,7 +1722,7 @@ class EquipmentVirtualMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):

View File

@ -147,8 +147,8 @@ class MeterCollection:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'energy_item_id' in new_values['data'].keys() and \ if 'energy_item_id' in new_values['data'].keys() and \
@ -595,8 +595,8 @@ class MeterItem:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
@ -955,7 +955,7 @@ class MeterPointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):

View File

@ -133,8 +133,8 @@ class OfflineMeterCollection:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
@ -518,8 +518,8 @@ class OfflineMeterItem:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']

View File

@ -377,7 +377,7 @@ class SensorPointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):

View File

@ -628,7 +628,7 @@ class ShopfloorEquipmentItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, eid): def on_options(req, resp, id_, eid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, eid): def on_delete(req, resp, id_, eid):
@ -809,7 +809,7 @@ class ShopfloorMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -989,7 +989,7 @@ class ShopfloorOfflineMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1169,7 +1169,7 @@ class ShopfloorPointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):
@ -1336,7 +1336,7 @@ class ShopfloorSensorItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, sid): def on_options(req, resp, id_, sid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, sid): def on_delete(req, resp, id_, sid):
@ -1516,7 +1516,7 @@ class ShopfloorVirtualMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):

View File

@ -925,7 +925,7 @@ class SpaceCombinedEquipmentItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, eid): def on_options(req, resp, id_, eid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, eid): def on_delete(req, resp, id_, eid):
@ -1092,7 +1092,7 @@ class SpaceEquipmentItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, eid): def on_options(req, resp, id_, eid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, eid): def on_delete(req, resp, id_, eid):
@ -1272,7 +1272,7 @@ class SpaceMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1454,7 +1454,7 @@ class SpaceOfflineMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1634,7 +1634,7 @@ class SpacePointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):
@ -1801,7 +1801,7 @@ class SpaceSensorItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, sid): def on_options(req, resp, id_, sid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, sid): def on_delete(req, resp, id_, sid):
@ -1967,7 +1967,7 @@ class SpaceShopfloorItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, sid): def on_options(req, resp, id_, sid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, sid): def on_delete(req, resp, id_, sid):
@ -2133,7 +2133,7 @@ class SpaceStoreItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, tid): def on_options(req, resp, id_, tid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, tid): def on_delete(req, resp, id_, tid):
@ -2299,7 +2299,7 @@ class SpaceTenantItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, tid): def on_options(req, resp, id_, tid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, tid): def on_delete(req, resp, id_, tid):
@ -2479,7 +2479,7 @@ class SpaceVirtualMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):

View File

@ -150,15 +150,15 @@ class StoreCollection:
if 'contact_id' not in new_values['data'].keys() or \ if 'contact_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['contact_id'], int) or \ not isinstance(new_values['data']['contact_id'], int) or \
new_values['data']['contact_id'] <= 0: new_values['data']['contact_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_CONTACT_ID') description='API.INVALID_CONTACT_ID')
contact_id = new_values['data']['contact_id'] contact_id = new_values['data']['contact_id']
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'description' in new_values['data'].keys() and \ if 'description' in new_values['data'].keys() and \
@ -718,7 +718,7 @@ class StoreMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -898,7 +898,7 @@ class StoreOfflineMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1078,7 +1078,7 @@ class StorePointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):
@ -1245,7 +1245,7 @@ class StoreSensorItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, sid): def on_options(req, resp, id_, sid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, sid): def on_delete(req, resp, id_, sid):
@ -1425,7 +1425,7 @@ class StoreVirtualMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):

View File

@ -195,15 +195,15 @@ class TenantCollection:
if 'contact_id' not in new_values['data'].keys() or \ if 'contact_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['contact_id'], int) or \ not isinstance(new_values['data']['contact_id'], int) or \
new_values['data']['contact_id'] <= 0: new_values['data']['contact_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_CONTACT_ID') description='API.INVALID_CONTACT_ID')
contact_id = new_values['data']['contact_id'] contact_id = new_values['data']['contact_id']
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
if 'description' in new_values['data'].keys() and \ if 'description' in new_values['data'].keys() and \
@ -815,7 +815,7 @@ class TenantMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -995,7 +995,7 @@ class TenantOfflineMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):
@ -1175,7 +1175,7 @@ class TenantPointItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, pid): def on_options(req, resp, id_, pid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, pid): def on_delete(req, resp, id_, pid):
@ -1342,7 +1342,7 @@ class TenantSensorItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, sid): def on_options(req, resp, id_, sid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, sid): def on_delete(req, resp, id_, sid):
@ -1522,7 +1522,7 @@ class TenantVirtualMeterItem:
@staticmethod @staticmethod
def on_options(req, resp, id_, mid): def on_options(req, resp, id_, mid):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_delete(req, resp, id_, mid): def on_delete(req, resp, id_, mid):

View File

@ -174,8 +174,8 @@ class VirtualMeterCollection:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']
@ -701,8 +701,8 @@ class VirtualMeterItem:
if 'cost_center_id' not in new_values['data'].keys() or \ if 'cost_center_id' not in new_values['data'].keys() or \
not isinstance(new_values['data']['cost_center_id'], int) or \ not isinstance(new_values['data']['cost_center_id'], int) or \
new_values['data']['cost_center_id'] <= 0: new_values['data']['cost_center_id'] <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_COST_CENTER_ID') description='API.INVALID_COST_CENTER_ID')
cost_center_id = new_values['data']['cost_center_id'] cost_center_id = new_values['data']['cost_center_id']

View File

@ -334,10 +334,11 @@ class Reporting:
} }
# export result to Excel file and then encode the file to base64 string # export result to Excel file and then encode the file to base64 string
result['excel_bytes_base64'] = excelexporters.metersubmetersbalance.export(result, result['excel_bytes_base64'] = \
master_meter['name'], excelexporters.metersubmetersbalance.export(result,
reporting_period_start_datetime_local, master_meter['name'],
reporting_period_end_datetime_local, reporting_period_start_datetime_local,
period_type) reporting_period_end_datetime_local,
period_type)
resp.body = json.dumps(result) resp.body = json.dumps(result)

View File

@ -554,16 +554,15 @@ class Reporting:
result['reporting_period']['increment_rate_in_kgce'] = \ result['reporting_period']['increment_rate_in_kgce'] = \
(result['reporting_period']['total_in_kgce'] - result['base_period']['total_in_kgce']) / \ (result['reporting_period']['total_in_kgce'] - result['base_period']['total_in_kgce']) / \
result['base_period']['total_in_kgce'] \ result['base_period']['total_in_kgce'] if result['base_period']['total_in_kgce'] > Decimal(0.0) else None
if result['base_period']['total_in_kgce'] > Decimal(0.0) else None
result['reporting_period']['total_in_kgce_per_unit_area'] = \ result['reporting_period']['total_in_kgce_per_unit_area'] = \
result['reporting_period']['total_in_kgco2e'] / tenant['area'] if tenant['area'] > 0.0 else None result['reporting_period']['total_in_kgco2e'] / tenant['area'] if tenant['area'] > 0.0 else None
result['reporting_period']['increment_rate_in_kgco2e'] = \ result['reporting_period']['increment_rate_in_kgco2e'] = \
(result['reporting_period']['total_in_kgco2e'] - result['base_period']['total_in_kgco2e']) / \ (result['reporting_period']['total_in_kgco2e'] - result['base_period']['total_in_kgco2e']) / \
result['base_period']['total_in_kgco2e'] \ result['base_period']['total_in_kgco2e'] if result['base_period']['total_in_kgco2e'] > Decimal(0.0)\
if result['base_period']['total_in_kgco2e'] > Decimal(0.0) else None else None
result['parameters'] = { result['parameters'] = {
"names": parameters_data['names'], "names": parameters_data['names'],