当前位置: 首页>>代码示例>>Python>>正文


Python Utility.base56_encode方法代码示例

本文整理汇总了Python中utility.Utility.base56_encode方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.base56_encode方法的具体用法?Python Utility.base56_encode怎么用?Python Utility.base56_encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.Utility的用法示例。


在下文中一共展示了Utility.base56_encode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import base56_encode [as 别名]
class InternalServer:
    def __init__(self, ip='0.0.0.0', port=9096 ,log_level=logging.DEBUG):


        self.ip   = ip
        self.port = port

        self.author  = __author__
        self.version = __version__

        self.file_path = os.path.realpath(__file__)
        self.dir_path  = os.path.dirname(self.file_path)

        # the database
        self.database = Database()

        self.utility = Utility()


        # mark system start time
        self.system_initialized = datetime.now()


        # set the logger
        self.log_level = logging.DEBUG
        self.log_path = 'Server.log'

        self.logger = logging.getLogger('Server')
        self.logger.setLevel(self.log_level)

        # create a handler for write the log to file.
        fh = logging.FileHandler(self.log_path)
        fh.setLevel(self.log_level)

        # create a handler for print the log info on console.
        ch = logging.StreamHandler()
        ch.setLevel(self.log_level)

        # set the log format
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        # add the handlers to logger
        self.logger.addHandler(fh)
        self.logger.addHandler(ch)

        #################
        #API
        #################
        @bottle.route('/api0/create/license', method="POST")
        def api_create_license():
            response = {}
            response['result']  = 'error'
            response['license'] = ''

            try:
                self.logger.debug('handle a request: /api0/create/license ')   
                # get the data
                post_data = bottle.request.body.getvalue()
                self.logger.debug('handle the request data: %s' %(post_data))
                '''
                    {
                        "logo"   : "xxx",
                        "name"   : "xxx"
                    }
                '''
                post_data_json = json.loads(post_data)

                # check must params
                if not post_data_json.has_key('logo'):
                    response['result'] = 'error'
                    response['message'] = 'need param: logo.'
                    return "%s" %(json.dumps(response)) 

                if not post_data_json.has_key('name'):
                    response['result'] = 'error'
                    response['message'] = 'need param: name.'
                    return "%s" %(json.dumps(response)) 

                if not isinstance(post_data_json['logo'], basestring):
                    response['result'] = 'error'
                    response['message'] = 'The type error, the param: logo type should be string.'
                    return "%s" %(json.dumps(response)) 

                if not isinstance(post_data_json['name'], basestring):
                    response['result'] = 'error'
                    response['message'] = 'The type error, the param: name type should be string.'
                    return "%s" %(json.dumps(response)) 

                # create license by now time
                now = time.time() - 1430000000
                now *= 1000
            
                now = int(now)
                self.logger.debug('[api_create_license] base value:%s.' %(now))

                #ret, code62 = self.utility.base62_encode(now)
                ret, code62 = self.utility.base56_encode(now)
                if ret != 'success':
#.........这里部分代码省略.........
开发者ID:moonflower,项目名称:biubiuServer2,代码行数:103,代码来源:internal_api.py


注:本文中的utility.Utility.base56_encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。