hxp
4 天以前 c3bbd3b0263fc6c2127cd9f072f497f46f98758b
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/CommFunc.py
@@ -29,7 +29,9 @@
import binascii
import GameWorld
import traceback
import shutil
import zlib
import json
#---------------------------------------------------------------------
#全局变量
@@ -57,6 +59,23 @@
    for i in [j for j in range(hexStrLen) if j%2==0]:
        returnStr += chr(string.atoi(hexStr[i:i+2],16))
    return returnStr
def B2Hex(buf, upper=True, space=True):
    hex_str = binascii.b2a_hex(buf)
    # 转换为大写
    if upper:
        hex_str = hex_str.upper()
    # 每两个字符添加一个空格
    if space:
        hex_str = ' '.join(hex_str[i:i+2] for i in range(0, len(hex_str), 2))
    return hex_str
def GetPackHead(clientPack):
    if hasattr(clientPack, "Head"):
        headStr = "%02x%02x" % (clientPack.Head.Cmd, clientPack.Head.SubCmd)
    else:
        headStr = "%02x%02x" % (clientPack.Cmd, clientPack.SubCmd)
    return headStr.upper()
#获取异常信息#(try:...except:..GetExceptionInfo())
## 
@@ -414,6 +433,16 @@
        
    return data
def DelFolder(path, makeDir=False):
    ## 删除文件夹
    if os.path.exists(path):
        # 删除整个目录(包括自身)
        shutil.rmtree(path)
        if makeDir:
            # 重新创建空目录(保留原目录名)
            os.makedirs(path)
    return
#提示除零错误的EVAL
## 
#  @param 参数
@@ -425,6 +454,9 @@
    except ZeroDivisionError:
        return "Division is Zero"
def JsonDump(dumpObj):
    return json.dumps(dumpObj, ensure_ascii=False)
##生成指定文件(如par:r'E:\开发版本\Data\logo\formName1.log')
#def MakeAppointFile(par):
#    dir = os.path.dirname(par)  # 获得文件目录