设备管理程序 v0.0.1.0, 终于出了一个基础版本,… …
两个字典的键值判断
辛亏用的是Python 这个编码时间大大缩短了
对已有的命令行进行GUI 化
from typing import Optional
import PySide6.QtCore
import PySide6.QtWidgets
from cmd_ui import Ui_MainWindow
from PySide6.QtWidgets import *
from PySide6.QtCore import *
from PySide6.QtGui import *
import sys
from paramiko import *
import timedef Except(func):def WARRPER(self):try:func(self)except:QMessageBox.information(self,"Except","exec error")return WARRPERclass MainWindow(QMainWindow):def __init__(self, parent=None) -> None:super().__init__(parent)self.ui = Ui_MainWindow()self.ui.setupUi(self)self.ui.Get.clicked.connect(self.link)self.log=self.ui.textBrowser.appendself.ui.cmd_1.clicked.connect(self.cmd1)self.ui.cmd_2.clicked.connect(self.cmd2)self.ui.cmd_3.clicked.connect(self.cmd3)self.ui.cmd_4.clicked.connect(self.cmd4)self.ui.cmd_5.clicked.connect(self.cmd5)@Exceptdef link(self):self.ui.List1.clear()self.ui.List2.clear()self.ui.List3.clear()self.ui.List4.clear()self.ui.List5.clear()self.__ssh__=SSHClient()self.__ssh__.set_missing_host_key_policy(AutoAddPolicy())self.__ssh__.connect(hostname=self.ui.ip.text(),port=22,username="root",password="root")stdin,stdout,stderr = self.__ssh__.exec_command("source /etc/profile && fun -h")res=list(map(lambda x: x.replace('\r', ''),stdout.read().decode().split('\n')))self.log(stderr.read().decode())Res=res[1:-2]self.ui.List1.addItems(Res)self.ui.List2.addItems(Res)self.ui.List3.addItems(Res)self.ui.List4.addItems(Res)self.ui.List5.addItems(Res)print(Res)def ShowLog(self,cmd,msg):self.log("[ %-8s ] %s: %s"%(time.strftime("%Y%m%d %H:%M:%S",time.localtime()),cmd,msg))@Exceptdef cmd1(self):CMD="source /etc/profile && fun %s %s"%(self.ui.List1.currentText(),self.ui.cmd_one.text())stdin,stdout,stderr=self.__ssh__.exec_command(CMD)self.ShowLog(self.ui.List1.currentText(),stdout.read().decode())self.ShowLog(self.ui.List1.currentText(),stderr.read().decode())@Exceptdef cmd2(self):stdin,stdout,stderr=self.__ssh__.exec_command("source /etc/profile && fun %s %s"%(self.ui.List2.currentText(),self.ui.cmd_two.text()))self.ShowLog(self.ui.List2.currentText(),stdout.read().decode())self.ShowLog(self.ui.List2.currentText(),stderr.read().decode())@Exceptdef cmd3(self):stdin,stdout,stderr=self.__ssh__.exec_command("source /etc/profile && fun %s %s"%(self.ui.List3.currentText(),self.ui.cmd_three.text()))self.ShowLog(self.ui.List3.currentText(),stdout.read().decode())self.ShowLog(self.ui.List3.currentText(),stderr.read().decode())@Exceptdef cmd4(self):stdin,stdout,stderr=self.__ssh__.exec_command("source /etc/profile && fun %s %s\r\n"%(self.ui.List4.currentText(),self.ui.cmd_four.text()))self.ShowLog(self.ui.List4.currentText(),stdout.read().decode())self.ShowLog(self.ui.List4.currentText(),stderr.read().decode())@Exceptdef cmd5(self):stdin,stdout,stderr=self.__ssh__.exec_command("source /etc/profile && fun %s %s"%(self.ui.List5.currentText(),self.ui.cmd_five.text()))self.ShowLog(self.ui.List5.currentText(),stdout.read().decode())self.ShowLog(self.ui.List5.currentText(),stderr.read().decode())if __name__ == "__main__":app=QApplication(sys.argv)w=MainWindow()w.show()app.exit(app.exec())
调试命令行的简易GUI化,面向工程人员
一套工具集,面向监控,和维护人员的使用
连上板卡测试,主题功能已没有问题 V0.0.1.2
这套工具的数据库于板卡保存的数据库完全一致,互为备份,设备的参数备份有一个保障
之后会在网管参数专有页面进行配置,一设备IP和编号和修改时间作为数据库修改的方法