Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
cupshelpers.openprinting._QueryThread Class Reference

List of all members.

Public Member Functions

def __init__
def run

Public Attributes

 parent
 parameters
 callback
 user_data
 result
 url

Detailed Description

Definition at line 38 of file openprinting.py.


Constructor & Destructor Documentation

def cupshelpers.openprinting._QueryThread.__init__ (   self,
  parent,
  parameters,
  callback,
  user_data = None 
)

Definition at line 39 of file openprinting.py.

00039 
00040     def __init__ (self, parent, parameters, callback, user_data=None):
00041         threading.Thread.__init__ (self)
00042         self.parent = parent
00043         self.parameters = parameters
00044         self.callback = callback
00045         self.user_data = user_data
00046         self.result = ""
00047 
00048         self.setDaemon (True)


Member Function Documentation

Definition at line 49 of file openprinting.py.

00049 
00050     def run (self):
00051 
00052         # Callback function for pycURL collecting the data coming from
00053         # the web server
00054         def collect_data(result):
00055             self.result += result;
00056             return len(result)
00057 
00058         # CGI script to be executed
00059         query_command = "/query.cgi"
00060         # Headers for the post request
00061         headers = {"Content-type": "application/x-www-form-urlencoded",
00062                    "Accept": "text/plain"}
00063         params = ("%s&uilanguage=%s&locale=%s" %
00064                   (urllib.urlencode (self.parameters),
00065                    self.parent.language[0],
00066                    self.parent.language[0]))
00067         self.url = "https://%s%s?%s" % (self.parent.base_url, query_command, params)
00068         # Send request
00069         result = None
00070         self.result = ""
00071         status = 1
00072         try:
00073             curl = pycurl.Curl()
00074             curl.setopt(pycurl.SSL_VERIFYPEER, 1)
00075             curl.setopt(pycurl.SSL_VERIFYHOST, 2)
00076             curl.setopt(pycurl.WRITEFUNCTION, collect_data)
00077             curl.setopt(pycurl.URL, self.url)
00078             status = curl.perform()
00079             if status == None: status = 0
00080             if (status != 0):
00081                 self.result = sys.exc_info ()
00082         except:
00083             self.result = sys.exc_info ()
00084             if status == None: status = 0
00085 
00086         if self.callback != None:
00087             self.callback (status, self.user_data, self.result)


Member Data Documentation

Definition at line 43 of file openprinting.py.

Definition at line 42 of file openprinting.py.

Definition at line 41 of file openprinting.py.

Definition at line 45 of file openprinting.py.

Definition at line 66 of file openprinting.py.

Definition at line 44 of file openprinting.py.


The documentation for this class was generated from the following file: