diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-07-18 13:08:48 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-07-19 12:24:50 +0100 |
commit | 73cf0335c463758379765fa5f26a4484afaca8a0 (patch) | |
tree | eed499207c71f925dfad21d1c4e58cbb1ec22d53 /meta/classes/tinderclient.bbclass | |
parent | 7b2c67874e03bc378c6def5cf1558238134e1b61 (diff) | |
download | poky-73cf0335c463758379765fa5f26a4484afaca8a0.tar.gz |
Remove a number of unneeded import os/bb calls
The bb and os modules are always imported so having these extra import calls
are a waste of space/execution time. They also set a bad example for people
copy and pasting code so clean them up.
(From OE-Core rev: 7d674820958be3a7051ea619effe1a6061d9cbe2)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/tinderclient.bbclass')
-rw-r--r-- | meta/classes/tinderclient.bbclass | 98 |
1 files changed, 43 insertions, 55 deletions
diff --git a/meta/classes/tinderclient.bbclass b/meta/classes/tinderclient.bbclass index 1027c7cef4..e57bc48c3b 100644 --- a/meta/classes/tinderclient.bbclass +++ b/meta/classes/tinderclient.bbclass | |||
@@ -55,22 +55,22 @@ def tinder_format_http_post(d,status,log): | |||
55 | 55 | ||
56 | # the variables we will need to send on this form post | 56 | # the variables we will need to send on this form post |
57 | variables = { | 57 | variables = { |
58 | "tree" : data.getVar('TINDER_TREE', d, True), | 58 | "tree" : d.getVar('TINDER_TREE', True), |
59 | "machine_name" : data.getVar('TINDER_MACHINE', d, True), | 59 | "machine_name" : d.getVar('TINDER_MACHINE', True), |
60 | "os" : os.uname()[0], | 60 | "os" : os.uname()[0], |
61 | "os_version" : os.uname()[2], | 61 | "os_version" : os.uname()[2], |
62 | "compiler" : "gcc", | 62 | "compiler" : "gcc", |
63 | "clobber" : data.getVar('TINDER_CLOBBER', d, True) or "0", | 63 | "clobber" : d.getVar('TINDER_CLOBBER', True) or "0", |
64 | "srcdate" : data.getVar('SRCDATE', d, True), | 64 | "srcdate" : d.getVar('SRCDATE', True), |
65 | "PN" : data.getVar('PN', d, True), | 65 | "PN" : d.getVar('PN', True), |
66 | "PV" : data.getVar('PV', d, True), | 66 | "PV" : d.getVar('PV', True), |
67 | "PR" : data.getVar('PR', d, True), | 67 | "PR" : d.getVar('PR', True), |
68 | "FILE" : data.getVar('FILE', d, True) or "N/A", | 68 | "FILE" : d.getVar('FILE', True) or "N/A", |
69 | "TARGETARCH" : data.getVar('TARGET_ARCH', d, True), | 69 | "TARGETARCH" : d.getVar('TARGET_ARCH', True), |
70 | "TARGETFPU" : data.getVar('TARGET_FPU', d, True) or "Unknown", | 70 | "TARGETFPU" : d.getVar('TARGET_FPU', True) or "Unknown", |
71 | "TARGETOS" : data.getVar('TARGET_OS', d, True) or "Unknown", | 71 | "TARGETOS" : d.getVar('TARGET_OS', True) or "Unknown", |
72 | "MACHINE" : data.getVar('MACHINE', d, True) or "Unknown", | 72 | "MACHINE" : d.getVar('MACHINE', True) or "Unknown", |
73 | "DISTRO" : data.getVar('DISTRO', d, True) or "Unknown", | 73 | "DISTRO" : d.getVar('DISTRO', True) or "Unknown", |
74 | "zecke-rocks" : "sure", | 74 | "zecke-rocks" : "sure", |
75 | } | 75 | } |
76 | 76 | ||
@@ -82,7 +82,7 @@ def tinder_format_http_post(d,status,log): | |||
82 | # we only need on build_status.pl but sending it | 82 | # we only need on build_status.pl but sending it |
83 | # always does not hurt | 83 | # always does not hurt |
84 | try: | 84 | try: |
85 | f = file(data.getVar('TMPDIR',d,True)+'/tinder-machine.id', 'r') | 85 | f = file(d.getVar('TMPDIR',True)+'/tinder-machine.id', 'r') |
86 | id = f.read() | 86 | id = f.read() |
87 | variables['machine_id'] = id | 87 | variables['machine_id'] = id |
88 | except: | 88 | except: |
@@ -103,12 +103,11 @@ def tinder_build_start(d): | |||
103 | by posting our name and tree to the build_start.pl script | 103 | by posting our name and tree to the build_start.pl script |
104 | on the server. | 104 | on the server. |
105 | """ | 105 | """ |
106 | from bb import data | ||
107 | 106 | ||
108 | # get the body and type | 107 | # get the body and type |
109 | content_type, body = tinder_format_http_post(d,None,None) | 108 | content_type, body = tinder_format_http_post(d,None,None) |
110 | server = data.getVar('TINDER_HOST', d, True ) | 109 | server = d.getVar('TINDER_HOST', True ) |
111 | url = data.getVar('TINDER_URL', d, True ) | 110 | url = d.getVar('TINDER_URL', True ) |
112 | 111 | ||
113 | selector = url + "/xml/build_start.pl" | 112 | selector = url + "/xml/build_start.pl" |
114 | 113 | ||
@@ -128,7 +127,7 @@ def tinder_build_start(d): | |||
128 | 127 | ||
129 | # now we will need to save the machine number | 128 | # now we will need to save the machine number |
130 | # we will override any previous numbers | 129 | # we will override any previous numbers |
131 | f = file(data.getVar('TMPDIR', d, True)+"/tinder-machine.id", 'w') | 130 | f = file(d.getVar('TMPDIR', True)+"/tinder-machine.id", 'w') |
132 | f.write(report) | 131 | f.write(report) |
133 | 132 | ||
134 | 133 | ||
@@ -136,12 +135,10 @@ def tinder_send_http(d, status, _log): | |||
136 | """ | 135 | """ |
137 | Send this log as build status | 136 | Send this log as build status |
138 | """ | 137 | """ |
139 | from bb import data | ||
140 | |||
141 | 138 | ||
142 | # get the body and type | 139 | # get the body and type |
143 | server = data.getVar('TINDER_HOST', d, True ) | 140 | server = d.getVar('TINDER_HOST', True) |
144 | url = data.getVar('TINDER_URL', d, True ) | 141 | url = d.getVar('TINDER_URL', True) |
145 | 142 | ||
146 | selector = url + "/xml/build_status.pl" | 143 | selector = url + "/xml/build_status.pl" |
147 | 144 | ||
@@ -162,22 +159,20 @@ def tinder_print_info(d): | |||
162 | we use. | 159 | we use. |
163 | """ | 160 | """ |
164 | 161 | ||
165 | from bb import data | ||
166 | # get the local vars | 162 | # get the local vars |
167 | |||
168 | time = tinder_time_string() | 163 | time = tinder_time_string() |
169 | ops = os.uname()[0] | 164 | ops = os.uname()[0] |
170 | version = os.uname()[2] | 165 | version = os.uname()[2] |
171 | url = data.getVar( 'TINDER_URL' , d, True ) | 166 | url = d.getVar( 'TINDER_URL' , True ) |
172 | tree = data.getVar( 'TINDER_TREE', d, True ) | 167 | tree = d.getVar( 'TINDER_TREE', True ) |
173 | branch = data.getVar( 'TINDER_BRANCH', d, True ) | 168 | branch = d.getVar( 'TINDER_BRANCH', True ) |
174 | srcdate = data.getVar( 'SRCDATE', d, True ) | 169 | srcdate = d.getVar( 'SRCDATE', True ) |
175 | machine = data.getVar( 'MACHINE', d, True ) | 170 | machine = d.getVar( 'MACHINE', True ) |
176 | distro = data.getVar( 'DISTRO', d, True ) | 171 | distro = d.getVar( 'DISTRO', True ) |
177 | bbfiles = data.getVar( 'BBFILES', d, True ) | 172 | bbfiles = d.getVar( 'BBFILES', True ) |
178 | tarch = data.getVar( 'TARGET_ARCH', d, True ) | 173 | tarch = d.getVar( 'TARGET_ARCH', True ) |
179 | fpu = data.getVar( 'TARGET_FPU', d, True ) | 174 | fpu = d.getVar( 'TARGET_FPU', True ) |
180 | oerev = data.getVar( 'OE_REVISION', d, True ) or "unknown" | 175 | oerev = d.getVar( 'OE_REVISION', True ) or "unknown" |
181 | 176 | ||
182 | # there is a bug with tipple quoted strings | 177 | # there is a bug with tipple quoted strings |
183 | # i will work around but will fix the original | 178 | # i will work around but will fix the original |
@@ -212,8 +207,6 @@ def tinder_print_env(): | |||
212 | """ | 207 | """ |
213 | Print the environment variables of this build | 208 | Print the environment variables of this build |
214 | """ | 209 | """ |
215 | from bb import data | ||
216 | |||
217 | time_start = tinder_time_string() | 210 | time_start = tinder_time_string() |
218 | time_end = tinder_time_string() | 211 | time_end = tinder_time_string() |
219 | 212 | ||
@@ -272,12 +265,10 @@ def tinder_do_tinder_report(event): | |||
272 | BuildCompleted Event. In this case we have to look up the status and | 265 | BuildCompleted Event. In this case we have to look up the status and |
273 | send it instead of 100/success. | 266 | send it instead of 100/success. |
274 | """ | 267 | """ |
275 | from bb.event import getName | ||
276 | from bb import data, mkdirhier, build | ||
277 | import glob | 268 | import glob |
278 | 269 | ||
279 | # variables | 270 | # variables |
280 | name = getName(event) | 271 | name = bb.event.getName(event) |
281 | log = "" | 272 | log = "" |
282 | status = 1 | 273 | status = 1 |
283 | # Check what we need to do Build* shows we start or are done | 274 | # Check what we need to do Build* shows we start or are done |
@@ -287,7 +278,7 @@ def tinder_do_tinder_report(event): | |||
287 | 278 | ||
288 | try: | 279 | try: |
289 | # truncate the tinder log file | 280 | # truncate the tinder log file |
290 | f = file(data.getVar('TINDER_LOG', event.data, True), 'w') | 281 | f = file(event.data.getVar('TINDER_LOG', True), 'w') |
291 | f.write("") | 282 | f.write("") |
292 | f.close() | 283 | f.close() |
293 | except: | 284 | except: |
@@ -296,7 +287,7 @@ def tinder_do_tinder_report(event): | |||
296 | try: | 287 | try: |
297 | # write a status to the file. This is needed for the -k option | 288 | # write a status to the file. This is needed for the -k option |
298 | # of BitBake | 289 | # of BitBake |
299 | g = file(data.getVar('TMPDIR', event.data, True)+"/tinder-status", 'w') | 290 | g = file(event.data.getVar('TMPDIR', True)+"/tinder-status", 'w') |
300 | g.write("") | 291 | g.write("") |
301 | g.close() | 292 | g.close() |
302 | except IOError: | 293 | except IOError: |
@@ -305,10 +296,10 @@ def tinder_do_tinder_report(event): | |||
305 | # Append the Task-Log (compile,configure...) to the log file | 296 | # Append the Task-Log (compile,configure...) to the log file |
306 | # we will send to the server | 297 | # we will send to the server |
307 | if name == "TaskSucceeded" or name == "TaskFailed": | 298 | if name == "TaskSucceeded" or name == "TaskFailed": |
308 | log_file = glob.glob("%s/log.%s.*" % (data.getVar('T', event.data, True), event.task)) | 299 | log_file = glob.glob("%s/log.%s.*" % (event.data.getVar('T', True), event.task)) |
309 | 300 | ||
310 | if len(log_file) != 0: | 301 | if len(log_file) != 0: |
311 | to_file = data.getVar('TINDER_LOG', event.data, True) | 302 | to_file = event.data.getVar('TINDER_LOG', True) |
312 | log += "".join(open(log_file[0], 'r').readlines()) | 303 | log += "".join(open(log_file[0], 'r').readlines()) |
313 | 304 | ||
314 | # set the right 'HEADER'/Summary for the TinderBox | 305 | # set the right 'HEADER'/Summary for the TinderBox |
@@ -319,23 +310,23 @@ def tinder_do_tinder_report(event): | |||
319 | elif name == "TaskFailed": | 310 | elif name == "TaskFailed": |
320 | log += "<--- TINDERBOX Task %s failed (FAILURE)\n" % event.task | 311 | log += "<--- TINDERBOX Task %s failed (FAILURE)\n" % event.task |
321 | elif name == "PkgStarted": | 312 | elif name == "PkgStarted": |
322 | log += "---> TINDERBOX Package %s started\n" % data.getVar('PF', event.data, True) | 313 | log += "---> TINDERBOX Package %s started\n" % event.data.getVar('PF', True) |
323 | elif name == "PkgSucceeded": | 314 | elif name == "PkgSucceeded": |
324 | log += "<--- TINDERBOX Package %s done (SUCCESS)\n" % data.getVar('PF', event.data, True) | 315 | log += "<--- TINDERBOX Package %s done (SUCCESS)\n" % event.data.getVar('PF', True) |
325 | elif name == "PkgFailed": | 316 | elif name == "PkgFailed": |
326 | if not data.getVar('TINDER_AUTOBUILD', event.data, True) == "0": | 317 | if not event.data.getVar('TINDER_AUTOBUILD', True) == "0": |
327 | build.exec_task('do_clean', event.data) | 318 | build.exec_task('do_clean', event.data) |
328 | log += "<--- TINDERBOX Package %s failed (FAILURE)\n" % data.getVar('PF', event.data, True) | 319 | log += "<--- TINDERBOX Package %s failed (FAILURE)\n" % event.data.getVar('PF', True) |
329 | status = 200 | 320 | status = 200 |
330 | # remember the failure for the -k case | 321 | # remember the failure for the -k case |
331 | h = file(data.getVar('TMPDIR', event.data, True)+"/tinder-status", 'w') | 322 | h = file(event.data.getVar('TMPDIR', True)+"/tinder-status", 'w') |
332 | h.write("200") | 323 | h.write("200") |
333 | elif name == "BuildCompleted": | 324 | elif name == "BuildCompleted": |
334 | log += "Build Completed\n" | 325 | log += "Build Completed\n" |
335 | status = 100 | 326 | status = 100 |
336 | # Check if we have a old status... | 327 | # Check if we have a old status... |
337 | try: | 328 | try: |
338 | h = file(data.getVar('TMPDIR',event.data,True)+'/tinder-status', 'r') | 329 | h = file(event.data.getVar('TMPDIR',True)+'/tinder-status', 'r') |
339 | status = int(h.read()) | 330 | status = int(h.read()) |
340 | except: | 331 | except: |
341 | pass | 332 | pass |
@@ -351,7 +342,7 @@ def tinder_do_tinder_report(event): | |||
351 | log += "Error:Was Runtime: %d\n" % event.isRuntime() | 342 | log += "Error:Was Runtime: %d\n" % event.isRuntime() |
352 | status = 200 | 343 | status = 200 |
353 | # remember the failure for the -k case | 344 | # remember the failure for the -k case |
354 | h = file(data.getVar('TMPDIR', event.data, True)+"/tinder-status", 'w') | 345 | h = file(event.data.getVar('TMPDIR', True)+"/tinder-status", 'w') |
355 | h.write("200") | 346 | h.write("200") |
356 | 347 | ||
357 | # now post the log | 348 | # now post the log |
@@ -366,13 +357,10 @@ def tinder_do_tinder_report(event): | |||
366 | # we want to be an event handler | 357 | # we want to be an event handler |
367 | addhandler tinderclient_eventhandler | 358 | addhandler tinderclient_eventhandler |
368 | python tinderclient_eventhandler() { | 359 | python tinderclient_eventhandler() { |
369 | from bb import note, error, data | 360 | if e.data is None or bb.event.getName(e) == "MsgNote": |
370 | from bb.event import getName | ||
371 | |||
372 | if e.data is None or getName(e) == "MsgNote": | ||
373 | return | 361 | return |
374 | 362 | ||
375 | do_tinder_report = data.getVar('TINDER_REPORT', e.data, True) | 363 | do_tinder_report = e.data.getVar('TINDER_REPORT', True) |
376 | if do_tinder_report and do_tinder_report == "1": | 364 | if do_tinder_report and do_tinder_report == "1": |
377 | tinder_do_tinder_report(e) | 365 | tinder_do_tinder_report(e) |
378 | 366 | ||