python自动发布
import os
import paramiko
baseconfig = {
"ip": "121.4.38.187",
"port": 22,
"username": "",
"password": "",
"localdir": "E:\\javawork\\moodapi\\target\\classes",
"remotedir": "/www/wwwroot/zshapi",
"startsplit": "target",
"exclude": [],
"include": ["Info"],
"fielExt": ".class",
"succExec": "",
"skipDircheck": False
}
# 遍历所有文件夹下的文件
def walkFiles(path, endpoint=None):
file_list = []
for root, dirs, files in os.walk(path):
for file in files:
file_path = os.path.join(root, file)
if endpoint:
if file_path.endswith(endpoint):
file_list.append(file_path)
else:
file_list.append(file_path)
return file_list
def getRemotedir(f):
if baseconfig["startsplit"] != "":
p = f.split(baseconfig["startsplit"])[1].replace("\\", "/")
return p
def checkExclude(file):
filename = os.path.split(file)[1]
filename = filename.lower()
for regstr in baseconfig["exclude"]:
if filename.__contains__(regstr.lower()):
return True
return False
def checkInclude(file):
filename = os.path.split(file)[1]
filename = filename.lower()
for regstr in baseconfig["include"]:
if filename.__contains__(regstr.lower()):
return True
return False
def upload(files):
if len(files) == 0:
return
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=baseconfig["ip"], port=baseconfig["port"], username=baseconfig["username"],
password=baseconfig["password"])
ssh.get_transport()
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
for f in files:
if checkExclude(f):
print("跳过:%s" % f)
continue
if len(baseconfig["include"]) > 0:
if checkInclude(f) == False:
continue
p = baseconfig["remotedir"] + getRemotedir(f)
if baseconfig["skipDircheck"] == False:
remotedir = os.path.split(p)[0]
stdin, stdout, stderr = ssh.exec_command("ls " + remotedir)
if stdout.readline() == '':
stdin, stdout, stderr = ssh.exec_command("mkdir -p " + remotedir)
stdout.readline()
print("上传:%s至%s" % (f, p))
sftp.put(f, p)
if baseconfig["succExec"] != "":
stdin, stdout, stderr = ssh.exec_command(baseconfig["succExec"])
stdout.readline()
ssh.close()
if __name__ == '__main__':
files = walkFiles(baseconfig["localdir"], endpoint=baseconfig["fielExt"])
upload(files)
python自动发布的更多相关文章
- Python自动发布Image service的实现
使用Python自动发布地图服务已经在上一篇博客中讲到,使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务,下面是利用Python自动发布Image service的实现. -- ...
- 测试开发Python培训:自动发布新浪微博-技术篇
测试开发Python培训:自动发布新浪微博-技术篇 在前面我们教大家如何登陆,大家需要先看自动登陆新浪微博(http://www.cnblogs.com/laoli0201/articles/48 ...
- gitlab+jenkins自动发布Python包到私有仓储
背景 有个私有仓储,地址为https://your.repo.com/pypi/ 代码存储在gitlab, 地址为https://gitlab.company.com/software.git CI为 ...
- Python + Selenium 自动发布文章(一):开源中国
https://blog.csdn.net/qq_28804275/article/details/80891949 https://blog.csdn.net/qq_28804275/article ...
- jenkins结合supervisor进行python程序发布后的自动重启
jenkins结合supervisor进行python程序发布后的自动重启 项目背景: 通过jenkins发布kvaccount.chinasoft.com站点的python服务端程序,业务部门同事需 ...
- 自动发布工具版本从python2升级成python3后遇到的种种问题(涉及paramiko,Crypto,zipfile等等)
从在公司实习到正式入职,一直还在被同事使用的是我写的一个自动发布工具.该工具的主要功能是:开发人员给出需要更新的代码包(zip格式),测试人员将该代码包部署到测服,这些代码包和JIRA数据库里的项目信 ...
- 解决GP服务产生的结果无法自动发布为地图服务的问题
在ArcGIS for Javascript API或REST API调用GP服务时,常常会遇到这样一种情况:GP服务运行以后,执行成功,也能够生成结果,然而结果并没有直接产生动态的地图服务供API调 ...
- fabric自动发布tomcat线上项目
现在公司的每个tomcat项目都有测试和生产两个环境,对于经常需要上线的tomcat项目,如用手工更新就非常耗费时间和人力.现用fabric开发了一个自动发布tomcat项目的脚本,该脚本已经在公司使 ...
- GeoServer自动发布地图服务
1 NetCDF气象文件自动发布案例 GeoServer是一个地理服务器,提供了管理页面进行服务发布,样式,切片,图层预览等一系列操作,但是手动进行页面配置有时并不满足业务需求,所以GeoServer ...
- Django实现自动发布(1数据模型)
公司成立之初,业务量较小,一个程序包揽了所有的业务逻辑,此时服务器数量少,上线简单,基本开发-测试-上线都是由开发人员完成. 随着业务量逐渐上升,功能增多,代码量增大,而单一功能上线需要重新编译整个程 ...
随机推荐
- Terminal(oh-my-zsh) 美化
如果你使用Mac进行开发,那么Terminal.app应该是你使用非常频繁的app了.初体验Terminal时你可能觉得单调乏味,阅读密密麻麻的内容也很费劲.但是如果你跟着我一起配置它,就会发现你平时 ...
- Marktext语法——Emoji表情大全
个人名片: 对人间的热爱与歌颂,可抵岁月冗长 Github:念舒_C.ying CSDN主页️:念舒_C.ying 个人博客 :念舒_C.ying People ️ ️ ️ ️ ♀️ ♀️ ♂ ...
- Kubernetes 1.25.4数据平面自带nginx负载均衡实现高可用
1.环境准备 要点: 1.使用一个FQDN统一作为API Server的接入点: 2.加入集群之前,每个节点都将该FQDN解析至第一个Master: 3.加入集群之后,每个Master节点将该FQDN ...
- 【DL论文精读笔记】VGGNet
VGGNet(Very Deep Convolutional Networks) 1.introduction ● 采用3x3的小卷积核应用在比较深的网络里 ● 结果不错,赢得了2014 Imagen ...
- Swing常用窗体
Swing常用窗体 Swing 主要具有以下特点: ( 1 )轻量级组件. ( 2 )可插入外观组件. 窗体作为Swing的应用程序中组件的承载体,处于非常重要的地位.Swing中常用的窗体包括JFr ...
- linux驱动移植
1.1 开发前准备 1.1.1 Linux 驱动(面向对象) 1).Linux 驱动框架 思想:写驱动的时候,只提供操作硬件设备的函数接口 文件存放磁盘: open ,read ,write ,clo ...
- 解决fpdf不能写入中文问题
安装依赖 pip3 install FPDF -i https://mirrors.aliyun.com/pypi/simple fpdf 原生是php调用的,不过他也提供了python的调用方式 示 ...
- Windows机器下VSCode安装及使用CmakeLists编译工程demo
使用VSCode, Mingw and Cmake写工程代码,从零开始写的那种,全过程分享...... 你若发现该帖中有待商榷的地方,还请指正赐教,先行拜谢了! 1 软件下载 1.1 vscode下载 ...
- volatile关键字在并发中有哪些作用?
作者:小牛呼噜噜 | https://xiaoniuhululu.com 计算机内功.JAVA源码.职业成长.项目实战.面试相关资料等更多精彩文章在公众号「小牛呼噜噜」 前言 读过笔者之前的一篇文章J ...
- SpringCloud Alibaba(三) - GateWay网关
1.基本环境搭建 1.1 依赖 <!-- Gatway 网关会和springMvc冲突,不能添加web依赖 --> <dependency> <groupId>or ...