forked from dasu23/e2ecoverage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcronScan.py
59 lines (55 loc) · 1.79 KB
/
cronScan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
import os
import sys
import time
from git.repo import Repo
import subprocess
from multiprocessing import Process
sys.path.append('.')
sys.path.append('./scripts')
import scripts.md_utils as md_utils
from gitlab import GitlabError, GitlabGetError
current_path = os.path.dirname(os.path.realpath(__file__))
parent_path = os.path.dirname(current_path)
if __name__ == '__main__':
start_time = time.time()
repo = Repo(current_path)
for i in range(5): # 拉取最新的代码
try:
os.system("git fetch --all")
os.system("git reset --hard origin/main")
break
except Exception as e:
print(f"拉取代码错误:{e}")
continue
cf = md_utils.getCaseFile()
iniProjects = cf.options('ProjectID')
print("iniProjects: ", iniProjects)
for i in iniProjects:
if '-ui' in i or '-anakin' in i:
print(i, " is skipped.")
continue
else:
if len(cf.options(i)) != 0:
print(i, " is skipped.")
try:
md_utils.generateBadges(i, current_path)
except GitlabError as e:
print("gitlab err: {0}".format(e))
os.system(f"cd badges")
print("current_path: ", current_path)
os.system(f"ls {current_path}/badges/")
os.system("git status")
os.system("git add .")
repo.index.commit(f'cronScan {start_time}')
print("start push。。。")
for i in range(5):
try:
res = subprocess.Popen("git push", shell=True, stdout=subprocess.PIPE)
print(res.stdout.read())
res.stdout.close()
break
except Exception as e:
print(f"push错误:{e}")
time.sleep(2)
print('scan issue done...')