-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathService.py
41 lines (37 loc) · 1.15 KB
/
Service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pycurl
try:
from cStringIO import StringIO
except ImportError:
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from urllib import urlencode
class Service(object):
def getProjects(self):
pass
def curl_post(self, url, postvals, header = []):
buffer = StringIO()
cobj = pycurl.Curl()
cobj.setopt(pycurl.URL, url)
cobj.setopt(pycurl.SSL_VERIFYPEER, 0)
cobj.setopt(pycurl.SSL_VERIFYHOST, 0)
cobj.setopt(pycurl.POST, 1)
cobj.setopt(pycurl.WRITEDATA, buffer)
postdata = urlencode(postvals)
cobj.setopt(pycurl.POSTFIELDS, postdata)
cobj.setopt(pycurl.HTTPHEADER, header)
cobj.perform()
cobj.close()
return buffer
def curl_get(self, url, header = []):
buffer = StringIO()
cobj = pycurl.Curl()
cobj.setopt(pycurl.SSL_VERIFYPEER, 0)
cobj.setopt(pycurl.SSL_VERIFYHOST, 0)
cobj.setopt(pycurl.URL, url)
cobj.setopt(pycurl.WRITEDATA, buffer)
cobj.setopt(pycurl.HTTPHEADER, header)
cobj.perform()
cobj.close()
return buffer