Changeset View
Changeset View
Standalone View
Standalone View
pykolab/wap_client/__init__.py
import json | import json | ||||
import sys | |||||
try: | try: | ||||
import httplib | import httplib | ||||
except ImportError: | except ImportError: | ||||
import http.client as httplib | import http.client as httplib | ||||
import urllib | |||||
import sys | |||||
try: | try: | ||||
from urlparse import urlparse | from urlparse import urlparse | ||||
except ImportError: | except ImportError: | ||||
from urllib.parse import urlparse | from urllib.parse import urlparse | ||||
try: | |||||
from urllib import urlencode | |||||
except ImportError: | |||||
from urllib.parse import urlencode | |||||
import pykolab | import pykolab | ||||
from pykolab import utils | from pykolab import utils | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
log = pykolab.getLogger('pykolab.wap_client') | log = pykolab.getLogger('pykolab.wap_client') | ||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
▲ Show 20 Lines • Show All 421 Lines • ▼ Show 20 Line(s) | |||||
reconnect = False | reconnect = False | ||||
conn = connect() | conn = connect() | ||||
if conf.debuglevel > 8: | if conf.debuglevel > 8: | ||||
conn.set_debuglevel(9) | conn.set_debuglevel(9) | ||||
if get is not None: | if get is not None: | ||||
_get = "?%s" % (urllib.urlencode(get)) | _get = "?%s" % (urlencode(get)) | ||||
else: | else: | ||||
_get = "" | _get = "" | ||||
log.debug(_("Requesting %r with params %r") % ("%s/%s" % (API_BASE, api_uri), (get, post)), level=8) | log.debug(_("Requesting %r with params %r") % ("%s/%s" % (API_BASE, api_uri), (get, post)), level=8) | ||||
try: | try: | ||||
conn.request(method.upper(), "%s/%s%s" % (API_BASE, api_uri, _get), post, headers) | conn.request(method.upper(), "%s/%s%s" % (API_BASE, api_uri, _get), post, headers) | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |