+def tinder_http_post(d, server, selector, content_type, body):
+ import httplib
+ # now post it
+ for i in range(0,5):
+ try:
+ proxy = data.getVar('HTTP_PROXY', d, True )
+ if (proxy):
+ if (proxy.endswith('/')):
+ proxy = proxy[:-1]
+ if (proxy.startswith('http://')):
+ proxy = proxy[7:]
+ h = httplib.HTTP(proxy)
+ h.putrequest('POST', 'http://%s%s' % (server, selector))
+ else:
+ h = httplib.HTTP(server)
+ h.putrequest('POST', selector)
+ h.putheader('content-type', content_type)
+ h.putheader('content-length', str(len(body)))
+ h.endheaders()
+ h.send(body)
+ errcode, errmsg, headers = h.getreply()
+ #print errcode, errmsg, headers
+ return (errcode,errmsg, headers, h.file)
+ except Exception, e:
+ print "Error sending the report! ", e
+ # try again
+ pass
+
+ # return some garbage
+ return (-1, "unknown", "unknown", None)
+
+def tinder_form_data(bound, dict, log):
+ output = []
+ # for each key in the dictionary
+ for name in dict:
+ assert dict[name]
+ output.append( "--" + bound )
+ output.append( 'Content-Disposition: form-data; name="%s"' % name )
+ output.append( "" )
+ output.append( dict[name] )
+ if log:
+ output.append( "--" + bound )
+ output.append( 'Content-Disposition: form-data; name="log"; filename="log.txt"' )
+ output.append( '' )
+ output.append( log )
+ output.append( '--' + bound + '--' )
+ output.append( '' )
+
+ return "\r\n".join(output)
+
+def tinder_time_string():
+ """
+ Return the time as GMT
+ """
+ return ""
+
+def tinder_format_http_post(d,status,log):
+ """
+ Format the Tinderbox HTTP post with the data needed
+ for the tinderbox to be happy.
+ """
+
+ import random
+
+ # the variables we will need to send on this form post
+ variables = {
+ "tree" : data.getVar('TINDER_TREE', d, True),
+ "machine_name" : data.getVar('TINDER_MACHINE', d, True),
+ "os" : os.uname()[0],
+ "os_version" : os.uname()[2],
+ "compiler" : "gcc",
+ "clobber" : data.getVar('TINDER_CLOBBER', d, True) or "0",
+ "srcdate" : data.getVar('SRCDATE', d, True),
+ "PN" : data.getVar('PN', d, True),
+ "PV" : data.getVar('PV', d, True),
+ "PR" : data.getVar('PR', d, True),
+ "FILE" : data.getVar('FILE', d, True) or "N/A",
+ "TARGETARCH" : data.getVar('TARGET_ARCH', d, True),
+ "TARGETFPU" : data.getVar('TARGET_FPU', d, True) or "Unknown",
+ "TARGETOS" : data.getVar('TARGET_OS', d, True) or "Unknown",
+ "MACHINE" : data.getVar('MACHINE', d, True) or "Unknown",
+ "DISTRO" : data.getVar('DISTRO', d, True) or "Unknown",
+ }
+
+ # optionally add the status
+ if status:
+ variables["status"] = str(status)
+
+ # try to load the machine id
+ # we only need on build_status.pl but sending it
+ # always does not hurt