I am currently using PycURL to trigger a build in Jenkins, by posting to a certain URL. The relevant code looks as follows:
curl = pycurl.Curl()
curl.setopt(pycurl.URL, url)
# These are the form fields expected by Jenkins
data = [
("name", "CI_VERSION"),
("value", str(version)),
("name", "integration.xml"),
("file0", (pycurl.FORM_FILE, metadata_fpath)),
("json", "{{'parameter': [{{'name': 'CI_VERSION', 'value':"
"'{0}'}}, {{'name': 'integration.xml', 'file': 'file0'}}]}}".
format(version,)),
("Submit", "Build"),
]
curl.setopt(pycurl.HTTPPOST, data)
curl.perform()
As you can see, one of the post parameters ('file0') is a file, as indicated by the parameter type pycurl.FORM_FILE.
How can I replace my usage of PycURL with the standard Python library?