0

I am having problems converting the following curl command into PyCurl:

curl -k --cert /tmp/blablabla "https://blablabla"

My attempt so far is shown below:

c = pycurl.Curl()
c.setopt(pycurl.URL, submit_url)
c.setopt(pycurl.HTTPGET, 1)
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
c.setopt(pycurl.SSLCERT, cert)
c.setopt(pycurl.CAPATH,'/bla/bla/bla')
c.perform()
c.close()

This does not work. If anyone could tell me where I am going wrong that would be great!

Tomalak
  • 332,285
  • 67
  • 532
  • 628
MWright
  • 1,681
  • 3
  • 19
  • 31
  • Can you show us a traceback (if an exception is thrown) or describe the unexpected behavior? Is it hanging forever, or what? – A. Jesse Jiryu Davis Mar 15 '11 at 18:13
  • I have set pycurl to verbose and supposedly it was having problems finding my certificate. I have sorted this and the problem is now solved...Thanks for your help – MWright Mar 16 '11 at 10:40

1 Answers1

0

Add "--libcurl example.c" to your curl command line to get to see better what libcurl options curl uses, then you can copy them into your pycurl program rather swiftly.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
  • Hi Daniel I don't have the --libcurl argument with the curl set up I have. Will using --verbose gives me some useful information that may help. – MWright Mar 15 '11 at 18:14
  • Wow, then you have a mighty old curl version as --libcurl was added over 4 years ago. But no, --verbose won't really help you to figure out options. You don't seem to even try to do the -k action (ignore the server cert verification). Finally: "this does not work" is not a very helpful way to describe what doesn't work. What exactly happens would be much better to know... – Daniel Stenberg Mar 15 '11 at 19:03
  • looks like the administrator has been taking it easy at work. I have set pycurl to verbose and supposedly it was having problems finding my certificate. I have sorted this and the problem is now solved...Thanks for your help – MWright Mar 16 '11 at 07:55