Index: pykota/trunk/pykota/errors.py
===================================================================
--- pykota/trunk/pykota/cups.py (revision 3275)
+++ pykota/trunk/pykota/errors.py (revision 3288)
@@ -20,89 +20,48 @@
 #
 
-"""This module implements some CUPS specific classes."""
+"""This module defines ALL PyKota specific exceptions."""
 
-from pykota.tool import PyKotaToolError
-try :
-    from pkipplib import pkipplib
-except ImportError :        
-    raise RuntimeError, "The python-pkipplib module is now mandatory. You can download pkipplib from http://www.pykota.com/"
-
-class JobTicket :    
-    """A class to hold CUPS print job informations."""
-    def __init__(self, jobid=None, printername=None, copies=1, filename=None, \
-                       options=None) :
-        """Initializes a print job's information."""
-        self.JobId = jobid
-        self.PrinterName = printername
-        self.Copies = copies
-        self.FileName = filename
-        self.Options = options
-        self.Charset = None
-        self.OriginatingUserName = None
-        self.OriginalUserName = None
-        self.Title = None
-        self.BillingCode = None
-        self.OriginatingHostName = None
-        self.TimeAtCreation = None
-        self.TimeAtProcessing = None
-        self.MimeType = None
-        self.UUID = None
-        if self.JobId is not None :
-            self.retrieveAttributesFromCUPS()
+class PyKotaError(Exception) :
+    """Mother class of all PyKota exceptions."""
+    def __init__(self, value) :
+        """Saves the value passed as a parameter."""
+        self.value = value
         
-    def getAttributeTypeAndValue(self, ippanswer, attribute, category="job") :    
-        """Retrieves a particular attribute's type and value from an IPP answer.
+    def __str__(self) :    
+        """Returns an unicode string representation."""
+        try :
+            return unicode(self.value, errors="replace")
+        except TypeError :    
+            return unicode(self.value) # None and strings which are already unicode
         
-           Returns a tuple of the form (type, value).
-        """
-        try :
-            return getattr(ippanswer, category)[attribute][0]
-        except KeyError :    
-            return (None, None)
-            
-    def retrieveAttributesFromCUPS(self) :
-        """Retrieve attribute's values from CUPS."""
-        server = pkipplib.CUPS() # TODO : username and password and/or encryption
-        answer = server.getJobAttributes(self.JobId)
-        if answer is None :
-            raise PyKotaToolError, "Network error while querying the CUPS server : %s" \
-                                      % server.lastErrorMessage
-        (dummy, self.Charset) = self.getAttributeTypeAndValue(answer, "attributes-charset", "operation")
-        (dummy, self.OriginatingUserName) = self.getAttributeTypeAndValue(answer, "job-originating-user-name")
-        (dummy, self.Title) = self.getAttributeTypeAndValue(answer, "job-name")
-        (dummy, self.BillingCode) = self.getAttributeTypeAndValue(answer, "job-billing")
-        (dummy, self.OriginatingHostName) = self.getAttributeTypeAndValue(answer, "job-originating-host-name")
-        (dummy, self.UUID) = self.getAttributeTypeAndValue(answer, "job-uuid")
-        (dummy, self.TimeAtCreation) = self.getAttributeTypeAndValue(answer, "time-at-creation")
-        (dummy, self.TimeAtProcessing) = self.getAttributeTypeAndValue(answer, "time-at-processing")
-        (dummy, self.MimeType) = self.getAttributeTypeAndValue(answer, "document-format")
-        
-        for attrib in ("OriginatingUserName", 
-                       "OriginatingHostName",
-                       "Title", 
-                       "BillingCode",
-                       "PrinterName",
-                       "Options",
-                       "Charset",
-                       "UUID",
-                       "MimeType") :
-            try :           
-                setattr(self, attrib, 
-                              getattr(self, attrib).decode("UTF-8", "replace"))
-            except AttributeError :                  
-                pass
-                
-        self.OriginalUserName = self.OriginatingUserName[:]
+class PyKotaToolError(PyKotaError) :
+    """PyKota Exception for all executables."""
+    pass
     
-if __name__ == "__main__" :    
-    import sys
-    if len(sys.argv) != 2 :
-        sys.stderr.write("usage : python cups.py jobid\n")
-    else :    
-        job = JobTicket(int(sys.argv[1]), "FakePrinter")
-        for attribute in ("PrinterName", "Charset", "JobId", "Copies", 
-                          "FileName", "OriginatingUserName", 
-                          "Title", "BillingCode", "OriginatingHostName", 
-                          "TimeAtCreation", "TimeAtProcessing", "UUID", 
-                          "MimeType") :
-            sys.stdout.write("%s : %s\n" % (attribute, repr(getattr(job, attribute))))
+class PyKotaToolError(PyKotaError) :
+    """PyKota Exception for all executables."""
+    pass
+    
+class PyKotaCommandLineError(PyKotaToolError) :
+    """PyKota Exception for errors on executables' command line."""
+    pass
+    
+class PyKotaStorageError(PyKotaError) :
+    """PyKota Exception for database backend related errors."""
+    pass
+    
+class PyKotaConfigError(PyKotaError) :
+    """PyKota Exception for errors in PyKota's configuration."""
+    pass
+    
+class PyKotaAccounterError(PyKotaError) :
+    """PyKota Exception for errors in PyKota accounters."""
+    pass
+    
+class PyKotaReporterError(PyKotaError) :
+    """PyKota Exception for errors in PyKota report generators."""
+    pass
+    
+class PyKotaLoggingError(PyKotaError) :
+    """PyKota Exception for errors in PyKota logging."""
+    pass
