An error occurred while loading the file. Please try again.
-
Guillaume Perréal authored
cf. https://spdx.org/licenses/
52427210
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import os.path
import requests
import glob
import sys
import re
import unittest
class Handler:
# project
# site
# stamp
# name
def __init__ (self):
self.build_dir = ""
self.configure_path = ""
self.url = "https://cdash.orfeo-toolbox.org"
self.project = "OTB"
self.site = ""
self.stamp = ""
self.name = ""
self.buildid = ""
def GetConfigureFile (self , build_dir = "" ):
if build_dir == "":
build_dir = self.build_dir
build_dir = os.path.normpath(build_dir)
test_path = os.path.join( build_dir , "Testing/")
list_folder = os.listdir(test_path)
# print(list_folder)
configure_xml = ""
for folder in list_folder:
if folder == "Temporary" or folder == "TAG":
pass
configure_xml = os.path.join( test_path , folder , "Configure.xml" )
if os.path.exists( configure_xml ):
break
# print ( configure_xml )
if os.path.exists( configure_xml ):
self.configure_path = configure_xml
return True
print("Could not find the Configure.xml produced by ctest")
return False
def GetSite (self , build_dir ):
"""
Site is corresponding to the Name field in the xml. As there are other
"Name" in it, it might be hard to find the right one.
"""
return
def GetProject (self , build_dir ):
"""
Could not find the project name in the configure file.
"""
return
def GetName (self , build_dir = ""):
"""
This function is looking for the name information in the build tree
"""
if self.configure_path == "" and not self.GetConfigureFile( build_dir ):
print ("Error in GetName function, could not find Configure.xml")
return False
configure_file = open( self.configure_path, "r" )
content = configure_file.read()
configure_file.close()
name_regex = re.compile( "<Site.*BuildName=\"([0-9,-,_,A-Z,a-z]+)\".*<Configure>" , re.S )
# print (name_regex)
# print(content)
name = name_regex.search( content )
# print( name)
if name:
# print("name value \n" , name.group(1))
self.name = name.group(1)
return True
print("Could not retreive name value")
return False
def GetStamp (self , build_dir = "" ):
"""
This function is looking for the stamp information in the build tree
"""
if self.configure_path == "" and not self.GetConfigureFile( build_dir ):
print ("Error in GetStamp function, could not find Configure.xml")
return False
configure_file = open( self.configure_path, "r" )
content = configure_file.read()
configure_file.close()
stamp_regex = re.compile( "<Site.*BuildStamp=\"([0-9,-]+[A-Z,a-z,0-9]+)\".*<Configure>" , re.S )
# print (stamp_regex)
# print(content)
stamp = stamp_regex.search( content )
# print( stamp)
if stamp:
# print("Stamp value \n" , stamp.group(1))
self.stamp = stamp.group(1)
return True
print("Could not retreive stamp value")
return False
def GetBuildId (self, **kwargs):
"""
This function is returning the buildid. Dict can be passed with the
different informations
"""
site = self.site
stamp = self.stamp
name = self.name
site = self.site
for key , value in kwargs.items():
if key == "site":
site = value
if key == "stamp":
stamp == value
if key == "name":
name = value
if key == "site":
site = value
if ( site == "" or stamp == "" or name == "" or site == ""):
print( "Not enougth argument given for buildid request ")
# TODO
return
buildid_url = handler.url + "/api/v1/getbuildid.php?"
buildid_url += "project=" + self.project + "&"
buildid_url += "site=" + self.site + "&"
buildid_url += "stamp=" + self.stamp + "&"
buildid_url += "name=" + self.name
build_id_page = requests.get(buildid_url)
build_id_regex = re.compile( "<buildid>([0-9]+)</buildid>" )
buildid = build_id_regex.search( build_id_page.text )
if buildid:
self.buildid = buildid.group(1)
return True
else:
print("Error in recovering buildid")
return False
def GetBuildUrl (self):
"""
This function is returning the build url. It can be called only when
everything is set
"""
build_url = self.url
build_url +="/buildSummary.php?"
build_url += "buildid=" + self.buildid
return build_url
#TODO
class TestHandler(unittest.TestCase):
def test_GetConfigureFile (self):
def test_GetName (self):
def test_GetStamp (self):
def test_GetBuildId (self):
def test_GetBuildUrl (self):
if __name__ == "__main__":
"""
TODO :
documentation, header, test if it is possible.
the script aims only at recovering the build url
"""
# The script needs the site name and the project name.