| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Classes | Functions | Variables
validate_patch Namespace Reference

## Classes
class | PatchData
class | SavannahParser
| parse the More...
class | TempDir

## Functions
def | get_patch_info_x (patch)
def | get_patch_info (patch)
def | get_patch_data (file_id)
def | check_out_gaudi (path)
def | apply_patch (patch_data, path)
def | check (path)
def | build (path)
def | test (path)
def | main ()

## Variables
string | __author__ = "Marco Clemencic <marco.clemencic@cern.ch>"

## Function Documentation

def validate_patch.apply_patch | ( |  | patch_data,
|  |  | path
| ) |  |

Definition at line 147 of file validate_patch.py.

147 def apply_patch(patch_data, path):
148 proc = Popen(["patch", "-p0", "--batch"], cwd = path, stdin = PIPE)
149 proc.communicate(patch_data)
150 return proc.returncode
151
validate_patch.apply_patch
def apply_patch(patch_data, path)
Definition: validate_patch.py:147

def validate_patch.build | ( |  | path | ) |

Definition at line 155 of file validate_patch.py.

155 def build(path):
156 if "LBCONFIGURATIONROOT" in os.environ:
157 cmd = ["make",
158 "-f", os.path.join(os.environ["LBCONFIGURATIONROOT"], "data", "Makefile")]
159 if "use-distcc" in os.environ.get("CMTEXTRATAGS",""):
160 cmd += ["-j", "6"]
161 else:
162 cmd = ["cmt", "-pack=GaudiRelease", "broadcast", "cmt", "make", "all_groups"]
163 return Popen(" ".join(cmd),
164 shell = True,
165 cwd = path).wait()
validate_patch.build
def build(path)
Definition: validate_patch.py:155

def validate_patch.check | ( |  | path | ) |

Definition at line 152 of file validate_patch.py.

152 def check(path):
153 return Popen(" ".join(["cmt", "show", "projects"]), shell = True, cwd = path).wait()
154
validate_patch.check
def check(path)
Definition: validate_patch.py:152

def validate_patch.check_out_gaudi | ( |  | path | ) |

Definition at line 144 of file validate_patch.py.

144 def check_out_gaudi(path):
145 return Popen(["svn", "co", "http://svnweb.cern.ch/guest/gaudi/Gaudi/trunk", os.path.join(path, "Gaudi")]).wait()
146
validate_patch.check_out_gaudi
def check_out_gaudi(path)
Definition: validate_patch.py:144

def validate_patch.get_patch_data | ( |  | file_id | ) |

Definition at line 107 of file validate_patch.py.

107 def get_patch_data(file_id):
108 file_id = int(file_id)
109 return urlopen("https://savannah.cern.ch/patch/download.php?file_id=%d" % file_id).read()
110
validate_patch.get_patch_data
def get_patch_data(file_id)
Definition: validate_patch.py:107

def validate_patch.get_patch_info | ( |  | patch | ) |

Definition at line 100 of file validate_patch.py.

100 def get_patch_info(patch):
101 patch = int(patch)
102 parser = SavannahParser()
103 parser.feed(urlopen("https://savannah.cern.ch/patch/?%d" % patch).read())
104 parser.close()
105 return parser.patch
106
validate_patch.get_patch_info
def get_patch_info(patch)
Definition: validate_patch.py:100
validate_patch.SavannahParser
parse the
Definition: validate_patch.py:39

def validate_patch.get_patch_info_x | ( |  | patch | ) |

Definition at line 83 of file validate_patch.py.

83 def get_patch_info_x(patch):
84 patch = int(patch)
85 server = "savannah.cern.ch"
86 path = "/patch/?%d" % patch
87 conn = httplib.HTTPSConnection(server)
88 conn.request("GET", path)
89 r = conn.getresponse()
90 if r.status == 200:
91 pass
92 else:
93 raise RuntimeError(r.status, r.reason, "https://" + server + path)
94 parser = SavannahParser()
95 parser.feed(r.read())
96 parser.close()
97 conn.close()
98 return parser.patch
99
validate_patch.get_patch_info_x
def get_patch_info_x(patch)
Definition: validate_patch.py:83
validate_patch.SavannahParser
parse the
Definition: validate_patch.py:39

def validate_patch.main | ( |  | ) |

Definition at line 193 of file validate_patch.py.

193 def main():
194 logging.basicConfig()
195 if len(sys.argv) != 2:
196 print """Usage:
197 validate_patch.py <savannah patch id>
198 validate_patch.py file.patch
199 """
200 return 2
201 patch_id = sys.argv[1]
202 if os.path.isfile(patch_id):
203 patch_data = open(patch_id, "rb").read()
204 else:
205 patch = get_patch_info(patch_id)
206 patch_file_id = patch.files[0][1]
207 patch_data = get_patch_data(patch_file_id)
208
209 td = TempDir(prefix = patch_id + "-")
210 if check_out_gaudi(str(td)) != 0:
211 print "Sorry, problems checking out Gaudi. Try again."
212 return 0
213 top_dir = os.path.join(str(td), "Gaudi")
214 open(os.path.join(top_dir, patch_id) ,"wb").write(patch_data)
215
216 revision = -1
217 for l in Popen(["svn", "info", top_dir], stdout = PIPE).communicate()[0].splitlines():
218 if l.startswith("Revision:"):
219 revision = int(l.split()[-1])
220 break
221
222 actions = [(lambda path: apply_patch(patch_data, path), "application of the patch"),
223 (check, "check of the configuration"),
224 (build, "build"),
225 (test, "test"),
226 ]
227 failure = False
228 for action, title in actions:
229 if action(top_dir) != 0:
230 failure = title
231 break
232
233 if failure:
234 print "*** Patch %s failed during %s (using revision r%d) ***" % (patch_id, failure, revision)
235 return 1
236
237 print "*** Patch %s succeeded (using revision r%d) ***" % (patch_id, revision)
238 return 0
239
validate_patch.get_patch_data
def get_patch_data(file_id)
Definition: validate_patch.py:107
validate_patch.apply_patch
def apply_patch(patch_data, path)
Definition: validate_patch.py:147
compareRootHistos.action
string action
Definition: compareRootHistos.py:320
validate_patch.main
def main()
Definition: validate_patch.py:193
validate_patch.get_patch_info
def get_patch_info(patch)
Definition: validate_patch.py:100
validate_patch.TempDir
Definition: validate_patch.py:111
validate_patch.check_out_gaudi
def check_out_gaudi(path)
Definition: validate_patch.py:144

def validate_patch.test | ( |  | path | ) |

Definition at line 166 of file validate_patch.py.

166 def test(path):
167 cmd = ["cmt", "-pack=GaudiRelease", "TestProject"]
168 proc = Popen(" ".join(cmd),
169 stdout = PIPE,
170 shell = True,
171 cwd = path)
172 output = []
173 while proc.poll() is None:
174 chunk = proc.stdout.read(256)
175 output.append(chunk)
176 sys.stdout.write(chunk)
177 sys.stdout.flush()
178 chunk = proc.stdout.read(256)
179 output.append(chunk)
180 sys.stdout.write(chunk)
181 sys.stdout.flush()
182 if proc.returncode:
183 # immediately return in case of failure
184 return proc.returncode
185 # look for failures in the output
186 output = ("".join(output)).splitlines()
187 for l in output:
188 l = l.strip()
189 if ": FAIL" in l or ": ERROR" in l:
190 return 1
191 return 0
192
validate_patch.test
def test(path)
Definition: validate_patch.py:166

## Variable Documentation

string validate_patch.__author__ = "Marco Clemencic <marco.clemencic@cern.ch>"

Definition at line 10 of file validate_patch.py.