Changeset 1451

Show
Ignore:
Timestamp:
05/06/04 14:37:47 (20 years ago)
Author:
jalet
Message:

pkpgcounter : comments
pkprinters : when --add is used, existing printers are now skipped.

Location:
pykota/trunk
Files:
1 added
15 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkpgcounter

    r1449 r1451  
    2424# 
    2525# $Log$ 
     26# Revision 1.5  2004/05/06 12:37:29  jalet 
     27# pkpgcounter : comments 
     28# pkprinters : when --add is used, existing printers are now skipped. 
     29# 
    2630# Revision 1.4  2004/05/04 12:21:55  jalet 
    2731# Now uses mmap in PCL mode 
     
    8892    # Backported from C to Python by Jerome Alet, then enhanced 
    8993    # with more PCL tags detected. I think all the necessary PCL tags 
    90     # are recognized to correctly handle PCL5e files wrt their number 
    91     # of pages 
    92     #  
     94    # are recognized to correctly handle PCL5 files wrt their number 
     95    # of pages. The documentation used for this was : 
     96    # 
     97    # HP PCL/PJL Reference Set 
     98    # PCL5 Printer Language Technical Quick Reference Guide 
     99    # http://h20000.www2.hp.com/bc/docs/support/SupportManual/bpl13205/bpl13205.pdf  
     100    # 
    93101    infileno = infile.fileno() 
    94102    infile = mmap.mmap(infileno, os.fstat(infileno).st_size, access=mmap.ACCESS_READ) 
    95     tagsends = { "&n" : "W", "&b": "W", "*i" : "W", "*l" : "W", "*m" : "W", "*v": "W", "*c" : "W", "(f" : "W", "*b" : "VW", "(s" : "W", ")s" : "W", "&p" : "X", "&l" : "X" }  
     103    tagsends = { "&n" : "W",  
     104                 "&b" : "W",  
     105                 "*i" : "W",  
     106                 "*l" : "W",  
     107                 "*m" : "W",  
     108                 "*v" : "W",  
     109                 "*c" : "W",  
     110                 "(f" : "W",  
     111                 "*b" : "VW", 
     112                 "(s" : "W",  
     113                 ")s" : "W",  
     114                 "&p" : "X",  
     115                 "&l" : "X" }  
    96116    copies = 1 
    97117    pagecount = 0 
  • pykota/trunk/bin/pkprinters

    r1438 r1451  
    2424# 
    2525# $Log$ 
     26# Revision 1.6  2004/05/06 12:37:29  jalet 
     27# pkpgcounter : comments 
     28# pkprinters : when --add is used, existing printers are now skipped. 
     29# 
    2630# Revision 1.5  2004/04/16 16:52:09  jalet 
    2731# Better formatting 
     
    163167            for pname in names : 
    164168                printer = self.storage.getPrinter(pname) 
    165                 if not printer.Exists : 
     169                if printer.Exists : 
     170                    self.logger.log_message(_("Printer %s already exists, skipping.") % printer.Name, "warn") 
     171                else : 
    166172                    if self.isValidName(pname) : 
    167173                        printer = self.storage.addPrinter(pname) 
    168174                        if not printer.Exists : 
    169175                            raise PyKotaToolError, _("Impossible to add printer %s") % pname 
     176                        else :     
     177                            printers.append(printer) 
    170178                    else :     
    171179                        raise PyKotaToolError, _("Invalid printer name %s") % pname 
    172                 printers.append(printer) 
    173180        else :         
    174181            printers = self.storage.getMatchingPrinters(",".join(names)) 
  • pykota/trunk/NEWS

    r1450 r1451  
    2222PyKota NEWS : 
    2323 
     24    - 1.19alpha5 : 
     25     
     26        - pkprinters --add now completely skips existing printers, but 
     27          logs a warning. 
     28           
    2429    - 1.19alpha4 : 
    2530     
     
    2732          is now fixed. 
    2833           
    29         - improved PCL support in pkpgcounter.   
     34        - improved PCL support in pkpgcounter, with the use of 
     35          HP PCL/PJL Reference Set 
     36          PCL5 Printer Language Technical Quick Reference Guide 
    3037         
    3138        - pkpgcounter now uses mmap to speed things up : duration 
  • pykota/trunk/po/br/pykota.po

    r1437 r1451  
    482482msgid "in" 
    483483msgstr "em" 
     484 
     485#, python-format 
     486msgid "Printer %s already exists, skipping." 
     487msgstr "" 
     488 
  • pykota/trunk/po/en/pykota.po

    r1437 r1451  
    446446msgid "in" 
    447447msgstr "" 
     448 
     449#, python-format 
     450msgid "Printer %s already exists, skipping." 
     451msgstr "" 
     452 
  • pykota/trunk/po/es/pykota.po

    r1437 r1451  
    486486msgid "in" 
    487487msgstr "en" 
     488 
     489#, python-format 
     490msgid "Printer %s already exists, skipping." 
     491msgstr "" 
     492 
  • pykota/trunk/po/fr/pykota.po

    r1437 r1451  
    473473msgid "in" 
    474474msgstr "dans" 
     475 
     476#, python-format 
     477msgid "Printer %s already exists, skipping." 
     478msgstr "L'imprimante %s existe d�, ignor�" 
     479 
  • pykota/trunk/po/it/pykota.po

    r1413 r1451  
    479479msgid "Problem modifying LDAP entry (%s, %s)" 
    480480msgstr "Errore avvenuto durante la modifica della entry LDAP (%s, %s)" 
     481 
     482#, python-format 
     483msgid "Printer %s already exists, skipping." 
     484msgstr "" 
     485 
  • pykota/trunk/po/pt/pykota.po

    r1437 r1451  
    482482msgid "in" 
    483483msgstr "em" 
     484 
     485#, python-format 
     486msgid "Printer %s already exists, skipping." 
     487msgstr "" 
     488 
  • pykota/trunk/po/pykota.pot

    r1437 r1451  
    446446msgid "in" 
    447447msgstr "" 
     448 
     449#, python-format 
     450msgid "Printer %s already exists, skipping." 
     451msgstr "" 
     452 
  • pykota/trunk/po/se/pykota.po

    r1413 r1451  
    478478msgid "Problem modifying LDAP entry (%s, %s)" 
    479479msgstr "Problem med att modifiera LDAP post (%s, %s)" 
     480 
     481#, python-format 
     482msgid "Printer %s already exists, skipping." 
     483msgstr "" 
     484 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1393 r1451  
    2222# 
    2323# $Log$ 
     24# Revision 1.63  2004/05/06 12:37:46  jalet 
     25# pkpgcounter : comments 
     26# pkprinters : when --add is used, existing printers are now skipped. 
     27# 
    2428# Revision 1.62  2004/03/05 14:31:58  jalet 
    2529# Improvement on strange history entries 
     
    444448        """Extracts user information given its name.""" 
    445449        user = StorageUser(self, username) 
    446         result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaLimitBy", self.info["usermail"]], base=self.info["userbase"]) 
     450        result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"]], base=self.info["userbase"]) 
    447451        if result : 
    448452            fields = result[0][1] 
    449453            user.ident = result[0][0] 
     454            user.Name = fields.get("pykotaUserName", [username])[0]  
    450455            user.Email = fields.get(self.info["usermail"]) 
    451456            if user.Email is not None : 
     
    478483        """Extracts group information given its name.""" 
    479484        group = StorageGroup(self, groupname) 
    480         result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaLimitBy"], base=self.info["groupbase"]) 
     485        result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy"], base=self.info["groupbase"]) 
    481486        if result : 
    482487            fields = result[0][1] 
    483488            group.ident = result[0][0] 
     489            group.Name = fields.get("pykotaGroupName", [groupname])[0]  
    484490            group.LimitBy = fields.get("pykotaLimitBy") 
    485491            if group.LimitBy is not None : 
     
    495501        
    496502    def getPrinterFromBackend(self, printername) :         
    497         """Extracts printer information given its name.""" 
     503        """Extracts printer information given its name : returns first matching printer.""" 
    498504        printer = StoragePrinter(self, printername) 
    499         result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 
    500         if result : 
    501             fields = result[0][1] 
     505        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 
     506        if result : 
     507            fields = result[0][1]       # take only first matching printer, ignore the rest 
    502508            printer.ident = result[0][0] 
     509            printer.Name = fields.get("pykotaPrinterName", [printername])[0]  
    503510            printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0] or 0.0) 
    504511            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
  • pykota/trunk/pykota/storages/sql.py

    r1358 r1451  
    2222# 
    2323# $Log$ 
     24# Revision 1.38  2004/05/06 12:37:47  jalet 
     25# pkpgcounter : comments 
     26# pkprinters : when --add is used, existing printers are now skipped. 
     27# 
    2428# Revision 1.37  2004/02/23 22:53:21  jalet 
    2529# Don't retrieve data when it's not needed, to avoid database queries 
     
    6367            fields = result[0] 
    6468            user.ident = fields.get("id") 
     69            user.Name = fields.get("username", username) 
    6570            user.LimitBy = fields.get("limitby") 
    6671            user.AccountBalance = fields.get("balance") 
     
    7782            fields = result[0] 
    7883            group.ident = fields.get("id") 
     84            group.Name = fields.get("groupname", groupname) 
    7985            group.LimitBy = fields.get("limitby") 
    8086            result = self.doSearch("SELECT SUM(balance) AS balance, SUM(lifetimepaid) AS lifetimepaid FROM users WHERE id IN (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(group.ident)) 
     
    9399            fields = result[0] 
    94100            printer.ident = fields.get("id") 
     101            printer.Name = fields.get("printername", printername) 
    95102            printer.PricePerJob = fields.get("priceperjob") 
    96103            printer.PricePerPage = fields.get("priceperpage") 
  • pykota/trunk/pykota/version.py

    r1447 r1451  
    2222# 
    2323 
    24 __version__ = "1.19alpha4_unofficial" 
     24__version__ = "1.19alpha5_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""