-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
executable file
·32 lines (24 loc) · 902 Bytes
/
util.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
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# logging.basicConfig(level = logging.INFO,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s',filename='app.log')
logger = logging.getLogger('logutil')
file_time_map = {}
def build_response(code=0, message='', data=''):
res = {}
res['code'] = code
res['message'] = message
res['data'] = data
return res
def build_ok_response(message='', data=''):
return build_response(0, message=message, data=data)
def build_err_response(message='', data=''):
return build_response(400, message=message, data=data)
def build_exception_response(e):
logger.error(e)
return build_err_response(message='err, %s, %s' % (type(e), e.message))
def not_empty(s):
if s:
return False
if 'None' == s:
return False
return True