Index: pykota/trunk/bin/warnpykota
===================================================================
--- pykota/trunk/bin/warnpykota (revision 1257)
+++ pykota/trunk/bin/warnpykota (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.27  2004/06/03 21:50:34  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.26  2004/01/08 14:10:32  jalet
 # Copyright year changed.
@@ -247,7 +252,9 @@
         else :
             retcode = sender.main(args, options)
-    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :            
-        sys.stderr.write("%s\n" % msg)
-        sys.stderr.flush()
+    except :
+        try :
+            sender.crashed("warnpykota failed")
+        except :    
+            pass
         retcode = -1
         
Index: pykota/trunk/bin/edpykota
===================================================================
--- pykota/trunk/bin/edpykota (revision 1436)
+++ pykota/trunk/bin/edpykota (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.73  2004/06/03 21:50:34  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.72  2004/04/16 16:20:19  jalet
 # Note about not implemented limitby values
@@ -690,7 +695,9 @@
         else :
             retcode = editor.main(args, options)
-    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :            
-        sys.stderr.write("%s\n" % msg)
-        sys.stderr.flush()
+    except :
+        try :
+            editor.crashed("edpykota failed")
+        except :    
+            pass
         retcode = -1
 
Index: pykota/trunk/bin/pkprinters
===================================================================
--- pykota/trunk/bin/pkprinters (revision 1453)
+++ pykota/trunk/bin/pkprinters (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.9  2004/06/03 21:50:34  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.8  2004/05/06 20:30:24  jalet
 # Added --skipexisting command line option to pkprinters
@@ -255,7 +260,9 @@
         else :
             retcode = manager.main(args, options)
-    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :            
-        sys.stderr.write("%s\n" % msg)
-        sys.stderr.flush()
+    except :
+        try :
+            manager.crashed("pkprinters failed")
+        except :    
+            pass
         retcode = -1
 
Index: pykota/trunk/bin/cupspykota
===================================================================
--- pykota/trunk/bin/cupspykota (revision 1515)
+++ pykota/trunk/bin/cupspykota (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.58  2004/06/03 21:50:33  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.57  2004/06/02 22:18:07  jalet
 # I think the bug when cancelling jobs should be fixed right now
@@ -330,8 +335,8 @@
             clienthost = self.getJobOriginatingHostname(printer.Name, user.Name, self.jobid)
             self.logdebug("Client Hostname : %s" % (clienthost or "Unknown"))    
-            os.putenv("PYKOTAJOBORIGINATINGHOSTNAME", str(clienthost or ""))
+            os.environ["PYKOTAJOBORIGINATINGHOSTNAME"] = str(clienthost or "")
             
             # enters first phase
-            os.putenv("PYKOTAPHASE", "BEFORE")
+            os.environ["PYKOTAPHASE"] = "BEFORE"
             
             # checks the user's quota
@@ -340,10 +345,10 @@
                 self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize)
                 self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice))
-            os.putenv("PYKOTAPRECOMPUTEDJOBSIZE", str(self.softwareJobSize))    
-            os.putenv("PYKOTAPRECOMPUTEDJOBPRICE", str(self.softwareJobPrice))    
+            os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize)
+            os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice)
             action = self.warnUserPQuota(userpquota)
             
             # exports some new environment variables
-            os.putenv("PYKOTAACTION", action)
+            os.environ["PYKOTAACTION"] = action
             
             # launches the pre hook
@@ -354,5 +359,5 @@
         else :    
             action = "ALLOW"
-            os.putenv("PYKOTAACTION", action)
+            os.environ["PYKOTAACTION"] = action
             
         # pass the job's data to the real backend    
@@ -367,5 +372,5 @@
         if policy == "OK" :        
             # indicate phase change
-            os.putenv("PYKOTAPHASE", "AFTER")
+            os.environ["PYKOTAPHASE"] = "AFTER"
             
             # stops accounting. 
@@ -390,8 +395,8 @@
             
             # exports some new environment variables
-            os.putenv("PYKOTAJOBSIZE", str(jobsize))
-            os.putenv("PYKOTAJOBPRICE", str(jobprice))
-            
-            # then re-export user information with new values
+            os.environ["PYKOTAJOBSIZE"] = str(jobsize)
+            os.environ["PYKOTAJOBPRICE"] = str(jobprice)
+            
+            # then re-export user information with new value
             self.exportUserInfo(userpquota)
             
@@ -660,10 +665,8 @@
             retcode = kotabackend.mainWork()
         except :
-            import traceback
-            lines = []
-            for line in traceback.format_exception(*sys.exc_info()) :
-                lines.extend([l for l in line.split("\n") if l])
-            sys.stderr.write("ERROR : cupspykota backend failed : \n%s" % (msg, "ERROR : ".join(["%s\n" % l for l in lines])))
-            sys.stderr.flush()
+            try :
+                kotabackend.crashed("cupspykota backend failed")
+            except :    
+                pass
             retcode = 1
         
Index: pykota/trunk/bin/pykotme
===================================================================
--- pykota/trunk/bin/pykotme (revision 1488)
+++ pykota/trunk/bin/pykotme (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.10  2004/06/03 21:50:34  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.9  2004/05/21 20:53:34  jalet
 # Now pykotme doesn't spawn a new process anymore to compute job's size, but
@@ -186,7 +191,9 @@
         else :
             retcode = sender.main(args, options)
-    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :            
-        sys.stderr.write("%s\n" % msg)
-        sys.stderr.flush()
+    except :
+        try :
+            sender.crashed("pykotme failed")
+        except :    
+            pass
         retcode = -1
 
Index: pykota/trunk/bin/pkhint
===================================================================
--- pykota/trunk/bin/pkhint (revision 1483)
+++ pykota/trunk/bin/pkhint (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.9  2004/06/03 21:50:34  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.8  2004/05/18 14:48:47  jalet
 # Big code changes to completely remove the need for "requester" directives,
@@ -266,7 +271,9 @@
                 args = [ "*" ]
             retcode = manager.main(args, options)
-    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :            
-        sys.stderr.write("%s\n" % msg)
-        sys.stderr.flush()
+    except :
+        try :
+            manager.crashed("pkhint failed")
+        except :    
+            pass
         retcode = -1
 
Index: pykota/trunk/bin/repykota
===================================================================
--- pykota/trunk/bin/repykota (revision 1257)
+++ pykota/trunk/bin/repykota (revision 1517)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.47  2004/06/03 21:50:34  jalet
+# Improved error logging.
+# crashrecipient directive added.
+# Now exports the job's size in bytes too.
+#
 # Revision 1.46  2004/01/08 14:10:32  jalet
 # Copyright year changed.
@@ -307,8 +312,10 @@
         else :
             retcode = reportTool.main(args, options)
-    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaReporterError), msg :            
-        sys.stderr.write("%s\n" % msg)
-        sys.stderr.flush()
-        retcode = -1 
+    except :
+        try :
+            reportTool.crashed("repykota failed")
+        except :    
+            pass
+        retcode = -1
 
     try :
