python遍历仓库列表文件,提交代码

【python遍历仓库列表文件,提交代码】# -*- coding: utf-8 -*-
#argv[1]:清单文件
import os
import sys
def read_file(fileName):
for line in open(fileName):
pathSub = str(line).strip()
pathAbs = "/home/account/branchName/" + pathSub##必须是绝对路径
print("%s" % pathAbs)
os.system("cd %s ; git add ." % pathAbs )
os.system("cd %s ; git commit -m '[scm]:add mtk patch'" % pathAbs )
os.system("cd %s ; git push origin HEAD:refs/for/branchName" % pathAbs )
os.system("cd -")

if "__main__" == __name__:
if len(sys.argv) < 2:##sys.argv[0]是脚本文件本身,sys.argv[1]才是第一个参数
raise Exception('please input fileNamePath')
fileName = sys.argv[1]
read_file(fileName)
pass

    推荐阅读