Index: /pykota/trunk/docs/pykosd.sgml
===================================================================
--- /pykota/trunk/docs/pykosd.sgml (revision 1600)
+++ /pykota/trunk/docs/pykosd.sgml (revision 1605)
@@ -13,11 +13,19 @@
     Whenever you launch <filename>pykosd</filename>, it will display the current user's print quota
     information in the top-left corner of the screen, above all existing windows, and with
-    a transparent background. Then after five seconds, the information displayed will disappear
-    and the program will exit.
+    a transparent background. 
   </para>
   
   <para>
-    In the future, this command will accept some parameters which will render it more
-    useful.
+    By default, the information will remain displayed during <literal>3</literal> seconds, and
+    will be refreshed every <literal>180</literal> seconds. The program will loop forever 
+    until <keysym>Ctrl+C</keysym> is pressed, unless a specific number of iterations was
+    asked for.
+    
+    <tip>
+      <title>Tip</title>
+      <para>
+        Use command line options to change this behaviour.
+      </para>
+    </tip>
   </para>
   
@@ -27,11 +35,19 @@
       <cmdsynopsis>
         <command>pykosd</command>
+        <group choice="opt"><arg>-v</arg><arg>--version</arg></group>
+        <group choice="opt"><arg>-h</arg><arg>--help</arg></group>
+        <group choice="opt">
+          <arg>-d <replaceable>d</replaceable></arg>
+          <arg>--duration <replaceable>d</replaceable></arg>
+        </group>
+        <group choice="opt">
+          <arg>-l <replaceable>n</replaceable></arg>
+          <arg>--loop <replaceable>n</replaceable></arg>
+        </group>
+        <group choice="opt">
+          <arg>-s <replaceable>s</replaceable></arg>
+          <arg>--sleep <replaceable>s</replaceable></arg>
+        </group>
       </cmdsynopsis>
-      <warning>
-        <para>
-          <filename>pykosd</filename> doesn't currently accept any command line
-          option. This will change in the future.
-        </para>  
-      </warning>
     </para>
   </sect1>
@@ -41,4 +57,7 @@
 
 $Log$
+Revision 1.2  2004/07/19 22:37:13  jalet
+pykosd is now a very good tool
+
 Revision 1.1  2004/07/16 12:22:46  jalet
 LPRng support early version
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 1600)
+++ /pykota/trunk/pykota/version.py (revision 1605)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.19alpha32_unofficial"
+__version__ = "1.19alpha33_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/bin/pkprinters
===================================================================
--- /pykota/trunk/bin/pkprinters (revision 1584)
+++ /pykota/trunk/bin/pkprinters (revision 1605)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.14  2004/07/19 22:37:13  jalet
+# pykosd is now a very good tool
+#
 # Revision 1.13  2004/07/01 19:56:41  jalet
 # Better dispatching of error messages
@@ -73,6 +76,4 @@
 from pykota import version
 from pykota.tool import PyKotaTool, PyKotaToolError, crashed
-from pykota.config import PyKotaConfigError
-from pykota.storage import PyKotaStorageError
 
 __doc__ = """pkprinters v%s (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
Index: /pykota/trunk/bin/pykosd
===================================================================
--- /pykota/trunk/bin/pykosd (revision 1597)
+++ /pykota/trunk/bin/pykosd (revision 1605)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.4  2004/07/19 22:37:13  jalet
+# pykosd is now a very good tool
+#
 # Revision 1.3  2004/07/07 21:44:15  jalet
 # Formatting improvements
@@ -42,26 +45,83 @@
 import pyosd
 
+from pykota import version
 from pykota.tool import PyKotaTool, PyKotaToolError, crashed
 
-DURATION = 5
+__doc__ = """pykosd v%s (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+An OSD quota monitor for PyKota.
 
-if __name__ == "__main__" :
-    retcode = -1
-    try :
-        cmd = PyKotaTool(doc="A tool to display remaining print units")
-    except :    
-        crashed("Initialization problem.")
-    else :    
-        try :
-            uid = os.geteuid()
-            uname = pwd.getpwuid(uid)[0]
-            user = cmd.storage.getUser(uname)
+command line usage :
+
+  pykosd [options]
+
+options :
+
+  -v | --version       Prints pkprinters's version number then exits.
+  -h | --help          Prints this message then exits.
+  
+  -d | --duration d    Sets the duration of the display in seconds. 
+                       Defaults to 3 seconds.
+  
+  -l | --loop n        Sets the number of times the info will be displayed.
+                       Defaults to 0, which means loop forever.
+                       
+  -s | --sleep s       Sets the sleeping duration between two displays 
+                       in seconds. Defaults to 180 seconds (3 minutes).
+                       
+  
+examples :                              
+
+  $ pykosd -s 60 --loop 5
+  
+  Will launch pykosd. Display will be refreshed every 60 seconds,
+  and will last for 3 seconds (the default) each time. After five
+  iterations, the program will exit.
+  
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+
+Please e-mail bugs to: %s""" % (version.__version__, version.__author__)
+
+
+class PyKOSD(PyKotaTool) :
+    def main(self, args, options) :
+        """Main function starts here."""
+        try :    
+            duration = int(options["duration"])
+        except :    
+            raise PyKotaToolError, "Invalid duration option %s" % str(options["duration"])
+            
+        try :    
+            loop = int(options["loop"])
+        except :    
+            raise PyKotaToolError, "Invalid loop option %s" % str(options["loop"])
+            
+        try :    
+            sleep = float(options["sleep"])
+        except :    
+            raise PyKotaToolError, "Invalid sleep option %s" % str(options["sleep"])
+            
+        uid = os.geteuid()
+        uname = pwd.getpwuid(uid)[0]
+        while 1 :
+            user = cmd.storage.getUserFromBackend(uname)        # don't use cache
             if not user.Exists :
                 raise PyKotaToolError, "User %s doesn't exist in PyKota's database." % uname
             if user.LimitBy == "quota" :    
                 printers = cmd.storage.getMatchingPrinters("*")
-                upquotas = [ cmd.storage.getUserPQuota(user, p) for p in printers ]
+                upquotas = [ cmd.storage.getUserPQuotaFromBackend(user, p) for p in printers ] # don't use cache
                 nblines = len(upquotas)
-                display = pyosd.osd(colour="#00FF00", timeout=DURATION, shadow=2, lines=nblines)
+                display = pyosd.osd(colour="#00FF00", timeout=duration, shadow=2, lines=nblines)
                 for line in range(nblines) :
                     upq = upquotas[line]
@@ -73,5 +133,5 @@
                     else :        
                         percent = "%s%%" % min((upq.PageCounter * 100) / upq.HardLimit, 100)
-                    display.display("Pages used on %s : %s" % (upq.Printer.Name, percent), type=pyosd.TYPE_STRING, line=line)
+                    display.display(_("Pages used on %s : %s") % (upq.Printer.Name, percent), type=pyosd.TYPE_STRING, line=line)
             else :
                 if user.AccountBalance <= 0 :
@@ -79,14 +139,58 @@
                 else :    
                     color = "#00FF00"
-                display = pyosd.osd(colour=color, timeout=DURATION, shadow=2)
-                display.display("PyKota Units left : %.2f" % user.AccountBalance, type=pyosd.TYPE_STRING)    
-            time.sleep(DURATION + 1)
-        except :
-            cmd.crashed("Strange problem : please report it ASAP to alet@librelogiciel.com")
-        else :
-            retcode = 0
+                display = pyosd.osd(colour=color, timeout=duration, shadow=2)
+                display.display(_("PyKota Units left : %.2f") % user.AccountBalance, type=pyosd.TYPE_STRING)
+            time.sleep(duration + 1)
+            if loop :
+                loop -= 1
+                if not loop :
+                    break
+            time.sleep(sleep)        
+            
+        return 0    
+        
+if __name__ == "__main__" :
+    retcode = -1
+    try :
+        defaults = { \
+                     "duration" : "3", \
+                     "loop" : "0", \
+                     "sleep" : "180", \
+                   }
+        short_options = "hvd:l:s:"
+        long_options = ["help", "version", "duration=", "loop=", "sleep="]
+        
+        cmd = PyKOSD(doc=__doc__)
+        
+        # parse and checks the command line
+        (options, args) = cmd.parseCommandline(sys.argv[1:], short_options, long_options, allownothing=1)
+        
+        # sets long options
+        options["help"] = options["h"] or options["help"]
+        options["version"] = options["v"] or options["version"]
+        options["duration"] = options["d"] or options["duration"] or defaults["duration"]
+        options["loop"] = options["l"] or options["loop"] or defaults["loop"]
+        options["sleep"] = options["s"] or options["sleep"] or defaults["sleep"]
+        
+        if options["help"] :
+            cmd.display_usage_and_quit()
+        elif options["version"] :
+            cmd.display_version_and_quit()
+        else :    
+            retcode = cmd.main(args, options)
+    except KeyboardInterrupt :
+        retcode = 0
+    except SystemExit :        
+        pass
+    except :    
         try :
-            cmd.storage.close()
+            cmd.crashed("pykosd failed")
         except :    
-            pass
+            crashed("pykosd failed")
+        
+    try :
+        cmd.storage.close()
+    except :    
+        pass
+        
     sys.exit(retcode)
Index: /pykota/trunk/man/edpykota.1
===================================================================
--- /pykota/trunk/man/edpykota.1 (revision 1582)
+++ /pykota/trunk/man/edpykota.1 (revision 1605)
@@ -2,7 +2,7 @@
 .TH EDPYKOTA "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-edpykota \- manual page for edpykota 1.19alpha28_unofficial
+edpykota \- manual page for edpykota 1.19alpha33_unofficial
 .SH DESCRIPTION
-edpykota v1.19alpha28_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+edpykota v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 A Print Quota editor for PyKota.
 .PP
Index: /pykota/trunk/man/pkprinters.1
===================================================================
--- /pykota/trunk/man/pkprinters.1 (revision 1582)
+++ /pykota/trunk/man/pkprinters.1 (revision 1605)
@@ -2,7 +2,7 @@
 .TH PKPRINTERS "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-pkprinters \- manual page for pkprinters 1.19alpha28_unofficial
+pkprinters \- manual page for pkprinters 1.19alpha33_unofficial
 .SH DESCRIPTION
-pkprinters v1.19alpha28_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+pkprinters v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 A Printers Manager for PyKota.
 .PP
Index: /pykota/trunk/man/pykotme.1
===================================================================
--- /pykota/trunk/man/pykotme.1 (revision 1582)
+++ /pykota/trunk/man/pykotme.1 (revision 1605)
@@ -2,7 +2,7 @@
 .TH PYKOTME "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-pykotme \- manual page for pykotme 1.19alpha28_unofficial
+pykotme \- manual page for pykotme 1.19alpha33_unofficial
 .SH DESCRIPTION
-pykotme v1.19alpha28_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+pykotme v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 .PP
 Gives print quotes to users.
Index: /pykota/trunk/man/pykosd.1
===================================================================
--- /pykota/trunk/man/pykosd.1 (revision 1605)
+++ /pykota/trunk/man/pykosd.1 (revision 1605)
@@ -0,0 +1,55 @@
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.33.
+.TH PYKOSD "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
+.SH NAME
+pykosd \- manual page for pykosd 1.19alpha33_unofficial
+.SH DESCRIPTION
+pykosd v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+An OSD quota monitor for PyKota.
+.PP
+command line usage :
+.IP
+pykosd [options]
+.PP
+options :
+.TP
+\fB\-v\fR | \fB\-\-version\fR
+Prints pkprinters's version number then exits.
+.TP
+\fB\-h\fR | \fB\-\-help\fR
+Prints this message then exits.
+.TP
+\fB\-d\fR | \fB\-\-duration\fR d
+Sets the duration of the display in seconds.
+Defaults to 3 seconds.
+.TP
+\fB\-l\fR | \fB\-\-loop\fR n
+Sets the number of times the info will be displayed.
+Defaults to 0, which means loop forever.
+.TP
+\fB\-s\fR | \fB\-\-sleep\fR s
+Sets the sleeping duration between two displays
+in seconds. Defaults to 180 seconds (3 minutes).
+.PP
+examples :
+.IP
+\f(CW$ pykosd -s 60 --loop 5\fR
+.IP
+Will launch pykosd. Display will be refreshed every 60 seconds,
+and will last for 3 seconds (the default) each time. After five
+iterations, the program will exit.
+.PP
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+.PP
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+.PP
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+.PP
+Please e-mail bugs to: Jerome Alet - alet@librelogiciel.com
Index: /pykota/trunk/man/Makefile.am
===================================================================
--- /pykota/trunk/man/Makefile.am (revision 1430)
+++ /pykota/trunk/man/Makefile.am (revision 1605)
@@ -9,4 +9,5 @@
 	waitprinter.sh.1	\
 	pkpgcounter.1	\
+	pykosd.1	\
 	warnpykota.1
 
Index: /pykota/trunk/man/pkhint.1
===================================================================
--- /pykota/trunk/man/pkhint.1 (revision 1582)
+++ /pykota/trunk/man/pkhint.1 (revision 1605)
@@ -2,7 +2,7 @@
 .TH PKHINT "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-pkhint \- manual page for pkhint 1.19alpha28_unofficial
+pkhint \- manual page for pkhint 1.19alpha33_unofficial
 .SH DESCRIPTION
-pkhint v1.19alpha28_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+pkhint v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 A tool to give hints on what accounting method is best for each printer.
 .PP
Index: /pykota/trunk/man/repykota.1
===================================================================
--- /pykota/trunk/man/repykota.1 (revision 1582)
+++ /pykota/trunk/man/repykota.1 (revision 1605)
@@ -2,7 +2,7 @@
 .TH REPYKOTA "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-repykota \- manual page for repykota 1.19alpha28_unofficial
+repykota \- manual page for repykota 1.19alpha33_unofficial
 .SH DESCRIPTION
-repykota v1.19alpha28_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+repykota v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 .PP
 Generates print quota reports.
Index: /pykota/trunk/man/genman.sh
===================================================================
--- /pykota/trunk/man/genman.sh (revision 1338)
+++ /pykota/trunk/man/genman.sh (revision 1605)
@@ -14,5 +14,5 @@
 # $Id$
 #
-for prog in edpykota pykotme repykota warnpykota pkprinters pkhint ; do 
+for prog in edpykota pykotme repykota warnpykota pkprinters pkhint pykosd ; do 
     help2man --section=1 --manual "User Commands" --source="C@LL - Conseil Internet & Logiciels Libres" --output=$prog.1 --no-info $prog ; 
 done
Index: /pykota/trunk/man/warnpykota.1
===================================================================
--- /pykota/trunk/man/warnpykota.1 (revision 1582)
+++ /pykota/trunk/man/warnpykota.1 (revision 1605)
@@ -2,7 +2,7 @@
 .TH WARNPYKOTA "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-warnpykota \- manual page for warnpykota 1.19alpha28_unofficial
+warnpykota \- manual page for warnpykota 1.19alpha33_unofficial
 .SH DESCRIPTION
-warnpykota v1.19alpha28_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+warnpykota v1.19alpha33_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 .PP
 Sends mail to users over print quota.
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1604)
+++ /pykota/trunk/NEWS (revision 1605)
@@ -22,4 +22,11 @@
 PyKota NEWS :
 
+
+    - 1.19alpha33 :
+    
+        - pykosd now accepts command line arguments. Enjoy !
+          NB : due to a bug in xosd, you need xosd version 2.2.8
+          or higher if you don't use the default C locale.
+          
     - 1.19alpha32 :
     
