-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
43 lines (33 loc) · 1.22 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from flask import Flask, redirect, url_for, request, render_template, session, logging
from flask_session.__init__ import Session
import json,os,sys, random, string, re, logging, time, datetime, requests
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SECRET_KEY'] = 'asjhd4895647664745464138537262ds00cd'
sess = Session()
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
###########################################################################
# other functions
def gen_guid(size=6, chars=string.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for x in range(size))
def format_date(inbound_str):
tmpstr = inbound_str.replace("T", " ")
tmpstr2 = tmpstr.replace(".000Z", "")
return tmpstr2
def check_admin_role(role_data):
admin_bool='n'
for i in range(0, len(role_data)):
tmpstr = role_data[i]['label']
if 'Administrator' in tmpstr:
admin_bool='y'
return admin_bool
def log_msg(oidc, msg):
try:
email = oidc.user_getfield('email')
ip=request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
except:
email=''
ip=''
app.logger.info(email + " : " + ip + " : " + msg)