#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package PyMongoDataServer.GM.GMShell # # @todo:dbÖ´ÐÐGMÃüÁî # @author hxp # @date 2025-03-04 # @version 1.0 # # ÏêϸÃèÊö: dbÖ´ÐÐGMÃüÁî # #------------------------------------------------------------------------------- #"""Version = 2025-03-04 16:30""" #------------------------------------------------------------------------------- from DBCommon import GlobalFunctions from Common import mylog import Commands import os ## µ¼ÈëGMÈ«²¿ÃüÁî # @param importDir ·¾¶Ãû # @return None # @remarks º¯ÊýÏêϸ˵Ã÷. def ImportCommandAll(importDir): curPath = GlobalFunctions.getAppPath() for root, dirs, files in os.walk("%s\\%s"%(curPath, importDir)): for file in files: fileName = os.path.join(root, file) fileName = fileName.replace(curPath, "") fileName = fileName[1:len(fileName)] if fileName.find("__init__") >= 0: continue curFileList = fileName.split(".") fileName = curFileList[0] ext = curFileList[1] if ext not in ['pyc', 'py']: continue fileName = fileName.replace("\\",".") __import__(fileName) ImportCommandAll("GM\\Commands") ## º¯Êýµ÷Óà # @param curCallObj ʵÀý£¨¿ÉÄÜÊÇij¸öÎļþÃû£© # @param callName ʵÀýµÄij¸öÊôÐÔ # @return ÊôÐÔ def ParseNameGetObj(curCallObj, callName): callList = callName.split(".") if len(callList) <= 1: return None for curCallName in callList: if hasattr(curCallObj, curCallName) != True: #ÎÞ´ËÊôÐÔ return None curCallObj = getattr(curCallObj, curCallName) return curCallObj ## Íⲿµ÷ÓõĻñÈ¡ÊôÐÔ£¬ÇÒÊÇ¿ÉÒÔcallµÄ # @param curCallObj ʵÀý£¨¿ÉÄÜÊÇij¸öÎļþÃû£© # @param callName ʵÀýµÄij¸öÊôÐÔ # @return ¿ÉÒÔcallµÄÊôÐÔ # @remarks º¯ÊýÏêϸ˵Ã÷. def GetExecFunc(curCallObj, callName): curCallObj = ParseNameGetObj(curCallObj, callName) if curCallObj == None: return None if callable(curCallObj) != True: #²»¿Éµ÷Óà return None return curCallObj def ClientGMCommand(msgData): mylog.debug('¿ç·þDBÊÕµ½×Ó·þGMÃüÁî: %s' % msgData) cmdMsgList = msgData.get("cmdMsgList", []) if not cmdMsgList: return [] dbAnswerList = [] cmdName = cmdMsgList[0] callName = "%s.%s"%(cmdName, "OnCrossDBExec") callFunc = GetExecFunc(Commands, callName) if callFunc != None: callFunc(cmdMsgList[1:], dbAnswerList) return dbAnswerList def DBGMCommand(cmdMsg): mylog.debug('DBÊÕµ½GameServerµÄGMÃüÁî: %s' % cmdMsg) if not cmdMsg: return [] dbAnswerList = [] try: cmdMsgList = eval(cmdMsg) cmdName = cmdMsgList[0] callName = "%s.%s"%(cmdName, "OnDBExec") callFunc = GetExecFunc(Commands, callName) if callFunc != None: callFunc(cmdMsgList[1:], dbAnswerList) except: pass return dbAnswerList