Show
Ignore:
Timestamp:
05/21/05 00:40:21 (19 years ago)
Author:
jerome
Message:

Now dumpykota and dumpykota.cgi accept start= and end=
to specify the starting and ending dates when dumping the
history.
Syntax allowed is :

start|end=YYYY[MM[DD[hh[mm[ss]]]]]

and this is REALLY powerful !

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2222 r2266  
    10441044            self.doModify(pgroup.ident, fields)          
    10451045             
    1046     def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, billingcode=None, limit=100) : 
    1047         """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results.""" 
     1046    def retrieveHistory(self, user=None, printer=None, hostname=None, billingcode=None, limit=100, start=None, end=None) : 
     1047        """Retrieves all print jobs for user on printer (or all) between start and end date, limited to first 100 results.""" 
    10481048        precond = "(objectClass=pykotaJob)" 
    10491049        where = [] 
     
    11101110                minute = int(date[10:12]) 
    11111111                second = int(date[12:14]) 
    1112                 job.JobDate = "%04i-%02i-%02i %02i:%02i:%02i" % (year, month, day, hour, minute, second) 
    1113                 if (datelimit is None) or (job.JobDate <= datelimit) : 
     1112                job.JobDate = "%04i%02i%02i %02i:%02i:%02i" % (year, month, day, hour, minute, second) 
     1113                if ((start is None) and (end is None)) or \ 
     1114                   ((start is None) and (job.JobDate <= end)) or \ 
     1115                   ((end is None) and (job.JobDate >= start)) or \ 
     1116                   ((job.JobDate >= start) and (job.JobDate <= end)) : 
    11141117                    job.UserName = fields.get("pykotaUserName")[0] 
    11151118                    job.PrinterName = fields.get("pykotaPrinterName")[0] 
     
    13351338        else :     
    13361339            printer = None 
    1337         entries = self.retrieveHistory(user, printer, hostname=extractonly.get("hostname"), billingcode=extractonly.get("billingcode"), limit=None) 
     1340        startdate = extractonly.get("start") 
     1341        enddate = extractonly.get("end") 
     1342        for limit in ("start", "end") : 
     1343            try : 
     1344                del extractonly[limit] 
     1345            except KeyError :     
     1346                pass 
     1347        (startdate, enddate) = self.cleanDates(startdate, enddate) 
     1348        entries = self.retrieveHistory(user, printer, hostname=extractonly.get("hostname"), billingcode=extractonly.get("billingcode"), limit=None, start=startdate, end=enddate) 
    13381349        if entries : 
    13391350            result = [ ("username", "printername", "dn", "jobid", "pagecounter", "jobsize", "action", "jobdate", "filename", "title", "copies", "options", "jobprice", "hostname", "jobsizebytes", "md5sum", "pages", "billingcode") ]