Changeset 1018
- Timestamp:
- 06/06/03 22:49:15 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/CREDITS
r1017 r1018 40 40 The following people contributed code or ideas to PyKota : 41 41 42 - Jo�Collet : made the PyKotalogo42 - Jo�Collet : PyKota's logo 43 43 - Stefan Wold - Stockholm University : code 44 44 - John Flynn - University of Belize : LDAP support 45 45 - Wayne Godoy - University of Belize : LDAP support 46 - Leif Johansson - LDAP support46 - Leif Johansson - Stockholm University : LDAP support 47 47 48 48 ============================================================ -
pykota/trunk/initscripts/ldap/pykota-sample.ldif
r1017 r1018 72 72 73 73 dn: cn=apple,ou=Printers,ou=PyKota,dc=librelogiciel,dc=com 74 objectClass: pykota Named74 objectClass: pykotaObject 75 75 objectClass: pykotaPrinter 76 76 cn: apple … … 80 80 81 81 dn: cn=uniqueidentifier01,ou=UQuotas,ou=PyKota,dc=librelogiciel,dc=com 82 objectClass: pykota Named82 objectClass: pykotaObject 83 83 objectClass: pykotaUserPQuota 84 84 cn: uniqueidentifier01 … … 92 92 93 93 dn: cn=uniqueidentifier02,ou=GQuotas,ou=PyKota,dc=librelogiciel,dc=com 94 objectClass: pykota Named94 objectClass: pykotaObject 95 95 objectClass: pykotaGroupPQuota 96 96 cn: uniqueidentifier02 … … 102 102 103 103 dn: cn=uniqueidentifier03,ou=Jobs,ou=PyKota,dc=librelogiciel,dc=com 104 objectClass: pykota Named104 objectClass: pykotaObject 105 105 objectClass: pykotaJob 106 106 cn: uniqueidentifier03 … … 113 113 114 114 dn: cn=uniqueidentifier04,ou=LastJobs,ou=PyKota,dc=librelogiciel,dc=com 115 objectClass: pykota Named115 objectClass: pykotaObject 116 116 objectClass: pykotaLastJob 117 117 cn: uniqueidentifier04 118 118 pykotaPrinterName: apple 119 pykotaLastJob UUID: uniqueidentifier03119 pykotaLastJobIdent: uniqueidentifier03 -
pykota/trunk/initscripts/ldap/pykota.schema
r1017 r1018 110 110 # pykotaAction 111 111 attributetype ( 1.3.6.1.4.1.16868.1.1.14 NAME 'pykotaAction' 112 DESC 'Was the job allowed, or denied '113 EQUALITY case IgnoreIA5Match112 DESC 'Was the job allowed, or denied : ( "ALLOW" | "DENY" )' 113 EQUALITY caseExactIA5Match 114 114 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 115 115 … … 132 132 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 133 133 134 # pykotaLastJob UUID135 attributetype ( 1.3.6.1.4.1.16868.1.1.18 NAME 'pykotaLastJob UUID'136 DESC ' Last job uuidin the history'134 # pykotaLastJobIdent 135 attributetype ( 1.3.6.1.4.1.16868.1.1.18 NAME 'pykotaLastJobIdent' 136 DESC 'Identifies the last job in the history' 137 137 EQUALITY caseExactIA5Match 138 138 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) … … 145 145 objectclass ( 1.3.6.1.4.1.16868.1.2.1 NAME 'pykotaAccount' SUP top AUXILIARY 146 146 DESC 'PyKota Auxiliary User Account' 147 MUST ( uid $ pykotaUserName)148 MAY ( pykota LimitBy ) )147 MUST ( uid ) 148 MAY ( pykotaUserName $ pykotaLimitBy ) ) 149 149 150 150 # pykotaGroup 151 151 objectclass ( 1.3.6.1.4.1.16868.1.2.2 NAME 'pykotaGroup' SUP top AUXILIARY 152 152 DESC 'PyKota Auxiliary Group' 153 MUST ( cn $ pykotaGroupName)154 MAY ( pykota LimitBy $ memberUid) )153 MUST ( cn ) 154 MAY ( pykotaGroupName $ pykotaLimitBy $ memberUid $ uniqueMember $ member ) ) 155 155 156 156 # pykotaPrinter 157 157 objectclass ( 1.3.6.1.4.1.16868.1.2.3 NAME 'pykotaPrinter' SUP top AUXILIARY 158 158 DESC 'PyKota Printer' 159 MUST ( cn $ pykotaPrinterName)160 MAY ( pykotaPri cePerPage $ pykotaPricePerJob ) )159 MUST ( cn ) 160 MAY ( pykotaPrinterName $ pykotaPricePerPage $ pykotaPricePerJob ) ) 161 161 162 162 # pykotaUserPQuota … … 181 181 objectclass ( 1.3.6.1.4.1.16868.1.2.7 NAME 'pykotaAccountBalance' SUP top AUXILIARY 182 182 DESC 'PyKota User account balance' 183 MUST ( pykotaUserName ) 184 MAY ( pykotaBalance $ pykotaLifeTimePaid ) ) 183 MAY ( pykotaUserName $ pykotaBalance $ pykotaLifeTimePaid ) ) 185 184 186 185 # pykotaLastJob 187 186 objectclass ( 1.3.6.1.4.1.16868.1.2.8 NAME 'pykotaLastJob' SUP top AUXILIARY 188 187 DESC 'Last job information for a printer' 189 MUST ( pykotaPrinterName $ pykotaLastJobUUID ) ) 188 MUST ( pykotaLastJobIdent ) 189 MAY ( pykotaPrinterName ) ) 190 190 191 # pykota Named- Use it if you have to192 objectclass ( 1.3.6.1.4.1.16868.1.2.9 NAME 'pykota Named' SUP top STRUCTURAL193 DESC 'PyKota NamedObject'191 # pykotaObject - Use it if you have to 192 objectclass ( 1.3.6.1.4.1.16868.1.2.9 NAME 'pykotaObject' SUP top STRUCTURAL 193 DESC 'PyKota Object' 194 194 MUST ( cn ) ) 195 195 -
pykota/trunk/pykota/storages/ldapstorage.py
r1017 r1018 21 21 # 22 22 # $Log$ 23 # Revision 1.3 2003/06/06 20:49:15 jalet 24 # Very latest schema. UNTESTED. 25 # 23 26 # Revision 1.2 2003/06/06 14:21:08 jalet 24 27 # New LDAP schema. … … 86 89 def getPrinterId(self, printername) : 87 90 """Returns a printerid given a printername.""" 88 result = self.doSearch("(&(objectClass=pykotaPrinter)( pykotaPrinterName=%s))" % printername, ["pykotaPrinterName"])91 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(cn=%s)))" % (printername, printername), ["pykotaPrinterName"]) 89 92 if result : 90 93 return result[0][0] … … 92 95 def getPrinterPrices(self, printerid) : 93 96 """Returns a printer prices per page and per job given a printerid.""" 94 result = self.doSearch(" pykotaPrinterName=*", ["pykotaPricePerPage", "pykotaPricePerJob"], base=printerid)97 result = self.doSearch("(|(pykotaPrinterName=*)(cn=*))", ["pykotaPricePerPage", "pykotaPricePerJob"], base=printerid, scope=ldap.SCOPE_BASE) 95 98 if result : 96 99 return (float(result[0][1]["pykotaPricePerPage"][0]), float(result[0][1]["pykotaPricePerJob"][0])) … … 102 105 def getUserId(self, username) : 103 106 """Returns a userid given a username.""" 104 result = self.doSearch("(&(objectClass=pykotaAccount)( pykotaUserName=%s))" % username, ["uid"])107 result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(uid=%s)))" % (username, username), ["uid"]) 105 108 if result : 106 109 return result[0][0] … … 108 111 def getGroupId(self, groupname) : 109 112 """Returns a groupid given a grupname.""" 110 result = self.doSearch("(&(objectClass=pykotaGroup)( pykotaGroupName=%s))" % groupname, ["cn"])113 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(cn=%s)))" % (groupname, groupname), ["cn"]) 111 114 if result is not None : 112 115 (groupid, dummy) = result[0] … … 120 123 """Returns the list of userids and usernames which uses a given printer.""" 121 124 # first get the printer's name from the id 122 result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName"], base=printerid, scope=ldap.SCOPE_BASE) 123 if result : 124 printername = result[0][1]["pykotaPrinterName"][0] 125 result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName", "cn"], base=printerid, scope=ldap.SCOPE_BASE) 126 if result : 127 fields = result[0][1] 128 printername = (fields.get("pykotaPrinterName") or fields.get("cn"))[0] 125 129 result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaPrinterName=%s))" % printername, ["pykotaUserName"]) 126 130 if result : … … 130 134 """Returns the list of groups which uses a given printer.""" 131 135 # first get the printer's name from the id 132 result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName"], base=printerid, scope=ldap.SCOPE_BASE) 133 if result : 134 printername = result[0][1]["pykotaPrinterName"][0] 136 result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName", "cn"], base=printerid, scope=ldap.SCOPE_BASE) 137 if result : 138 fields = result[0][1] 139 printername = (fields.get("pykotaPrinterName") or fields.get("cn"))[0] 135 140 result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaPrinterName=%s))" % printername, ["pykotaGroupName"]) 136 141 if result : … … 139 144 def getGroupMembersNames(self, groupname) : 140 145 """Returns the list of user's names which are member of this group.""" 141 result = self.doSearch("(&(objectClass=pykotaGroup)(pykotaGroupName=%s))" % groupname, ["memberUid"]) 142 if result : 143 return result[0][1]["memberUid"] 146 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(cn=%s)))" % (groupname, groupname), ["memberUid", "uniqueMember", "member"]) 147 if result : 148 fields = result[0][1] 149 return fields.get("memberUid") or fields.get("uniqueMember") or fields.get("member") 144 150 145 151 def getUserGroupsNames(self, userid) : … … 177 183 if result : 178 184 username = result[0][1]["pykotaUserName"][0] 179 result = self.doSearch("(&(objectClass=pykotaAccountBalance)( pykotaUserName=%s))" % username, ["pykotaBalance", "pykotaLifeTimePaid"])185 result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(uid=%s)))" % (username, username), ["pykotaBalance", "pykotaLifeTimePaid"]) 180 186 if result : 181 187 fields = result[0][1] … … 185 191 """Returns the current account balance for a given user id.""" 186 192 # first get the user's name from the user id 187 result = self.doSearch("objectClass=pykotaAccount", ["pykotaUserName"], base=userid, scope=ldap.SCOPE_BASE) 188 if result : 189 username = result[0][1]["pykotaUserName"][0] 190 result = self.doSearch("(&(objectClass=pykotaAccountBalance)(pykotaUserName=%s))" % username, ["pykotaBalance", "pykotaLifeTimePaid"]) 193 result = self.doSearch("objectClass=pykotaAccount", ["pykotaUserName", "uid"], base=userid, scope=ldap.SCOPE_BASE) 194 if result : 195 fields = result[0][1] 196 username = (fields.get("pykotaUserName") or fields.get("uid"))[0] 197 result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(uid=%s)))" % (username, username), ["pykotaBalance", "pykotaLifeTimePaid"]) 191 198 if result : 192 199 fields = result[0][1] -
pykota/trunk/pykota/version.py
r1017 r1018 21 21 # 22 22 23 __version__ = "1.08alpha 6_unofficial"23 __version__ = "1.08alpha7_unofficial" 24 24 25 25 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" -
pykota/trunk/setup.py
r997 r1018 23 23 # 24 24 # $Log$ 25 # Revision 1.16 2003/06/06 20:49:15 jalet 26 # Very latest schema. UNTESTED. 27 # 25 28 # Revision 1.15 2003/05/17 16:32:30 jalet 26 29 # Also outputs the original import error message. … … 111 114 return result 112 115 113 def checkWithPrompt(prompt, module=None, command=None, help =None) :116 def checkWithPrompt(prompt, module=None, command=None, helper=None) : 114 117 """Tells the user what will be checked, and asks him what to do if something is absent.""" 115 118 sys.stdout.write("Checking for %s availability : " % prompt) … … 125 128 sys.stdout.write("NO.\n") 126 129 sys.stderr.write("ERROR : %s not available !\n" % prompt) 127 if help is not None :128 sys.stdout.write("%s\n" % help )130 if helper is not None : 131 sys.stdout.write("%s\n" % helper) 129 132 sys.stdout.write("You may continue safely if you don't need this functionnality.\n") 130 133 answer = raw_input("%s is missing. Do you want to continue anyway (y/N) ? " % prompt) … … 190 193 191 194 # checks if some needed Python modules are there or not. 192 modulestocheck = [("PygreSQL", "pg"), ("mxDateTime", "mx.DateTime")] 195 modulestocheck = [ ("PygreSQL", "pg", "PygreSQL is mandatory if you want to use PostgreSQL as the quota storage backend."), 196 ("mxDateTime", "mx.DateTime", "eGenix' mxDateTime is mandatory for PyKota to work."), 197 ("Python-LDAP", "ldap", "Python-LDAP is mandatory if you plan to use an LDAP\ndirectory as the quota storage backend.") 198 ] 193 199 commandstocheck = [("SNMP Tools", "snmpget", "SNMP Tools are needed if you want to use SNMP enabled printers."), ("Netatalk", "pap", "Netatalk is needed if you want to use AppleTalk enabled printers.")] 194 for (name, module ) in modulestocheck :195 action = checkWithPrompt(name, module=module )200 for (name, module, helper) in modulestocheck : 201 action = checkWithPrompt(name, module=module, helper=helper) 196 202 if action == ACTION_ABORT : 197 203 sys.stderr.write("Aborted !\n") … … 199 205 200 206 # checks if some software are there or not. 201 for (name, command, help ) in commandstocheck :202 action = checkWithPrompt(name, command=command, help =help)207 for (name, command, helper) in commandstocheck : 208 action = checkWithPrompt(name, command=command, helper=helper) 203 209 if action == ACTION_ABORT : 204 210 sys.stderr.write("Aborted !\n")