# Path: src/utils/tool.py
# class DO(dict):
#     def __getattr__(self, name):
# def ip_check(ip):
# def email_check(email):
# def ParseMySQL(mysql, callback="dict"):
# def UploadImage2Upyun(FilePath, FileData, kwargs=PLUGINS['UpYunStorage']):
# def UploadRealFile2Upyun(file, imgurl, kwargs=PLUGINS['UpYunStorage']):
# def BaiduActivePush(pushUrl, original=True, callUrl=PLUGINS['BaiduActivePush']['callUrl']):
# def ChoiceColor():
# def TagRandomColor():
# def getIpArea(ip):
# def getIpArea2(ip):
# def get_current_timestamp():
# def timestamp_after_timestamp(timestamp=None, seconds=0, minutes=0, hours=0, days=0):
# def timestamp_to_timestring(timestamp, format='%Y-%m-%d %H:%M:%S'):
# def url_check(addr):
# def sql_safestring_check(string):
# def formatSize(bytes):
# def make_zipfile(zip_filename, zip_path, exclude=[]):
# def str_count(str):
#         M = kb / 1024
#             G = M / 1024


from config import SYSTEM
from .tool import logger, md5, get_current_timestamp
from functools import wraps
from flask import request, jsonify
            if req_timestamp - self._timestamp_expiration <= now_timestamp and req_timestamp + self._timestamp_expiration >= now_timestamp:
                return True
        return False

    def _check_req_accesskey_id(self, req_accesskey_id):
        """ 校验accesskey_id
        @pram req_accesskey_id str: 请求参数中的用户标识id
        """
        if req_accesskey_id in [ i['accesskey_id'] for i in self._accessKeys if "accesskey_id" in i ]:
            return True
        return False

    def _get_accesskey_secret(self, accesskey_id):
        """ 根据accesskey_id获取对应的accesskey_secret
        @pram accesskey_id str: 用户标识id
        """
        return [ i['accesskey_secret'] for i in self._accessKeys if i.get('accesskey_id') == accesskey_id ][0]

    def _sign(self, parameters):
        """ MD5签名
        @param parameters dict: 除signature外请求的所有查询参数(公共参数和私有参数)
        """
        if "signature" in parameters:
            parameters.pop("signature")
        accesskey_id = parameters["accesskey_id"]
        sortedParameters = sorted(parameters.items(), key=lambda parameters: parameters[0])
        canonicalizedQueryString = ''
        for (k, v) in sortedParameters:
            canonicalizedQueryString += k + "=" + v + "&"
        canonicalizedQueryString += self._get_accesskey_secret(accesskey_id)

# Path: src/utils/tool.py
# class DO(dict):
#     def __getattr__(self, name):
# def ip_check(ip):
# def email_check(email):
# def ParseMySQL(mysql, callback="dict"):
# def UploadImage2Upyun(FilePath, FileData, kwargs=PLUGINS['UpYunStorage']):
# def UploadRealFile2Upyun(file, imgurl, kwargs=PLUGINS['UpYunStorage']):
# def BaiduActivePush(pushUrl, original=True, callUrl=PLUGINS['BaiduActivePush']['callUrl']):
# def ChoiceColor():
# def TagRandomColor():
# def getIpArea(ip):
# def getIpArea2(ip):
# def get_current_timestamp():
# def timestamp_after_timestamp(timestamp=None, seconds=0, minutes=0, hours=0, days=0):
# def timestamp_to_timestring(timestamp, format='%Y-%m-%d %H:%M:%S'):
# def url_check(addr):
# def sql_safestring_check(string):
# def formatSize(bytes):
# def make_zipfile(zip_filename, zip_path, exclude=[]):
# def str_count(str):
#         M = kb / 1024
#             G = M / 1024


# Path: src/utils/Signature.py
from config import SYSTEM
from .tool import logger, md5, get_current_timestamp
from functools import wraps
from flask import request, jsonify

            if req_timestamp - self._timestamp_expiration <= now_timestamp and req_timestamp + self._timestamp_expiration >= now_timestamp:
                return True
        return False

    def _check_req_accesskey_id(self, req_accesskey_id):
        """ 校验accesskey_id
        @pram req_accesskey_id str: 请求参数中的用户标识id
        """
        if req_accesskey_id in [ i['accesskey_id'] for i in self._accessKeys if "accesskey_id" in i ]:
            return True
        return False

    def _get_accesskey_secret(self, accesskey_id):
        """ 根据accesskey_id获取对应的accesskey_secret
        @pram accesskey_id str: 用户标识id
        """
        return [ i['accesskey_secret'] for i in self._accessKeys if i.get('accesskey_id') == accesskey_id ][0]

    def _sign(self, parameters):
        """ MD5签名
        @param parameters dict: 除signature外请求的所有查询参数(公共参数和私有参数)
        """
        if "signature" in parameters:
            parameters.pop("signature")
        accesskey_id = parameters["accesskey_id"]
        sortedParameters = sorted(parameters.items(), key=lambda parameters: parameters[0])
        canonicalizedQueryString = ''
        for (k, v) in sortedParameters:
            canonicalizedQueryString += k + "=" + v + "&"
        canonicalizedQueryString += self._get_accesskey_secret(accesskey_id)

        signature = md5(canonicalizedQueryString).upper()