#! /usr/bin/env python
# -*- coding:utf-8 -*-
import os
#zip压缩模块
import zipfile
#上传模块
import paramiko
remoteIp = '192.168.1.100'
remotePort = '22'
remoteUser = 'root'
remotePw = '123456'
def Compress(dirs, path):
kZip = zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED)
for dir in dirs:
for dirpath, dirnames, filenames in os.walk(dir):
for file in filenames:
kZip.write(os.path.join(dirpath,file)) #绝对路径
kZip.close()
print('compress finished')
def Upload_file(local_path, remote_path):
try:
kParamiko = paramiko.Transport(remoteIp,remotePort)
print('Transport Success!')
kParamiko.connect(username = remoteUser, password = remotePw)
print('co