Index: /pykota/trunk/pykota/utils.py
===================================================================
--- /pykota/trunk/pykota/utils.py (revision 3366)
+++ /pykota/trunk/pykota/utils.py (revision 3367)
@@ -31,9 +31,4 @@
 from pykota.errors import PyKotaCommandLineError
 
-def onlyAdmin(app, restricted=True) :
-    """Raises an exception if the user is not a PyKota administrator."""
-    if restricted and not app.config.isAdmin :
-        raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
-        
 def initlocale(lang="", cset=None) :
     """Initializes the locale stuff."""
Index: /pykota/trunk/pykota/tool.py
===================================================================
--- /pykota/trunk/pykota/tool.py (revision 3327)
+++ /pykota/trunk/pykota/tool.py (revision 3367)
@@ -171,4 +171,9 @@
         sys.stderr.flush()
         
+    def adminOnly(self, restricted=True) :
+        """Raises an exception if the user is not a PyKota administrator."""
+        if restricted and not self.config.isAdmin :
+            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
+            
     def matchString(self, s, patterns) :
         """Returns True if the string s matches one of the patterns, else False."""
Index: /pykota/trunk/bin/pkinvoice
===================================================================
--- /pykota/trunk/bin/pkinvoice (revision 3365)
+++ /pykota/trunk/bin/pkinvoice (revision 3367)
@@ -189,6 +189,5 @@
             raise PyKotaToolError, "The Python Imaging Library is missing. Download it from http://www.pythonware.com/downloads"
             
-        if not self.config.isAdmin :
-            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
+        self.adminOnly()
         
         self.pagesize = getPageSize(options.pagesize)
Index: /pykota/trunk/bin/pkbcodes
===================================================================
--- /pykota/trunk/bin/pkbcodes (revision 3362)
+++ /pykota/trunk/bin/pkbcodes (revision 3367)
@@ -46,6 +46,6 @@
     def main(self, names, options) :
         """Manage billing codes."""
-        if (not self.config.isAdmin) and (options.action != "list") :
-            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
+        if options.action != "list" :
+            self.adminOnly()
            
         islist = (options.action == "list")
Index: /pykota/trunk/bin/pkturnkey
===================================================================
--- /pykota/trunk/bin/pkturnkey (revision 3295)
+++ /pykota/trunk/bin/pkturnkey (revision 3367)
@@ -381,8 +381,6 @@
     def main(self, names, options) :
         """Intializes PyKota's database."""
-        if not self.config.isAdmin :
-            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], \
-                                   _("You're not allowed to use this command."))
-            
+        self.adminOnly()
+        
         if not names :
             names = ["*"]
Index: /pykota/trunk/bin/pkprinters
===================================================================
--- /pykota/trunk/bin/pkprinters (revision 3295)
+++ /pykota/trunk/bin/pkprinters (revision 3367)
@@ -190,6 +190,6 @@
     def main(self, names, options) :
         """Manage printers."""
-        if (not self.config.isAdmin) and (not options["list"]) :
-            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
+        if not options["list"] :
+            self.adminOnly()
             
         docups = options["cups"]
Index: /pykota/trunk/bin/pkrefund
===================================================================
--- /pykota/trunk/bin/pkrefund (revision 3360)
+++ /pykota/trunk/bin/pkrefund (revision 3367)
@@ -183,6 +183,5 @@
             raise PyKotaToolError, "The Python Imaging Library is missing. Download it from http://www.pythonware.com/downloads"
             
-        if not self.config.isAdmin :
-            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
+        self.adminOnly()    
             
         self.pagesize = getPageSize(options.pagesize)
