Changeset 1239

Show
Ignore:
Timestamp:
12/27/03 16:43:36 (21 years ago)
Author:
uid67467
Message:

Savannah is back online...

Location:
pykota/trunk
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/cgi-bin/printquota.cgi

    r1235 r1239  
    1 #! /usr/bin/python 
     1#! /usr/bin/python2.2 
    22 
    33# PyKota Print Quota Reports generator 
     
    2323# 
    2424# $Log$ 
     25# Revision 1.17  2003/12/27 15:43:36  uid67467 
     26# Savannah is back online... 
     27# 
    2528# Revision 1.16  2003/12/02 14:40:20  jalet 
    2629# Some code refactoring. 
     
    9194  <head> 
    9295    <title>PyKota Reports</title> 
     96    <link rel="stylesheet" type="text/css" href="pykota.css" /> 
    9397  </head> 
    9498  <body> 
     
    104108          </td> 
    105109          <td colspan="2"> 
    106             <h2>PyKota Reports</h2> 
     110            <h1>PyKota Reports</h1> 
    107111          </td> 
    108112        </tr> 
  • pykota/trunk/NEWS

    r1235 r1239  
    2222PyKota NEWS : 
    2323 
    24     - 1.16alpah16 : 
     24    - 1.16alpha17 : 
     25     
     26        - Added portugues translation. 
     27         
     28        - Major code refactoring in accounters. 
     29         
     30    - 1.16alpha16 : 
    2531     
    2632        - Code refactoring, and addition of a real HTML reporter, to  
  • pykota/trunk/po/en/pykota.po

    r1192 r1239  
    2121# 
    2222# $Log$ 
     23# Revision 1.37  2003/12/27 15:43:36  uid67467 
     24# Savannah is back online... 
     25# 
    2326# Revision 1.36  2003/11/18 23:43:11  jalet 
    2427# Mailto can be any external command now, as usual. 
     
    206209msgstr "" 
    207210 
    208 msgid "*** Report for %s quota on printer %s" 
     211msgid "Report for %s quota on printer %s" 
    209212msgstr "" 
    210213 
  • pykota/trunk/po/es/pykota.po

    r1238 r1239  
    2121# 
    2222# $Log$ 
     23# Revision 1.5  2003/12/27 15:43:36  uid67467 
     24# Savannah is back online... 
     25# 
    2326# Revision 1.4  2003/12/03 18:51:09  jalet 
    2427# Fixed spanish translation 
     
    9194msgstr "Impresora %s no encontrada" 
    9295 
    93 msgid "*** Report for %s quota on printer %s" 
    94 msgstr "*** Reporte para la cuota %s en la impresora  %s" 
     96msgid "Report for %s quota on printer %s" 
     97msgstr "Reporte para la cuota %s en la impresora  %s" 
    9598 
    9699msgid "Error in page count value %i for user %s on printer %s" 
  • pykota/trunk/po/fr/pykota.po

    r1192 r1239  
    2121# 
    2222# $Log$ 
     23# Revision 1.36  2003/12/27 15:43:36  uid67467 
     24# Savannah is back online... 
     25# 
    2326# Revision 1.35  2003/11/18 23:43:12  jalet 
    2427# Mailto can be any external command now, as usual. 
     
    209212msgstr "Aucune imprimante ne correspond �s" 
    210213 
    211 msgid "*** Report for %s quota on printer %s" 
    212 msgstr "*** Rapport pour le quota %s sur l'imprimante %s" 
     214msgid "Report for %s quota on printer %s" 
     215msgstr "Rapport pour le quota %s sur l'imprimante %s" 
    213216 
    214217msgid "Error in page count value %i for user %s on printer %s" 
  • pykota/trunk/po/pykota.pot

    r1192 r1239  
    2121# 
    2222# $Log$ 
     23# Revision 1.37  2003/12/27 15:43:36  uid67467 
     24# Savannah is back online... 
     25# 
    2326# Revision 1.36  2003/11/18 23:43:11  jalet 
    2427# Mailto can be any external command now, as usual. 
     
    206209msgstr "" 
    207210 
    208 msgid "*** Report for %s quota on printer %s" 
     211msgid "Report for %s quota on printer %s" 
    209212msgstr "" 
    210213 
  • pykota/trunk/pykota/accounter.py

    r1219 r1239  
    2222# 
    2323# $Log$ 
     24# Revision 1.8  2003/12/27 15:43:36  uid67467 
     25# Savannah is back online... 
     26# 
    2427# Revision 1.7  2003/11/25 23:46:40  jalet 
    2528# Don't try to verify if module name is valid, Python does this better than us. 
     
    8992            infile.close() 
    9093             
    91     def doAccounting(self, printer, user) :     
    92         """Does the real accounting.""" 
    93         raise PyKotaAccounterError, "Accounter not implemented !" 
     94    def beginJob(self, printer, user) :     
     95        """Saves the computed job size.""" 
     96        # computes job's size 
     97        self.JobSize = self.computeJobSize() 
     98         
     99        # get last job information for this printer 
     100        if not printer.LastJob.Exists : 
     101            # The printer hasn't been used yet, from PyKota's point of view 
     102            self.LastPageCounter = 0 
     103        else :     
     104            # get last job size and page counter from Quota Storage 
     105            # Last lifetime page counter before actual job is  
     106            # last page counter + last job size 
     107            self.LastPageCounter = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 
     108         
     109    def endJob(self, printer, user) :     
     110        """Do nothing.""" 
     111        pass 
     112         
     113    def getJobSize(self) :     
     114        """Returns the actual job size.""" 
     115        try : 
     116            return self.JobSize 
     117        except AttributeError :     
     118            return 0 
     119         
     120    def doAccounting(self, printer, user) : 
     121        """Deletgates the computation of the job size to an external command. 
     122         
     123           The command must print the job size on its standard output and exit successfully. 
     124        """ 
     125        self.beginJob(printer, user) 
     126         
     127        # get the job size, which is real job size * number of copies. 
     128        jobsize = self.getJobSize() * self.filter.copies 
     129             
     130        # Is the current user allowed to print at all ? 
     131        userpquota = self.filter.storage.getUserPQuota(user, printer) 
     132        action = self.filter.warnUserPQuota(userpquota) 
     133         
     134        # update the quota for the current user on this printer, if allowed to print 
     135        if action == "DENY" : 
     136            jobsize = 0 
     137        else :     
     138            userpquota.increasePagesUsage(jobsize) 
     139         
     140        # adds the current job to history     
     141        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 
     142        printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
     143        self.endJob(printer, user) 
     144        return action 
    94145         
    95146def openAccounter(kotafilter) : 
  • pykota/trunk/pykota/accounters/external.py

    r1203 r1239  
    2222# 
    2323# $Log$ 
     24# Revision 1.11  2003/12/27 15:43:36  uid67467 
     25# Savannah is back online... 
     26# 
    2427# Revision 1.10  2003/11/23 19:01:36  jalet 
    2528# Job price added to history 
     
    6366 
    6467class Accounter(AccounterBase) : 
    65     def beginJob(self, printer, user) :     
    66         """Saves the computed job size.""" 
    67         # computes job's size 
    68         self.JobSize = self.computeJobSize() 
    69          
    70         # get last job information for this printer 
    71         if not printer.LastJob.Exists : 
    72             # The printer hasn't been used yet, from PyKota's point of view 
    73             self.LastPageCounter = 0 
    74         else :     
    75             # get last job size and page counter from Quota Storage 
    76             # Last lifetime page counter before actual job is  
    77             # last page counter + last job size 
    78             self.LastPageCounter = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 
    79          
    80     def endJob(self, printer, user) :     
    81         """Do nothing.""" 
    82         pass 
    83          
    84     def getJobSize(self) :     
    85         """Returns the actual job size.""" 
    86         try : 
    87             return self.JobSize 
    88         except AttributeError :     
    89             return 0 
    90          
    91     def doAccounting(self, printer, user) : 
    92         """Deletgates the computation of the job size to an external command. 
    93          
    94            The command must print the job size on its standard output and exit successfully. 
    95         """ 
    96         self.beginJob(printer, user) 
    97          
    98         # get the job size, which is real job size * number of copies. 
    99         jobsize = self.getJobSize() * self.filter.copies 
    100              
    101         # Is the current user allowed to print at all ? 
    102         userpquota = self.filter.storage.getUserPQuota(user, printer) 
    103         action = self.filter.warnUserPQuota(userpquota) 
    104          
    105         # update the quota for the current user on this printer, if allowed to print 
    106         if action == "DENY" : 
    107             jobsize = 0 
    108         else :     
    109             userpquota.increasePagesUsage(jobsize) 
    110          
    111         # adds the current job to history     
    112         jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 
    113         printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
    114          
    115         self.endJob(printer, user) 
    116              
    117         return action 
    118          
    11968    def computeJobSize(self) :     
    12069        """Feeds an external command with our datas to let it compute the job size, and return its value.""" 
     
    181130        else : 
    182131            infile.close() 
    183              
    184132        return pagecount     
    185133             
  • pykota/trunk/pykota/accounters/querying.py

    r1200 r1239  
    2222# 
    2323# $Log$ 
     24# Revision 1.9  2003/12/27 15:43:36  uid67467 
     25# Savannah is back online... 
     26# 
    2427# Revision 1.8  2003/11/21 14:28:46  jalet 
    2528# More complete job history. 
     
    182185        # adds the current job to history     
    183186        printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, filename=self.filter.preserveinputfile, title=self.filter.title, copies=self.filter.copies, options=self.filter.options) 
    184              
    185187        return action 
    186188             
  • pykota/trunk/pykota/accounters/stupid.py

    r1203 r1239  
    2222# 
    2323# $Log$ 
     24# Revision 1.9  2003/12/27 15:43:36  uid67467 
     25# Savannah is back online... 
     26# 
    2427# Revision 1.8  2003/11/23 19:01:37  jalet 
    2528# Job price added to history 
     
    5558 
    5659class Accounter(AccounterBase) : 
    57     def beginJob(self) :     
    58         """Saves the computed job size.""" 
    59         self.JobSize = self.computeJobSize() 
    60          
    61         # get last job information for this printer 
    62         if not printer.LastJob.Exists : 
    63             # The printer hasn't been used yet, from PyKota's point of view 
    64             self.LastPageCounter = 0 
    65         else :     
    66             # get last job size and page counter from Quota Storage 
    67             # Last lifetime page counter before actual job is  
    68             # last page counter + last job size 
    69             self.LastPageCounter = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 
    70          
    71     def endJob(self) :     
    72         """Do nothing.""" 
    73         pass 
    74          
    75     def getJobSize(self) :     
    76         """Returns the actual job size.""" 
    77         try : 
    78             return self.JobSize 
    79         except AttributeError :     
    80             return 0 
    81          
    82     def doAccounting(self, printer, user) : 
    83         """Does print accounting by stupidly counting the 'showpage' postscript instructions in the document. 
    84          
    85            This method is essentially unreliable, but shows how to create a simple accounter. 
    86         """ 
    87         # first we log a message because using this accounting method is not recommended. 
    88         self.filter.logger.log_message(_("Using the 'stupid' accounting method is unreliable."), "warn") 
    89          
    90         # get the job size     
    91         jobsize = self.computeJobSize() * self.filter.copies 
    92              
    93         # get last job information for this printer 
    94         if not printer.LastJob.Exists : 
    95             # The printer hasn't been used yet, from PyKota's point of view 
    96             counterbeforejob = 0 
    97         else :     
    98             # get last job size and page counter from Quota Storage 
    99             # Last lifetime page counter before actual job is  
    100             # last page counter + last job size 
    101             counterbeforejob = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 
    102              
    103         # Is the current user allowed to print at all ? 
    104         userpquota = self.filter.storage.getUserPQuota(user, printer) 
    105         action = self.filter.warnUserPQuota(userpquota) 
    106          
    107         # update the quota for the current user on this printer, if allowed to print 
    108         if action == "DENY" : 
    109             jobsize = 0 
    110         else :     
    111             userpquota.increasePagesUsage(jobsize) 
    112          
    113         # adds the current job to history     
    114         jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 
    115         printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
    116              
    117         return action 
    118          
    11960    def computeJobSize(self) :     
    12061        """Computes the job size and return its value. 
     
    12263           THIS METHOD IS COMPLETELY UNRELIABLE BUT SERVES AS AN EXAMPLE. 
    12364        """ 
     65        # first we log a message because using this accounting method is not recommended. 
     66        self.filter.logger.log_message(_("Using the 'stupid' accounting method is unreliable."), "warn") 
     67         
    12468        temporary = None     
    12569        if self.filter.inputfile is None :     
     
    14690        else : 
    14791            infile.close() 
    148              
    14992        return pagecount     
    150              
  • pykota/trunk/pykota/reporter.py

    r1235 r1239  
    2222# 
    2323# $Log$ 
     24# Revision 1.5  2003/12/27 15:43:36  uid67467 
     25# Savannah is back online... 
     26# 
    2427# Revision 1.4  2003/12/02 14:40:21  jalet 
    2528# Some code refactoring. 
     
    5861         
    5962    def getPrinterTitle(self, printer) :      
    60         return _("*** Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name) 
     63        return _("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name) 
    6164         
    6265    def getPrinterGraceDelay(self, printer) :     
  • pykota/trunk/pykota/reporters/html.py

    r1236 r1239  
    2222# 
    2323# $Log$ 
     24# Revision 1.2  2003/12/27 15:43:36  uid67467 
     25# Savannah is back online... 
     26# 
    2427# Revision 1.1  2003/12/02 14:41:17  jalet 
    2528# And as always, I forgot most of the new files :-) 
     
    3841        self.report = [] 
    3942        for printer in self.printers : 
    40             self.report.append("<h1>%s</h1>" % self.getPrinterTitle(printer)) 
    41             self.report.append("<h2>%s</h2>" % self.getPrinterGraceDelay(printer)) 
     43            self.report.append('<h2 class="printername">%s</h2>' % self.getPrinterTitle(printer)) 
     44            self.report.append('<h3 class="printergracedelay">%s</h3>' % self.getPrinterGraceDelay(printer)) 
    4245            (pjob, ppage) = self.getPrinterPrices(printer) 
    43             self.report.append("<h3>%s</h3>" % pjob) 
    44             self.report.append("<h3>%s</h3>" % ppage) 
     46            self.report.append('<h4 class="priceperjob">%s</h4>' % pjob) 
     47            self.report.append('<h4 class="priceperpage">%s</h4>' % ppage) 
    4548            total = 0 
    4649            totalmoney = 0.0 
    47             self.report.append('<table border="1">') 
     50            self.report.append('<table class="pykotatable" border="1">') 
    4851            headers = self.getReportHeader().split() 
    49             headers.insert(1, "LimitBy") 
    50             self.report.append('<tr bgcolor="gold">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 
     52            headers.insert(1, "LimitBy") 
     53            self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 
     54            oddeven = 0 
    5155            if self.isgroup : 
    5256                for (group, grouppquota) in self.tool.storage.getPrinterGroupsAndQuotas(printer, self.ugnames) : 
     57                    oddeven += 1 
     58                    if oddeven % 1 : 
     59                        oddevenclass = "odd" 
     60                    else :     
     61                        oddevenclass = "even" 
    5362                    (pages, money, name, reached, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(group, grouppquota) 
    54                     self.report.append("<tr>%s</tr>" % "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)])) 
     63                    self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)]))) 
    5564                    total += pages 
    5665                    totalmoney += money 
     
    5867                # default is user quota report 
    5968                for (user, userpquota) in self.tool.storage.getPrinterUsersAndQuotas(printer, self.ugnames) : 
     69                    oddeven += 1 
     70                    if oddeven % 1 : 
     71                        oddevenclass = "odd" 
     72                    else :     
     73                        oddevenclass = "even" 
    6074                    (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(user, userpquota) 
    61                     self.report.append("<tr>%s</tr>" % "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)])) 
     75                    self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)]))) 
    6276                    total += pages 
    6377                    totalmoney += money 
    6478            if total or totalmoney :         
    6579                (tpage, tmoney) = self.getTotals(total, totalmoney) 
    66                 self.report.append('<tr><td colspan="7">&nbsp;</td><td align="right">%s</td><td align="right">%s</td></tr>' % (tpage, tmoney)) 
    67             self.report.append('<tr><td colspan="7">&nbsp;</td><td align="right">%s</td></tr>' % self.getPrinterRealPageCounter(printer)) 
     80                self.report.append('<tr class="totals"><td colspan="7">&nbsp;</td><td align="right">%s</td><td align="right">%s</td></tr>' % (tpage, tmoney)) 
     81            self.report.append('<tr class="realpagecounter"><td colspan="7">&nbsp;</td><td align="right">%s</td></tr>' % self.getPrinterRealPageCounter(printer)) 
    6882            self.report.append('</table>') 
    6983        if self.isgroup :     
    70             self.report.append("<p>%s</p>" % _("Totals may be inaccurate if some users are members of several groups.")) 
     84            self.report.append('<p class="warning">%s</p>' % _("Totals may be inaccurate if some users are members of several groups.")) 
    7185        return "\n".join(self.report)     
    7286                         
  • pykota/trunk/pykota/version.py

    r1227 r1239  
    2222# 
    2323 
    24 __version__ = "1.16alpha16_unofficial" 
     24__version__ = "1.16alpha17_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""