资讯 小学 初中 高中 语言 会计职称 学历提升 法考 计算机考试 医护考试 建工考试 教育百科
栏目分类:
子分类:
返回
空麓网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
空麓网 > 计算机考试 > 软件开发 > 后端开发 > Python

简单的xshell转moba的Python代码

Python 更新时间: 发布时间: 计算机考试归档 最新发布

简单的xshell转moba的Python代码

最新发现xshell用的有点问题,用moba的话好多会话需要导入,手动比较麻烦,这边参考别人的代码,修改了一下能够正常使用了,本人菜鸟,仅做参考。
参考大佬连接https://github.com/guugle/xshelltoMobaXterm

# -*- coding:utf-8 -*-import codecsimport osimport sysfrom configparser import ConfigParser# 将代码放在Session目录执行以下命令即可 完成转换# python xshelltomoba.py ./Session > xshell.mxtsessions# 只扫描特定文件suffix_name = '.xsh'# 这是密钥路径 请填对应的Session目录keyLocation = "C:Sessions"def joinString(infolist, keyLocation, iconId):    fullString = infolist[0] + ' (' + infolist[3] + ')' + "=#" + str(iconId) + "#0%" + infolist[1] + "%" + infolist[2] + "%" + infolist[        3] + "%%-1%-1%%%%%0%0%0%%%-1%0%0%0%%1080%%0%0%1%%0%%%%0%-1%-1%0#MobaFont%10%0%0%-1%15%236,236,236%30,30,30%180,180,192%0%-1%0%%xterm%-1%0%_Std_Colors_0_%80%24%0%1%-1%%%0%0%-1%0#0# #-1"    #这块后面的可以根据自己的moba测试导出 用notepad--打开 修改即可    print(fullString)    returndef convertFile(filePath, fileName):    config = ConfigParser()    config.read_file(codecs.open(filePath, "r", "utf-16"))    name = fileName.replace(".xsh", "")    ipAddr = config.get("CONNECTION", "Host")    port = config.get("CONNECTION", "Port")    username = config.get("CONNECTION:AUTHENTICATION", "UserName")    infoList = [name, ipAddr, port, username]    return infoListdef scanDirs(basePath):    global iconId    # print('basePath', basePath)    iconId = 41  # 图标ID    for dirRoot, dirs, dirFiles in os.walk(basePath):        if iconId == 41:            SubRep = ''        else:            break        print("[Bookmarks]")        print("SubRep=%s" % SubRep)        print("ImgNum=%d" % iconId)        iconId += 1        for fileName in dirFiles:            if fileName.endswith(suffix_name):                # print(dirRoot,111,os.sep,2222,fileName,333)                fileFullName = dirRoot + os.sep + fileName                # print(fileFullName)                infoList = convertFile(fileFullName, fileName)                joinString(infoList, keyLocation, iconId)if __name__ == '__main__':    xshellpath = keyLocation    scanDirs(xshellpath)
转载请注明:文章转载自 http://www.konglu.com/
本文地址:http://www.konglu.com/it/1097790.html
免责声明:

我们致力于保护作者版权,注重分享,被刊用文章【简单的xshell转moba的Python代码】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理,本文部分文字与图片资源来自于网络,转载此文是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请立即通知我们,情况属实,我们会第一时间予以删除,并同时向您表示歉意,谢谢!

我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2023 成都空麓科技有限公司

ICP备案号:蜀ICP备2023000828号-2