Index: pykota/trunk/pykota/accounters/software.py
===================================================================
--- pykota/trunk/pykota/accounters/software.py (revision 1678)
+++ pykota/trunk/pykota/accounters/software.py (revision 1680)
@@ -22,4 +22,11 @@
 #
 # $Log$
+# Revision 1.9  2004/08/25 22:34:39  jalet
+# Now both software and hardware accounting raise an exception when no valid
+# result can be extracted from the subprocess' output.
+# Hardware accounting now reads subprocess' output until an integer is read
+# or data is exhausted : it now behaves just like software accounting in this
+# aspect.
+#
 # Revision 1.8  2004/08/22 14:04:47  jalet
 # Tries to fix problem with subprocesses outputting more datas than needed
@@ -74,5 +81,5 @@
             self.filter.printInfo(_("Unable to compute job size with accounter %s") % msg)
         
-        pagecount = 0
+        pagecounter = None
         try :
             answer = child.fromchild.read()
@@ -84,8 +91,7 @@
             for i in range(len(lines)) : 
                 try :
-                    pagecount = int(lines[i])
+                    pagecounter = int(lines[i])
                 except (AttributeError, ValueError) :
-                    self.filter.printInfo(_("Unable to compute job size with accounter %s") % self.arguments)
-                    self.filter.printInfo(_("Line skipped in accounter's output. Trying again..."))
+                    self.filter.printInfo(_("Line [%s] skipped in accounter's output. Trying again...") % lines[i])
                 else :    
                     break
@@ -102,5 +108,9 @@
                 status = retcode
             self.filter.printInfo(_("Software accounter %s exit code is %s") % (self.arguments, str(status)))
-        self.filter.logdebug("Software accounter %s said job is %s pages long." % (self.arguments, pagecount))
-        return pagecount    
             
+        if pagecounter is None :    
+            raise PyKotaAccounterError, _("Unable to compute job size with accounter %s") % self.arguments
+            
+        self.filter.logdebug("Software accounter %s said job is %s pages long." % (self.arguments, pagecounter))
+        return pagecounter    
+            
Index: pykota/trunk/pykota/accounters/hardware.py
===================================================================
--- pykota/trunk/pykota/accounters/hardware.py (revision 1624)
+++ pykota/trunk/pykota/accounters/hardware.py (revision 1680)
@@ -22,4 +22,11 @@
 #
 # $Log$
+# Revision 1.9  2004/08/25 22:34:39  jalet
+# Now both software and hardware accounting raise an exception when no valid
+# result can be extracted from the subprocess' output.
+# Hardware accounting now reads subprocess' output until an integer is read
+# or data is exhausted : it now behaves just like software accounting in this
+# aspect.
+#
 # Revision 1.8  2004/07/22 22:41:48  jalet
 # Hardware accounting for LPRng should be OK now. UNTESTED.
@@ -122,12 +129,8 @@
             raise PyKotaAccounterError, _("Unknown printer address in HARDWARE(%s) for printer %s") % (commandline, self.filter.printername)
         self.filter.printInfo(_("Launching HARDWARE(%s)...") % commandline)
-        error = 1
         pagecounter = None
         child = popen2.Popen4(commandline)    
         try :
-            line = child.fromchild.readline()
-            pagecounter = int(line.strip())
-        except ValueError :    
-            self.filter.printInfo(_("Incorrect answer : %s") % repr(line), "error")
+            answer = child.fromchild.read()
         except IOError :    
             # we were interrupted by a signal, certainely a SIGTERM
@@ -139,5 +142,12 @@
             self.filter.printInfo(_("SIGTERM was sent to hardware accounter %s (pid: %s)") % (commandline, child.pid))
         else :    
-            error = 0
+            lines = [l.strip() for l in answer.split("\n")]
+            for i in range(len(lines)) : 
+                try :
+                    pagecounter = int(lines[i])
+                except (AttributeError, ValueError) :
+                    self.filter.printInfo(_("Line [%s] skipped in accounter's output. Trying again...") % lines[i])
+                else :    
+                    break
         child.fromchild.close()    
         child.tochild.close()
@@ -146,6 +156,5 @@
         except OSError, msg :    
             self.filter.logdebug("Error while waiting for hardware accounter pid %s : %s" % (child.pid, msg))
-            error = 1
-        if (not error) and os.WIFEXITED(status) and (not os.WEXITSTATUS(status)) :
+        if (pagecounter is not None) and os.WIFEXITED(status) and (not os.WEXITSTATUS(status)) :
             return pagecounter
         else :    
Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 1676)
+++ pykota/trunk/pykota/version.py (revision 1680)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.20alpha2_unofficial"
+__version__ = "1.20alpha3_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 1678)
+++ pykota/trunk/NEWS (revision 1680)
@@ -22,4 +22,9 @@
 PyKota NEWS :
 
+    - 1.20alpha3 :
+       
+        - Now hardware accounting method works like software
+          accounting method wrt the subprocess' output.
+          
     - 1.20alpha2 :
     
