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数据模型)
公司成立之初,业务量较小,一个程序包揽了所有的业务逻辑,此时服务器数量少,上线简单,基本开发-测试-上线都是由开发人员完成. 随着业务量逐渐上升,功能增多,代码量增大,而单一功能上线需要重新编译整个程 ...
随机推荐
- Archlinux安装Picgo配置Typora
Typora堪称为markdown界的老大哥,其大名我们多有耳闻,所见即所的就是他的特点.但是在日常使用中,也经常会碰到一些特别的需求,比如:希望图片能够上传到云端. 怎么将markdown即时粘贴的 ...
- C#在Xp系统执行.exe程序的报错怎么查看原因
我的电脑---->管理---->事件查看器----->应用程序,查看错误来源
- redis五种数据结构详解
5.相关介绍和命令 5. redis是单线程+多路io复用技术 多路复用是指使用一个线程来检查多个文件描述符的就绪状态,比如调用select和poll函数,传入多个文件毛舒服,如果有一个文件描述符就绪 ...
- CPU cache知识 —— ARM架构cache结构和细节
cache如何寻址 处理器访问cache时,cache电路会将CPU地址进行解码,分成3个部分,分别是: offset: 用于某个cache line -- 字抽取: index: 用于匹配某个cac ...
- Asp.Net Core&Jaeger实现链路追踪
前言 随着应用愈发复杂,请求的链路也愈发复杂,微服务化下,更是使得不同的服务分布在不同的机器,地域,语言也不尽相同.因此需要借助工具帮助分析,跟踪,定位请求中出现的若干问题,以此来保障服务治理,链路追 ...
- 关于Mybatis-Plus中update()、updateById()方法的使用及null值的判断
使用场景说明: 在 Mybatis-Plus 的使用过程中,经常会遇对数据库更新的情况 更新常用方法:update().updateById() 问题:经常会遇见对 null 值的处理,对传入的实体参 ...
- org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
1.报错信息 org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: org.post ...
- MySQL 性能压测工具-sysbench,从入门到自定义测试项
sysbench是一个开源的.基于LuaJIT(LuaJIT 是 Lua 的即时编译器,可将代码直接翻译成机器码,性能比原生 lua 要高) 的.可自定义脚本的多线程基准测试工具,也是目前用得最多的 ...
- Graph Neural Network——图神经网络
本文是跟着李沐老师的论文精度系列进行GNN的学习的,详细链接请见:零基础多图详解图神经网络(GNN/GCN)[论文精读] 该论文的标题为<A Gentle Introduction to Gra ...
- ob-myfreemp3
网站 aHR0cDovL3Rvb2wubGl1bWluZ3llLmNuL211c2ljLw== 打开之后随便搜一个歌手的名字或歌曲(这里搜林俊杰) m/api/search,可以看到数据全在这里 全 ...