python 中tar打包
for file in files: if not os.path.isfile(temp+"/"+file): print (temp+"/"+file) shutil.copyfile(root+"/"+file,temp+"/"+file) filePath=fileDir+tarRealName #停止安装目录下的node.js 进程 commend = nodeCommend %("stop",projectName+"*",projectName+"*",projectName+"*",projectName+"*") print "停止安装目录下的node.js 进程" print commend os.system(commend) print "结束关闭服务命令" time.sleep(5) # for root, dir, files in os.walk(install_home): # if projectName in root: # print root # shutil.rmtree(root) # for file in files: # if projectName in file: # os.remove(root + file) #删除旧的安装目录和tar.gz包 print "删除旧的安装目录" commend = "rm -fr %s%s" %(install_home,projectName+"*") time.sleep(5) print commend os.system(commend) shutil.copytree(filePath,install_home+tarRealName) time.sleep(10) tarName = tarRealName + ".tar.gz" tar = tarfile.open(fileDir+tarName,"w:gz") for root,dir,files in os.walk(filePath): kk = root.replace(fileDir,"")+"/" for file in files: fullpath = os.path.join(root,file) #,arcname=file tar.add(fullpath,arcname=kk+file) tar.close() # 复制tar.gz包到download_dir目录 os.makedirs(download_dir); msg = "复制到下载目录:"+download_dir; print msg shutil.copyfile(fileDir+ tarName, download_dir + "/" + tarName) #执行启动命令 # startcommend = "forever start --minUptime 1000 --spinSleepTime 1000 -l /home/appuser/app/%s/app.js" # startcommend = startcommend %(tarRealName,tarRealName,tarRealName,tarRealName) print "执行启动命令" print 'sh -x /home/jenkins/resin_jenkins/install/data_collect_init.sh start' os.system('sh -x /home/jenkins/resin_jenkins/install/data_collect_init.sh start') print "执行启动命令完成"
相关推荐
benico 2020-07-04
jackalwb 2020-06-21
wintelx 2020-06-11
神龙 2020-02-19
zmjzhangmj 2020-02-11
hickwu 2020-01-29
xue0zhiqiang 2013-05-31
sunln00 2019-12-15
安得情怀似旧时 2019-12-10
xiaohouye 2019-12-02
FruitDrop 2013-08-22
codedecode 2013-09-11
NeverAgain 2013-09-05
宁静致远 2015-02-03
studylinux 2016-12-22
snowboy00 2016-12-01
Proudoffaith 2019-10-28
doITwhat 2017-03-07
atb 2017-02-23
zealfish 2017-03-13
Rafema 2017-12-01
SIstvan 2019-05-18
eastnow 2019-05-18
hongsheyoumo 2019-09-03
鲵之风采 2017-06-29
朱登凯 2016-12-22