Changeset 1993 for pykota/trunk
- Timestamp:
- 12/21/04 17:46:25 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1991 r1993 22 22 PyKota NEWS : 23 23 24 - 1.21alpha15 : 25 26 - dumpykota filtering capabilities are now supported within 27 the LDAP backend too. 28 24 29 - 1.21alpha14 : 25 30 -
pykota/trunk/pykota/storages/ldapstorage.py
r1990 r1993 22 22 # 23 23 # $Log$ 24 # Revision 1.91 2004/12/21 16:46:25 jalet 25 # dumpykota's filtering capabilities are now supported within the LDAP 26 # backend as well as within the PostgreSQL backend. Untested though since 27 # my only PyKota+LDAP setup is on my laptop at work :-) 28 # 24 29 # Revision 1.90 2004/12/21 14:45:31 jalet 25 30 # Prepared dumpykota to accept the new --filter command line option. Some … … 574 579 raise PyKotaStorageError, message 575 580 576 def getAllPrintersNames(self ) :577 """Extracts all printer names ."""581 def getAllPrintersNames(self, printername=None) : 582 """Extracts all printer names or only the printers' names matching the optional parameter.""" 578 583 printernames = [] 579 result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName"], base=self.info["printerbase"]) 584 ldapfilter = "objectClass=pykotaPrinter" 585 if printername : 586 ldapfilter = "&(%s)(pykotaPrinterName=%s)" % (ldapfilter, printername) 587 result = self.doSearch(ldapfilter, ["pykotaPrinterName"], base=self.info["printerbase"]) 580 588 if result : 581 589 printernames = [record[1]["pykotaPrinterName"][0] for record in result] 582 590 return printernames 583 591 584 def getAllUsersNames(self ) :585 """Extracts all user names ."""592 def getAllUsersNames(self, username=None) : 593 """Extracts all user names or only the users' names matching the optional parameter.""" 586 594 usernames = [] 587 result = self.doSearch("objectClass=pykotaAccount", ["pykotaUserName"], base=self.info["userbase"]) 595 ldapfilter = "objectClass=pykotaAccount" 596 if username : 597 ldapfilter = "&(%s)(pykotaUserName=%s)" % (ldapfilter, username) 598 result = self.doSearch(ldapfilter, ["pykotaUserName"], base=self.info["userbase"]) 588 599 if result : 589 600 usernames = [record[1]["pykotaUserName"][0] for record in result] 590 601 return usernames 591 602 592 def getAllGroupsNames(self ) :593 """Extracts all group names ."""603 def getAllGroupsNames(self, groupname=None) : 604 """Extracts all group names or only the groups' names matching the optional parameter.""" 594 605 groupnames = [] 595 result = self.doSearch("objectClass=pykotaGroup", ["pykotaGroupName"], base=self.info["groupbase"]) 606 ldapfilter = "objectClass=pykotaGroup" 607 if groupname : 608 ldapfilter = "&(%s)(pykotaGroupName=%s)" % (ldapfilter, groupname) 609 result = self.doSearch(ldapfilter, ["pykotaGroupName"], base=self.info["groupbase"]) 596 610 if result : 597 611 groupnames = [record[1]["pykotaGroupName"][0] for record in result] … … 1402 1416 def extractPrinters(self, extractonly={}) : 1403 1417 """Extracts all printer records.""" 1404 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames()] if p.Exists] 1418 pname = extractonly.get("printername") 1419 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 1405 1420 if entries : 1406 1421 result = [ ("dn", "pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerPage", "description") ] … … 1411 1426 def extractUsers(self, extractonly={}) : 1412 1427 """Extracts all user records.""" 1413 entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames()] if u.Exists] 1428 uname = extractonly.get("username") 1429 entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames(uname)] if u.Exists] 1414 1430 if entries : 1415 1431 result = [ ("dn", "pykotaUserName", self.info["usermail"], "pykotaBalance", "pykotaLifeTimePaid", "pykotaLimitBy") ] … … 1420 1436 def extractGroups(self, extractonly={}) : 1421 1437 """Extracts all group records.""" 1422 entries = [g for g in [self.getGroup(name) for name in self.getAllGroupsNames()] if g.Exists] 1438 gname = extractonly.get("groupname") 1439 entries = [g for g in [self.getGroup(name) for name in self.getAllGroupsNames(gname)] if g.Exists] 1423 1440 if entries : 1424 1441 result = [ ("dn", "pykotaGroupName", "pykotaBalance", "pykotaLifeTimePaid", "pykotaLimitBy") ] … … 1429 1446 def extractPayments(self, extractonly={}) : 1430 1447 """Extracts all payment records.""" 1431 entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames()] if u.Exists] 1448 uname = extractonly.get("username") 1449 entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames(uname)] if u.Exists] 1432 1450 if entries : 1433 1451 result = [ ("pykotaUserName", "date", "amount") ] … … 1439 1457 def extractUpquotas(self, extractonly={}) : 1440 1458 """Extracts all userpquota records.""" 1441 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames()] if p.Exists] 1459 pname = extractonly.get("printername") 1460 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 1442 1461 if entries : 1443 1462 result = [ ("pykotaUserName", "pykotaPrinterName", "dn", "userdn", "printerdn", "pykotaLifePageCounter", "pykotaPageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit") ] 1463 uname = extraconly.get("username") 1444 1464 for entry in entries : 1445 1465 for (user, userpquota) in self.getPrinterUsersAndQuotas(entry) : 1446 result.append((user.Name, entry.Name, userpquota.ident, user.ident, entry.ident, userpquota.LifePageCounter, userpquota.PageCounter, userpquota.SoftLimit, userpquota.HardLimit, userpquota.DateLimit)) 1466 if (uname is None) or (user.Name == uname) : 1467 result.append((user.Name, entry.Name, userpquota.ident, user.ident, entry.ident, userpquota.LifePageCounter, userpquota.PageCounter, userpquota.SoftLimit, userpquota.HardLimit, userpquota.DateLimit)) 1447 1468 return result 1448 1469 1449 1470 def extractGpquotas(self, extractonly={}) : 1450 1471 """Extracts all grouppquota records.""" 1451 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames()] if p.Exists] 1472 pname = extractonly.get("printername") 1473 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 1452 1474 if entries : 1453 1475 result = [ ("pykotaGroupName", "pykotaPrinterName", "dn", "groupdn", "printerdn", "pykotaLifePageCounter", "pykotaPageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit") ] 1476 gname = extractonly.get("groupname") 1454 1477 for entry in entries : 1455 1478 for (group, grouppquota) in self.getPrinterGroupsAndQuotas(entry) : 1456 result.append((group.Name, entry.Name, grouppquota.ident, group.ident, entry.ident, grouppquota.LifePageCounter, grouppquota.PageCounter, grouppquota.SoftLimit, grouppquota.HardLimit, grouppquota.DateLimit)) 1479 if (gname is None) or (group.Name == gname) : 1480 result.append((group.Name, entry.Name, grouppquota.ident, group.ident, entry.ident, grouppquota.LifePageCounter, grouppquota.PageCounter, grouppquota.SoftLimit, grouppquota.HardLimit, grouppquota.DateLimit)) 1457 1481 return result 1458 1482 1459 1483 def extractUmembers(self, extractonly={}) : 1460 1484 """Extracts all user groups members.""" 1461 entries = [g for g in [self.getGroup(name) for name in self.getAllGroupsNames()] if g.Exists] 1485 gname = extractonly.get("groupname") 1486 entries = [g for g in [self.getGroup(name) for name in self.getAllGroupsNames(gname)] if g.Exists] 1462 1487 if entries : 1463 1488 result = [ ("pykotaGroupName", "pykotaUserName", "groupdn", "userdn") ] 1489 uname = extractonly.get("username") 1464 1490 for entry in entries : 1465 1491 for member in entry.Members : 1466 result.append((entry.Name, member.Name, entry.ident, member.ident)) 1492 if (uname is None) or (member.Name == uname) : 1493 result.append((entry.Name, member.Name, entry.ident, member.ident)) 1467 1494 return result 1468 1495 1469 1496 def extractPmembers(self, extractonly={}) : 1470 1497 """Extracts all printer groups members.""" 1471 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames()] if p.Exists] 1498 pname = extractonly.get("printername") 1499 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 1472 1500 if entries : 1473 1501 result = [ ("pykotaPGroupName", "pykotaPrinterName", "pgroupdn", "printerdn") ] 1502 pgname = extractonly.get("pgroupname") 1474 1503 for entry in entries : 1475 1504 for parent in self.getParentPrinters(entry) : 1476 result.append((parent.Name, entry.Name, parent.ident, entry.ident)) 1505 if (pgname is None) or (parent.Name == pgname) : 1506 result.append((parent.Name, entry.Name, parent.ident, entry.ident)) 1477 1507 return result 1478 1508 1479 1509 def extractHistory(self, extractonly={}) : 1480 1510 """Extracts all jobhistory records.""" 1481 entries = self.retrieveHistory(limit=None) 1511 uname = extractonly.get("username") 1512 if uname : 1513 user = self.getUser(uname) 1514 else : 1515 user = None 1516 pname = extractonly.get("printername") 1517 if pname : 1518 printer = self.getPrinter(pname) 1519 else : 1520 printer = None 1521 entries = self.retrieveHistory(user, printer, limit=None) 1482 1522 if entries : 1483 1523 result = [ ("pykotaUserName", "pykotaPrinterName", "dn", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "createTimeStamp", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "pykotaJobPrice", "pykotaHostName", "pykotaJobSizeBytes") ] -
pykota/trunk/pykota/version.py
r1991 r1993 22 22 # 23 23 24 __version__ = "1.21alpha1 4_unofficial"24 __version__ = "1.21alpha15_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""