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


Python MyUtil.splitCmd方法代码示例

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


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

示例1: enterCmd

# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import splitCmd [as 别名]
 def enterCmd(self,cmd):
     """登录成功,进入登录解释行
     """
     try:
         if 'cmd=uploads' in cmd:
             self.uploadFile(cmd,MyUtil.splitCmd(cmd))
         else:
             cmd = _3ds.Encrypt(cmd)
             self.sock.sendall(cmd)
             self.response = self.sock.recv(sockSize)
             result = self.response
             result = result.decode('utf-8').encode("gbk")
             print result
     except:
         print "enterCmd Error:"+str(sys.exc_info()[0])+str(sys.exc_info()[1])
开发者ID:derekzhan,项目名称:ioms,代码行数:17,代码来源:IomClient.py

示例2: handle

# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import splitCmd [as 别名]
 def handle(self):
     try:
         while True:
             cmd = self.request.recv(sockSize)
             cmd = _3ds.Decrypt(cmd)
             print "recevied command: "+str(cmd)
             cmds = MyUtil.splitCmd(cmd)
             keys = cmds.keys()
             if len(keys) > 0:
                 if cmds['cmd'] in fm.keys():
                     self.request.sendall(str(fm[cmds['cmd']](cmds, cmd)))
                     break
                 else:
                     self.request.sendall("-1")
                     break
             else:
                 self.request.sendall("-1")
                 break
         self.request.close()
     except:
         self.request.close()
         writeLog("CmdServer.handle:" + str(sys.exc_info()[0]) + str(sys.exc_info()[1]))
         print "CmdServer.handle:" + str(sys.exc_info()[0]) + str(sys.exc_info()[1])
开发者ID:derekzhan,项目名称:ioms,代码行数:25,代码来源:CMDServer.py

示例3: handle

# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import splitCmd [as 别名]
    def handle(self):
        user = ""
        userIp = ""
        print str(time.strftime("[%Y-%m-%d_%H:%M:%S]进入IOMS核心模块")).decode("utf-8").encode("gbk")
        while True:
            reStr = u""
            recvData = None
            try:
                recvData = self.request.recv(sockSize)
                recvData = _3ds.Decrypt(recvData).decode("gbk").encode("utf-8")
                userIp = str(self.client_address[0])
            except:
                writeLog("IOMServer.recvData Error:" + str(sys.exc_info()[0]) + str(sys.exc_info()[1]))
                writeLog("|" + userIp + "| " + user + "Connection break. 断开连接!")
                if user in socketMap.keys():
                    socketMap.pop(user)
                break
            if not recvData:
                # 因有时会发生一直读取到空消息的问题,所以先改成让服务休息一会避免CPU占用而卡死
                time.sleep(1)
                continue
            cmds = MyUtil.splitCmd(recvData)
            keys = cmds.keys()
            if not (("parm=checkUser" in recvData) or ("cmd=login" in recvData)):
                p = str(time.strftime("[%Y-%m-%d_%H:%M:%S]Receviced command.收到命令: ") + recvData)
                print p.decode("utf-8").encode("gbk")
                writeLog("|" + userIp + "| " + user + " " + recvData)
            else:
                recvData = "login"
                # continue
            # try:
            if "cmd" in keys and cmds["cmd"] == "login":
                """登录"""
                if "user" in keys and "pwd" in keys:
                    user = str(cmds["user"])
                    re = self.login(self.request, cmds["user"], cmds["pwd"])
                    if re == -1:
                        p = str(
                            time.strftime(
                                "[%Y-%m-%d_%H:%M:%S]Receviced command.收到命令"
                                + userIp
                                + "| "
                                + user
                                + "Login failed! 登录失败!连接关闭!"
                            )
                        )
                        print p.decode("utf-8").encode("gbk")
                        writeLog("|" + userIp + "| " + user + "Login failed 登录失败!连接关闭!")
                        self.request.close()
                        reStr = "Login failed.登录失败."
                        break
                    elif re == 1:
                        p = str(
                            time.strftime(
                                "[%Y-%m-%d_%H:%M:%S]Receviced command.收到命令"
                                + userIp
                                + "| "
                                + user
                                + " : Login sucess! 连接!"
                            )
                        )
                        print p.decode("utf-8").encode("gbk")
                        writeLog("|" + userIp + "| " + user + " 连接!")
                        reStr = "Login sucess.登录成功."

            elif "cmd" in keys and "uploads" == cmds["cmd"] and "file" in keys:
                """上传文件,把客户端接收到的数据直接转发到AutoUpdateServer上去"""
                writeLog("|" + userIp + "| " + user + " 请求上传文件!" + cmds["file"])
                sock = getSock(UpdateServerIP, int(UpdateServerPort))
                sock.sendall("au," + recvData)
                self.request.sendall(sock.recv(sockSize))
                print "Begin updaload...开始上传。。。".decode("utf-8").encode("gbk")
                i = 0
                while True:
                    data = self.request.recv(10485760)
                    print "Receviced files...接受文件中。。。。".decode("utf-8").encode("gbk"), "  ", i
                    i += 1
                    if not data:
                        reStr = "Receviced complete.上传完成."
                        print "All File Receviced complete.文件全部接受完成".decode("utf-8").encode("gbk")
                        break
                    if str(data).endswith("4423718C61C4E8A4362D955BBC7B9711"):
                        data = data[: len(data) - len("4423718C61C4E8A4362D955BBC7B9711")]
                        reStr = "Receviced complete.上传完成."
                        print "All File Receviced complete.文件全部接受完成".decode("utf-8").encode("gbk")
                        break
                    while len(data) > 0:
                        intSent = sock.send(data)
                        data = data[intSent:]
                        print "Sending...发送文件中。。。".decode("utf-8").encode("gbk"), "  ", intSent
                    print "File Receviced complete.接受文件完成".decode("utf-8").encode("gbk")
                    # time.sleep(1)
                reStr = "Receviced complete.上传完成."
                sock.close()
                writeLog("|" + userIp + "| " + user + " 上传文件完成")
                if reStr == "":
                    reStr = "Receviced failed.上传失败."

            elif "cmd" in keys and "dir" == cmds["cmd"]:
                """查看可以下载的文件"""
#.........这里部分代码省略.........
开发者ID:derekzhan,项目名称:ioms,代码行数:103,代码来源:IomServer.py

示例4: updateSelf

# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import splitCmd [as 别名]
def updateSelf(cmd,cmdStr):
    """2011-01-13 update self
    """
    try:
        print "updateself step 1"
        path = MyUtil.cur_file_dir()
        cmdStr = "cmd=downloads,file=update4Linux.zip,updateself=updateself,path="+path
        cmd = MyUtil.splitCmd(cmdStr)
        reStr = downloads(cmd, cmdStr)
        if reStr[0] == int('-1'):
            return reStr[1]
        rs =""
        print "updateself step 2 ", reStr
        if reStr[0] == int('2'):
            """解压update.zip至当前目录下的update.tmp中"""
            zipout = MyUtil.UnZIP("update4Linux.zip", "update.tmp")
            print "updateself step 3 unzip. zipout = ",zipout[0]
            if zipout[0] == '1':
                rs += zipout[1]
            '''检验update.tmp/config.ini是否存在'''
            if os.path.isfile("update.tmp/config.ini"):
                print "updateself step 4 check config.ini"
                '''读取config.ini的配置'''
                cf = ConfigParser.ConfigParser()
                cf.read("update.tmp/config.ini")
                md5Files = cf.get("filemd5","md5Files")
                uAgent = cf.get("main", "updateAgentService")
                uCMDServer = cf.get("main", "updateCMDServer")
                uRunPro = cf.get("main", "RunPrograms")
                uremove = cf.get("main", "removeFiles")

                '''对需要的文件做MD5验证,通过则下一步'''
                md5FilePath = (MyUtil.cur_file_dir()+"/update.tmp/")
                _md5Files = md5Files.split(',')
                MD5Flag = False
                if _md5Files != None and md5FilePath != None and _md5Files != '' and md5FilePath != '':
                    for filemd5 in _md5Files:
                        '''循环比对指定文件的MD5码值'''
                        fileName,rightMD5 = filemd5.split(":")
                        filePath = md5FilePath + fileName
                        ret = string.split(md5sum(filePath))
                        if ret[0] == "-1" or ret[0] == "-2":
                            MD5Flag = False
                        elif ret[1] == rightMD5:
                            MD5Flag = True
                    print "updateself step 5 check MD5, MD5Flag =",MD5Flag
                    if MD5Flag:
                        '''根据配置运行'''
                        print "updateself step 6 update Agent4Linux =",uAgent.upper()
                        if uAgent.upper() == "YES":
                            '''如果要更新Agent,则先杀掉进程,调用自更新脚本复制文件和启动服务'''
                            _allpronameid = ServerInfo.getAllProcessNameId()
                            for _name,_id in _allpronameid:
                                if _name.upper() == "Agent4Linux".upper():
                                    p = ServerInfo.Kill_Process_pid(_id)
                                    str1 = "find process "+str(_name)+", pid = "+str(_id)+", kill it!\n"
                                    rs += str1
                            try:
                                os.chmod(MyUtil.cur_file_dir()+"/updateself.sh",0755)
                                p = os.popen(MyUtil.cur_file_dir()+"/updateself.sh")
                                str1 = p.readlines()
                                for s in str1:
                                    rs += s
                                p.close()
                            except:
                                print "updateAgent4LinuxError:"+str(sys.exc_info()[0]) + str(sys.exc_info()[1])
                                pass
                        print "updateself step 7, RunProcess= ",uRunPro.upper()
                        if uRunPro.upper() <> "NO" :
                            """如果不是NO,则把要运行的程序绝对路径和执行名放在参数中,以逗号隔开
                            """
                            try:
                                Pros = uRunPro.split(",")
                                for Pro in Pros:
                                    p = os.popen(Pro)
                                    str1 = p.readlines()
                                    for s in str1:
                                        rs += s
                                    p.close()                                     
                            except:
                                pass
                        
                        print "updateself step 8, RemoveFile= ",uremove.upper()
                        """如果不是NO,则把要删除的文件绝对路径放在参数中,以逗号隔开
                        """
                        if uremove.upper() <> "NO":
                            try:
                                removefiles = uremove.split(",")
                                for rfile in removefiles:
                                    shutil.rmtree(rfile)
                            except:
                                pass
                        
                        print "updateself step 9, Update CMDServer4Linux = ",uCMDServer.upper()
                        if uCMDServer.upper() == "YES":
                            '''如果需要更新CMDServer4Linux,调用updateCMDServer.sh完成更新'''
#                            _allpronameid = getAllProcessNameId()
#                            for _name,_id in _allpronameid:
#                                if _name.upper() == "CMDServer4Linux".upper():
#                                    p = Kill_Process_pid(_id)
#.........这里部分代码省略.........
开发者ID:derekzhan,项目名称:ioms,代码行数:103,代码来源:AgentUpdateClient.py

示例5: updateSelf

# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import splitCmd [as 别名]
def updateSelf(cmd,cmdStr):
    """2011-01-13 update self
    """
    try:
        #print "updateself step 1"
        path = MyUtil.cur_file_dir()
        cmdStr = "cmd=downloads,file=update.zip,updateself=updateself,path="+path
        cmd = MyUtil.splitCmd(cmdStr)
        reStr = downloads(cmd, cmdStr)
        if reStr[0] == int('-1'):
            return reStr[1]
        rs =""
        #print "updateself step 2 ", reStr
        if reStr[0] == int('2'):
            """解压update.zip至当前目录下的update.tmp中"""
            zipout = MyUtil.UnZIP("update.zip", "update.tmp")
            #print "updateself step 3 unzip. zipout = ",zipout[0]
            if zipout[0] == '1':
                rs += zipout[1]
            '''检验update.tmp/config.ini是否存在'''
            if os.path.isfile("update.tmp/config.ini"):
                #print "updateself step 4 check config.ini"
                '''读取config.ini的配置'''
                cf = ConfigParser.ConfigParser()
                cf.read("update.tmp\\config.ini")
                md5Files = cf.get("filemd5","md5Files")
                uAgent = cf.get("main", "updateAgentService")
                uCMDServer = cf.get("main", "updateCMDServer")
                uRunPro = cf.get("main", "RunPrograms")
                uremove = cf.get("main", "removeFiles")

                '''对需要的文件做MD5验证,通过则下一步'''
                md5FilePath = (MyUtil.cur_file_dir()+"\\update.tmp\\")
                _md5Files = md5Files.split(',')
                MD5Flag = False
                if _md5Files != None and md5FilePath != None and _md5Files != '' and md5FilePath != '':
                    for filemd5 in _md5Files:
                        '''循环比对指定文件的MD5码值'''
                        fileName,rightMD5 = filemd5.split(":")
                        filePath = md5FilePath + fileName
                        ret = string.split(md5sum(filePath))
                        if ret[0] == "-1" or ret[0] == "-2":
                            MD5Flag = False
                        elif ret[1] == rightMD5:
                            MD5Flag = True
                    #print "updateself step 5 check MD5, MD5Flag =",MD5Flag
                    if MD5Flag:
                        '''根据配置运行'''
                        #print "updateself step 6 update AgentService =",uAgent.upper()
                        if uAgent.upper() == "YES":
                            '''如果要更新Agentservices,则先杀掉进程,卸载服务,然后复制文件'''
                            '''再安装服务,运行服务。'''
                            p = os.popen(ServerInfo.sysDir()+'\\taskkill /IM AgentService.exe /F')
                            str1 = p.readlines()
                            for s in str1:
                                rs += s.decode('gbk').encode("utf-8")
                            p.close()                         
                            p = os.popen(ServerInfo.sysDir()+'\\sc delete AgentService 2>&1')
                            str1 = p.readlines()
                            for s in str1:
                                rs += s.decode('gbk').encode("utf-8")
                            p.close()                             
                            try:
                                shutil.copy2(md5FilePath+"AgentService.exe", os.path.join(MyUtil.cur_file_dir()+"\\AgentService.exe"))
                            except:
                                #print "AgentService copy Error.",sys.exc_info()[0],sys.exc_info()[1]
                                pass
                            try:
                                shutil.copy2(md5FilePath+"w9xpopen.exe", os.path.join(MyUtil.cur_file_dir()+"\\w9xpopen.exe"))
                            except:
                                pass
                            try:
                                shutil.copy2(md5FilePath+"MSVCR71.dll", os.path.join(MyUtil.cur_file_dir()+"\\MSVCR71.dll"))
                            except:
                                pass
                            try:
                                shutil.copy2(md5FilePath+"setCfg.exe", os.path.join(MyUtil.cur_file_dir()+"\\setCfg.exe"))
                            except:
                                pass
                            
                            p = os.popen("setCfg.exe 2>&1")
                            str1 = p.readlines()
                            for s in str1:
                                rs += s.decode('gbk').encode("utf-8")
                            p.close()                             
                            p = os.popen(MyUtil.cur_file_dir()+"\\AgentService.exe -install 2>&1")
                            str1 = p.readlines()
                            for s in str1:
                                rs += s.decode('gbk').encode("utf-8")
                            p.close()                             
                            p = os.popen(ServerInfo.sysDir()+"\\sc config AgentService start= auto")
                            str1 = p.readlines()
                            for s in str1:
                                rs += s.decode('gbk').encode("utf-8")
                            p.close()                             
                            p = os.popen(ServerInfo.sysDir()+"\\sc start AgentService")
                            str1 = p.readlines()
                            for s in str1:
                                rs += s.decode('gbk').encode("utf-8")
                            p.close()                             
#.........这里部分代码省略.........
开发者ID:derekzhan,项目名称:ioms,代码行数:103,代码来源:AgentUpdateClient.py


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