forked from INFERLab/gridlab-d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive_failed_tests.py
58 lines (48 loc) · 1.16 KB
/
archive_failed_tests.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
#!/usr/bin/python
import glob
import sys
import tarfile
import os
from zipfile import ZipFile
def main():
fname = sys.argv[1]
fp = open(fname,'r')
fnames = []
for line in fp:
fnames.append(line.rstrip())
fp.close()
createArchiveFiles(fnames)
def generatePathList(fnames):
pathlist = []
for fname in fnames:
globline = "./*/autotest/"+fname
temp = glob.glob(globline)
if len(temp) > 0:
pathname = temp[0]
pathlist.append(pathname)
return pathlist
def createArchiveFiles(fnames):
paths = generatePathList(fnames)
tar = tarfile.open("failed_tests.tar","w")
zfile = ZipFile("failed_tests.zip","w")
for path in paths:
tar.add(path)
for fname in os.listdir(path):
zfile.write(os.path.join(path,fname))
tar.close()
zfile.close()
def createTarFile(fnames):
paths = generatePathList(fnames)
tar = tarfile.open("failed_tests.tar","w")
for path in paths:
tar.add(path)
tar.close()
def createZipFile(paths):
paths = generatePathList(fnames)
zfile = ZipFile("failed_tests.zip","w")
for dirpath in paths:
for fname in os.listdir(dirpath):
zfile.write(os.path.join(path,fname))
zfile.close()
if __name__ == '__main__':
main()