Changeset 887 for pykota

Show
Ignore:
Timestamp:
04/08/03 22:38:08 (22 years ago)
Author:
jalet
Message:

The last job Id is saved now for each printer, this will probably
allow other accounting methods in the future.

Location:
pykota/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykota

    r873 r887  
    2323# 
    2424# $Log$ 
     25# Revision 1.16  2003/04/08 20:38:08  jalet 
     26# The last job Id is saved now for each printer, this will probably 
     27# allow other accounting methods in the future. 
     28# 
    2529# Revision 1.15  2003/03/29 13:45:27  jalet 
    2630# GPL paragraphs were incorrectly (from memory) copied into the sources. 
     
    131135         
    132136    #     
     137    # According to CUPS documentation, the job id is the second command line argument 
     138    jobid = sys.argv[1].strip() 
     139     
     140    #     
    133141    # According to CUPS documentation, the username is the third command line argument 
    134142    username = sys.argv[2].strip()     
     
    155163    else :     
    156164        # get last values from Quota Storage 
    157         (lastpagecounter, lastusername) = (pgc["pagecounter"], pgc["lastusername"]) 
     165        (lastpagecounter, lastjobid, lastusername) = (pgc["pagecounter"], pgc["lastjobid"], pgc["lastusername"]) 
    158166         
    159167        # if printer is off then we assume the correct counter value is the last one 
     
    163171        # Update the last page counter and last username in the Quota Storage backend 
    164172        # set them to current user and  
    165         kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob) 
     173        kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob, jobid) 
    166174         
    167175        # Was the printer ever used ? 
  • pykota/trunk/initscripts/pykota-postgresql.sql

    r873 r887  
    2020-- 
    2121-- $Log$ 
     22-- Revision 1.7  2003/04/08 20:38:08  jalet 
     23-- The last job Id is saved now for each printer, this will probably 
     24-- allow other accounting methods in the future. 
     25-- 
    2226-- Revision 1.6  2003/03/29 13:45:27  jalet 
    2327-- GPL paragraphs were incorrectly (from memory) copied into the sources. 
     
    8488CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL, 
    8589                      printername TEXT UNIQUE NOT NULL, 
     90                      lastjobid TEXT, 
    8691                      lastusername TEXT, 
    8792                      pagecounter INT4 DEFAULT 0); 
  • pykota/trunk/initscripts/README

    r873 r887  
    2222This directory contains scripts to initialise the PyKota 
    2323storage database. Use the one which best suits your need 
    24 depending on the storage backend you want to use. Each 
    25 script has an associated README file, be sure to read  
    26 this as well : 
     24depending on the storage backend you want to use. 
    2725 
    28         File                            Backend 
    29         -------------------------------------------------- 
    30          pykota-posgresql.sql | PostgreSQL storage 
    31 pykota-upgrade-postgresql.sql | Upgrade database schema from pre 1.01 
    32                               | 
    33          
    34 ============================================================ 
     26 
     27Files : 
     28======= 
     29 
     30  * pykota-postgresql.sql : 
     31   
     32    This file creates an empty Quota Storage Database, using PostgreSQL 
     33    as a backend. You have to use it the first time you install PyKota 
     34    if you want to use PostgreSQL as the Quota Storage Backend. 
     35     
     36  * pykota-upgrade-postgresql.sql : 
     37   
     38    This files upgrades the PostgreSQL Quota Storage Database schema 
     39    from versions before 1.01 to version 1.01. 
     40     
     41  * upgrade-1.01-to-1.03.sh : 
     42   
     43    This shell script upgrades the PostgreSQL Quota Storage Database schema 
     44    from versions 1.01 or 1.02 to version 1.03. 
     45    PLEASE DO A BACKUP OF YOUR PYKOTA DATABASE BEFORE RUNNING THIS SCRIPT ! 
     46    Also this script will try to connect to PostgreSQL as the postgres user 
     47    (i.e. PostgreSQL's administrator), on the local machine (PyKota Storage  
     48    Server), without prompting for a password. Please read this script and  
     49    adapt it to your own configuration before running it. THIS IS IMPORTANT. 
     50   
  • pykota/trunk/initscripts/README.postgresql

    r880 r887  
    2727 
    2828If you have already installed PyKota, and have datas in your 
    29 Quota Storage DataBase, you may prefer to  skip this section 
     29Quota Storage DataBase, you may prefer to skip this section 
    3030and read the next one. 
    3131 
     
    4949============================================================ 
    5050 
    51 Upgrade script : 
     51Upgrade scripts : 
    5252 
    53   An sql script to upgrade a pre-1.01 PyKota Quota Storage  
    54   DataBase is included, if you want to keep your datas from 
    55   a pre-1.01 PyKota version, then please launch the following 
    56   commands : 
     53  Some scripts to upgrade old PyKota databases to the new 
     54  database schema are included. You may have to run all 
     55  of them or only some of them, depending on your  
     56  version of PyKota. 
     57   
     58* An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to  
     59  1.01 is included. If your PyKota version is equal or higher than 1.01 then 
     60  you can skip to the next section. Otherwise, if you want to keep your datas 
     61  from a pre-1.01 PyKota version, then please launch the following commands :  
    5762   
    5863        - Launch the psql frontend and connect to the 
     
    7681  to run this upgrade script. 
    7782   
    78 WARNING :   
     83  WARNING :   
    7984 
    8085  This script requires a recent version of PostgreSQL to run 
     
    8590  fields are pagecounter and lifepagecounter, just forgot them. 
    8691   
    87 IMPORTANT : 
    88  
    89   Because the modifications are just about Group Print Quotas 
    90   and because Group Print Quotas are currently not fully    
    91   implemented, you can delay the launch of this upgrade 
    92   script until you really need Group Print Quotas. 
    93   In other terms, running this script is not mandatory 
    94   for PyKota to continue to work correctly, at least 
    95   until Group Print Quotas will be fully implemented. 
    96    
     92* If you are already running PyKota 1.01 or 1.02 and want to upgrade to  
     93  1.03, YOU HAVE TO RUN the upgrade-1.01-to-1.03.sh shell script. 
     94  NOT LAUNCHING THIS SCRIPT WILL CAUSE PYKOTA TO STOP WORKING ! 
     95  Please don't run this script if your version of PyKota is already 
     96  1.03 or higher. 
  • pykota/trunk/NEWS

    r885 r887  
    2424    - 1.03alpha : 
    2525     
     26        - IMPORTANT : DataBase schema has changed, YOU HAVE TO 
     27          UPGRADE using the upgrade-1.01-to-1.03.sh script. 
     28          Please read initscripts/README first and then  
     29          read initscripts/README.postgresql 
     30           
    2631        - The installation script now allows to install the sample 
    2732          configuration file during first installation. 
  • pykota/trunk/pykota/storages/sql.py

    r873 r887  
    2121# 
    2222# $Log$ 
     23# Revision 1.21  2003/04/08 20:38:08  jalet 
     24# The last job Id is saved now for each printer, this will probably 
     25# allow other accounting methods in the future. 
     26# 
    2327# Revision 1.20  2003/03/29 13:45:27  jalet 
    2428# GPL paragraphs were incorrectly (from memory) copied into the sources. 
     
    148152    def getPrinterPageCounter(self, printername) : 
    149153        """Returns the last page counter value for a printer given its name.""" 
    150         result = self.doQuery("SELECT pagecounter, lastusername FROM printers WHERE printername=%s;" % self.doQuote(printername)) 
     154        result = self.doQuery("SELECT pagecounter, lastjobid, lastusername FROM printers WHERE printername=%s;" % self.doQuote(printername)) 
    151155        try : 
    152156            return self.doParseResult(result)[0] 
     
    154158            return 
    155159         
    156     def updatePrinterPageCounter(self, printername, username, pagecount) : 
    157         """Updates the last page counter information for a printer given its name, last username and pagecount.""" 
    158         return self.doQuery("UPDATE printers SET pagecounter=%s, lastusername=%s WHERE printername=%s;" % (self.doQuote(pagecount), self.doQuote(username), self.doQuote(printername))) 
     160    def updatePrinterPageCounter(self, printername, username, pagecount, jobid) : 
     161        """Updates the last page counter information for a printer given its name, last username, pagecount and jobid.""" 
     162        return self.doQuery("UPDATE printers SET pagecounter=%s, lastusername=%s, lastjobid=%s WHERE printername=%s;" % (self.doQuote(pagecount), self.doQuote(username), self.doQuote(jobid), self.doQuote(printername))) 
    159163         
    160164    def addUserPQuota(self, username, printername) : 
  • pykota/trunk/README

    r882 r887  
    110110============= 
    111111 
     112WARNING : 
     113========= 
     114 
     115  If you run a PyKota version lower than 1.01, you definitely have to  
     116  upgrade you Quota Storage Database. Please read the documentation  
     117  included in the initscripts subdirectory first !  
     118   
    112119Prerequisite :  
    113120--------------