import os
import paramiko
import time
import xlrd
import pandas as pd
class ServerSsh:
def __int__(self):
pass
def ssh_server(self, ip, user, user_passwd):
"""
远程服务器模块
:param ip: 服务器ip
:param user: 登录用户
:param user_passwd: 密码
:return: 返回登录会话对象
"""
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh_client.connect(hostname=ip, port="22", username=user, password=user_passwd)
return ssh_client
except Exception as e:
print(ip + '密码错误,登录失败')
ssh_client.close()
return '登录失败'
def read_xsxl(self, file_path, sheet_name):
"""
读excel文件,返回sheet页内容
:param file_path: 文件路径
:param sheet_name: sheet名称
:return: 返回excel结果
"""
try:
df = pd.read_excel(file_path, sheet_name=sheet_name)
return df
except Exception as e:
return "文件读取失败"
def ssh_cmd(self, server_ip, user, user_passwd, cmd, root_passwd):
"""
执行命令
:param server_ip: 服务器ip
:param user: 登录用户
:param user_passwd: 登录密码
:param cmd: 执行命令
:param root_passwd: root密码
:return:返回执行结果
"""
ssh_client = self.ssh_server(server_ip, user, user_passwd)
if ssh_client != '登录失败':
if user != 'root':
ssh = ssh_client.invoke_shell()
time.sleep(0.1)
# 切换root用户
ssh.send('su - root\n')
buff = ''
# 拼出返回结果
while not buff.endswith('Password: '):
resp = ssh.recv(9999)
buff += resp.decode('utf-8')
ssh.send(root_passwd + '\n')
# 拼出返回结果
buff = ''
while "root@" not in buff:
resp = ssh.recv(9999)
buff += resp.decode('utf-8')
# 拼出返回结果
ssh.send(cmd + '\n')
buff = ''
while "root@" not in buff:
resp = ssh.recv(9999)
buff += resp.decode('utf-8')
result = buff
ssh.close()
return result
else:
stdin, stdout, stderr = ssh_client.exec_command(cmd)
result = stdout.read()
ssh_client.close()
return result
else:
return server_ip +'命令执行失败'
if __name__ == '__main__':
a = ServerSsh()
flie_path = 'C:\\Users\\admin\\PycharmProjects\\pythonProject\\venv\\Scripts\\zznode\\serveripinfo.xlsx'
sheet_name = 'Sheet1'
user = 'test'
passwd = '123456'
cmd = 'touch 1.txt'
root_passwd = '12345678'
if '文件读取失败' == date_obj:
print('文件读取失败')
else:
date_obj = a.read_xsxl(flie_path, sheet_name)
for ip in date_obj['服务器信息']:
result = a.ssh_cmd(server_ip=ip, user=user, user_passwd=passwd, cmd=cmd, root_passwd=root_passwd)
print(ip + result)
之所以会出现error C2377: 'BOOL' : redefinition; typedef cannot be overloaded with any othe这样的问题,主要是因为引用的头文件写的不对#ifndef CopyDirectory#define CopyDirectory……#endif应改为:#ifndef CopyDirectory_H#defin_bool redefinition
HashMap对应1.7、1.8版本的区别首先说一下HashMapJDK1.7链表用的是头插法、JDK1.8用的是尾插法HashMap的扩容方式在1.7与1.8中也存在差异扩容后数据存储位置的计算方式也不一首先说一下HashMapJDK1.7链表用的是头插法、JDK1.8用的是尾插法为什么要改变链表的插入方式,在1.7的时候采用的是链表的方式存储的相同hash值的元素,采用头插法速度相对较快(链表的存储空间与数组不同链表的存储空间是不连续的,需要先找到头节点在根据nextnode指向的地址找到下一个节_1.7头插法和1.8尾插法区别
转成实体类:Xtxmb xtxmb = JSONArray.parseObject(json字符串).toJavaObject(Xtxmb.class);转成实体类集合:List<XmGys> list = JSONArray.parseArray(json字符串,XmGys.class)_json.parseobject实体内集合
I/O 工具主要是提供数据和文件读取的函数,Pandas支持常用的文本格式数据,二进制数据,SQL数据。常用函数: 读写csv read_csv 和 to_csv 读写Excel read_excel 和 to_excel 读写数据库 read_sql 和 to..._财经数据预处理pandas工具包里的,属于读写文件命令的是
jlink 固件修复_附件 jlink.exe 即可自动更新固件
Git修改之前的注释提交注释_git 修改上一步提交的代码的注释
506.Examine the following ALTER command;SQL> ALTER DISKGROUP dgroup1 UNDROP DISKS;What is the purpose of the command?A. It cancels all pending disk drops within the disk group.B. It adds previ
【超实用课程内容】 本课程从pytorch安装开始讲起,从基本计算结构到深度学习各大神经网络,全程案例代码实战,一步步带大家入门如何使用深度学习框架pytorch,玩转pytorch模型训练等所有知识点。最后通过 kaggle 项目:猫狗分类,实战pytorch深度学习工具。 【课程如何观看?】 PC端:https://edu.csd..._pytorh从入门到实战
VMIC-5595是专为光纤网络设计的光纤交换机,可以与5565光纤反射内存配合使用搭建星型光纤网络。VMIC-5595有8个连接口,可按用户需求配置成单模、多模类型。VMIC-5595可以自动旁路有故障或不连贯的反射内存节点。VMIC反射内存实时网络 VMIC反射内存卡 VMIPCI-5565 GE 1553 429 VMIC反射内存优惠供货价格优势明显。反射内存 反射内存卡 光纤反射内存卡 光纤反射内存口 反射内存网 反射内存实时网络 反射内存集线器VMIACC-5595网络集线器 ACC559
本文会持续更新,如果对您有帮助的话可以点点关注,双击本人2021年蓝桥杯C++B组国二,今年转战Java,并整理此文,希望能够对大家有所帮助,第一次写这么长的文章,可能有的地方写的不是很好,还请大家多多谅解,我会持续进行改进并且更新。第七届蓝桥杯国赛题解第八届蓝桥杯国赛题解第九届蓝桥杯国赛题解第十届蓝桥杯国赛题解第十一届蓝桥杯国赛题解注:内容为蓝桥杯来自蓝桥杯决赛特训营蓝桥杯Jvav基础知识总结输入和输出输入Scanner s = new Scanner(System.in);
前边讲了ByteBuf、Channel、Unsafe、ChannelPipeline、ChannelHandler等核心的类。这篇来学习学习EventLoop(EventLoopGroup)——Netty的线程。Netty的线程模型是经过精心的设计,既提高了框架的并发性能,又能在很大程度上避免死锁,局部还是实现了无锁化设计。非常值得学习的。 一,Reactor线程模型..._failed to open a new selector
1、安装Python因为SCons是用Python编写的,所以你必须在使用SCons之前安装好Python。你在安装Python之前,应该注意查看Python是否在你的系统里已经可用了(在系统的命令行中运行python -V或python --version)。$python -VPython 2.5.1在一个Windows系统里,C:\>python -VPython 2