Merge branch 'develop'
commit
bd03f67c75
|
@ -80,62 +80,60 @@ class CostFileCollection:
|
|||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor = cnx.cursor()
|
||||
cnx_user_db = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor_user_db = cnx_user_db.cursor()
|
||||
|
||||
query = (" SELECT utc_expires "
|
||||
" FROM tbl_sessions "
|
||||
" WHERE user_uuid = %s AND token = %s")
|
||||
cursor.execute(query, (user_uuid, token,))
|
||||
row = cursor.fetchone()
|
||||
cursor_user_db.execute(query, (user_uuid, token,))
|
||||
row = cursor_user_db.fetchone()
|
||||
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
if cursor_user_db:
|
||||
cursor_user_db.close()
|
||||
if cnx_user_db:
|
||||
cnx_user_db.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
utc_expires = row[0]
|
||||
if datetime.utcnow() > utc_expires:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
if cursor_user_db:
|
||||
cursor_user_db.close()
|
||||
if cnx_user_db:
|
||||
cnx_user_db.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_SESSION_TIMEOUT')
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor.fetchone()
|
||||
cursor_user_db.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor_user_db.fetchone()
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
if cursor_user_db:
|
||||
cursor_user_db.close()
|
||||
if cnx_user_db:
|
||||
cnx_user_db.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
user_id = row[0]
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_historical_db)
|
||||
cursor = cnx.cursor()
|
||||
cnx_historical_db = mysql.connector.connect(**config.myems_historical_db)
|
||||
cursor_historical_db = cnx_historical_db.cursor()
|
||||
|
||||
add_values = (" INSERT INTO tbl_cost_files "
|
||||
" (file_name, uuid, upload_datetime_utc, status, file_object ) "
|
||||
" VALUES (%s, %s, %s, %s, %s) ")
|
||||
cursor.execute(add_values, (filename,
|
||||
file_uuid,
|
||||
datetime.utcnow(),
|
||||
'new',
|
||||
raw_blob))
|
||||
new_id = cursor.lastrowid
|
||||
cnx.commit()
|
||||
cursor.close()
|
||||
cnx.disconnect()
|
||||
cursor_historical_db.execute(add_values, (filename,
|
||||
file_uuid,
|
||||
datetime.utcnow(),
|
||||
'new',
|
||||
raw_blob))
|
||||
new_id = cursor_historical_db.lastrowid
|
||||
cnx_historical_db.commit()
|
||||
cursor_historical_db.close()
|
||||
cnx_historical_db.disconnect()
|
||||
|
||||
resp.status = falcon.HTTP_201
|
||||
resp.location = '/costfiles/' + str(new_id)
|
||||
|
|
|
@ -2,7 +2,7 @@ import base64
|
|||
import uuid
|
||||
import os
|
||||
from openpyxl.chart import PieChart, LineChart, Reference
|
||||
from decimal import *
|
||||
from decimal import Decimal
|
||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||
from openpyxl.drawing.image import Image
|
||||
from openpyxl import Workbook
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
import excelexporters.combinedequipmentbatch
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
import excelexporters.equipmentbatch
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
import excelexporters.equipmenttracking
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,8 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
import excelexporters.meterbatch
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
import excelexporters.metertracking
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
import excelexporters.shopfloorbatch
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
import excelexporters.storebatch
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from anytree import Node, AnyNode, LevelOrderIter
|
||||
from anytree import AnyNode, LevelOrderIter
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
import excelexporters.tenantbatch
|
||||
|
|
|
@ -283,7 +283,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.3.1 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
# update tbl_analog_value_latest
|
||||
delete_values = " DELETE FROM tbl_analog_value_latest WHERE point_id IN ( "
|
||||
|
@ -306,7 +305,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.3.2 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
try:
|
||||
# trim ", " at the end of string and then execute
|
||||
|
@ -315,7 +313,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.3.3 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
if len(energy_value_list) > 0:
|
||||
add_values = (" INSERT INTO tbl_energy_value (point_id, utc_date_time, actual_value) "
|
||||
|
@ -337,7 +334,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.4.1 of acquisition process: " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
# update tbl_energy_value_latest
|
||||
delete_values = " DELETE FROM tbl_energy_value_latest WHERE point_id IN ( "
|
||||
|
@ -361,7 +357,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.4.2 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
try:
|
||||
# trim ", " at the end of string and then execute
|
||||
|
@ -371,7 +366,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.4.3 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
if len(digital_value_list) > 0:
|
||||
add_values = (" INSERT INTO tbl_digital_value (point_id, utc_date_time, actual_value) "
|
||||
|
@ -393,7 +387,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.5.1 of acquisition process: " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
# update tbl_digital_value_latest
|
||||
delete_values = " DELETE FROM tbl_digital_value_latest WHERE point_id IN ( "
|
||||
|
@ -415,7 +408,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.5.2 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
try:
|
||||
# trim ", " at the end of string and then execute
|
||||
|
@ -424,7 +416,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.5.3 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
# update data source last seen datetime
|
||||
update_row = (" UPDATE tbl_data_sources "
|
||||
|
@ -436,7 +427,6 @@ def process(logger, data_source_id, host, port):
|
|||
except Exception as e:
|
||||
logger.error("Error in step 4.6 of acquisition process " + str(e))
|
||||
# ignore this exception
|
||||
pass
|
||||
|
||||
# sleep and continue the next iteration of the inner while loop
|
||||
time.sleep(config.interval_in_seconds)
|
||||
|
|
Loading…
Reference in New Issue