12345678910111213141516171819202122232425262728293031323334353637383940 |
- import base64
- import time
- from configs.logging import logger
- def decode_user(username, password):
- if not username or not password:
- return '' , ''
- try:
- u = base64.b64decode(username).decode('utf-8')
- p = base64.b64decode(password).decode('utf-8')
- return u, p
- except Exception as e:
- logger.error(e)
- return username, password
- def encode_base64(str):
- return base64.encodebytes(str.encode('utf-8')).decode('utf-8')
- def decode_base64(str):
- return base64.decodebytes(str.encode('utf-8')).decode('utf-8')
- def byte_conversion(size):
- if size < 1024:
- return str("%.1f"%size) + 'B'
- elif size < 1024 * 1024:
- return str("%.1f"%(size/1024)) + 'KB'
- elif size < 1024 * 1024 * 1024:
- return str("%.1f"%(size/1024/1024)) + 'MB'
- else:
- return str("%.1f"%(size/1024/1024/1024)) + 'GB'
- def get_cmd_parameter(jvm_param):
- cmd_parameter = ''
- if jvm_param is not None and jvm_param != '':
- cmd_parameter += '-j "' + jvm_param + '" '
- return cmd_parameter
|