Changeset 1021 for pykota/trunk/pykota
- Timestamp:
- 06/10/03 18:37:54 (21 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 1 added
- 2 removed
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/config.py
r1000 r1021 21 21 # 22 22 # $Log$ 23 # Revision 1.28 2003/06/10 16:37:54 jalet 24 # Deletion of the second user which is not needed anymore. 25 # Added a debug configuration field in /etc/pykota.conf 26 # All queries can now be sent to the logger in debug mode, this will 27 # greatly help improve performance when time for this will come. 28 # 23 29 # Revision 1.27 2003/05/27 23:00:21 jalet 24 30 # Big rewrite of external accounting methods. … … 183 189 for option in [ "storagebackend", "storageserver", \ 184 190 "storagename", "storageadmin", \ 185 "storageuser", \186 191 ] : 187 192 backendinfo[option] = self.getGlobalOption(option) 188 for option in [ "storageadminpw", "storageuserpw" ] : 189 backendinfo[option] = self.getGlobalOption(option, ignore=1) 193 backendinfo["storageadminpw"] = self.getGlobalOption("storageadminpw", ignore=1) 190 194 return backendinfo 191 195 … … 304 308 except ValueError : 305 309 raise PyKotaConfigError, _("Invalid grace delay %s") % gd 310 311 def getDebug(self) : 312 """Returns 1 if debugging is activated, else 0.""" 313 debug = self.getGlobalOption("debug", ignore=1) 314 if (debug is not None) and (debug.upper().strip() in ['Y', 'YES', '1', 'ON', 'O']) : 315 return 1 316 else : 317 return 0 -
pykota/trunk/pykota/logger.py
r952 r1021 21 21 # 22 22 # $Log$ 23 # Revision 1.7 2003/06/10 16:37:54 jalet 24 # Deletion of the second user which is not needed anymore. 25 # Added a debug configuration field in /etc/pykota.conf 26 # All queries can now be sent to the logger in debug mode, this will 27 # greatly help improve performance when time for this will come. 28 # 23 29 # Revision 1.6 2003/04/23 22:13:57 jalet 24 30 # Preliminary support for LPRng added BUT STILL UNTESTED. … … 55 61 __str__ = __repr__ 56 62 57 def openLogger( config) :63 def openLogger(pykotatool) : 58 64 """Returns the appropriate logger subsystem object.""" 59 backend = config.getLoggingBackend()65 backend = pykotatool.config.getLoggingBackend() 60 66 try : 61 67 if not backend.isalpha() : -
pykota/trunk/pykota/storage.py
r952 r1021 21 21 # 22 22 # $Log$ 23 # Revision 1.13 2003/06/10 16:37:54 jalet 24 # Deletion of the second user which is not needed anymore. 25 # Added a debug configuration field in /etc/pykota.conf 26 # All queries can now be sent to the logger in debug mode, this will 27 # greatly help improve performance when time for this will come. 28 # 23 29 # Revision 1.12 2003/04/23 22:13:57 jalet 24 30 # Preliminary support for LPRng added BUT STILL UNTESTED. … … 78 84 __str__ = __repr__ 79 85 80 def openConnection( config, asadmin=0) :86 def openConnection(pykotatool) : 81 87 """Returns a connection handle to the appropriate Quota Storage Database.""" 82 backendinfo = config.getStorageBackend()88 backendinfo = pykotatool.config.getStorageBackend() 83 89 backend = backendinfo["storagebackend"] 84 90 try : … … 86 92 # don't trust user input 87 93 raise ImportError 94 # 95 # TODO : descending compatibility 96 # 97 if backend == "postgresql" : 98 backend = "pgstorage" # TODO : delete, this is for descending compatibility only 88 99 exec "from pykota.storages import %s as storagebackend" % backend.lower() 89 100 except ImportError : … … 93 104 database = backendinfo["storagename"] 94 105 admin = backendinfo["storageadmin"] 95 user = backendinfo["storageuser"]96 106 adminpw = backendinfo["storageadminpw"] 97 userpw = backendinfo["storageuserpw"] 98 if asadmin : 99 return getattr(storagebackend, "Storage")(host, database, admin, adminpw) 100 else : 101 return getattr(storagebackend, "Storage")(host, database, user, userpw) 107 return getattr(storagebackend, "Storage")(pykotatool, host, database, admin, adminpw) 102 108 -
pykota/trunk/pykota/storages/ldapstorage.py
r1020 r1021 21 21 # 22 22 # $Log$ 23 # Revision 1.5 2003/06/10 16:37:54 jalet 24 # Deletion of the second user which is not needed anymore. 25 # Added a debug configuration field in /etc/pykota.conf 26 # All queries can now be sent to the logger in debug mode, this will 27 # greatly help improve performance when time for this will come. 28 # 23 29 # Revision 1.4 2003/06/10 10:45:32 jalet 24 30 # Not implemented methods now raise an exception when called. … … 55 61 56 62 class Storage : 57 def __init__(self, host, dbname, user, passwd) :63 def __init__(self, pykotatool, host, dbname, user, passwd) : 58 64 """Opens the LDAP connection.""" 59 65 # raise PyKotaStorageError, "Sorry, the LDAP backend for PyKota is not yet implemented !" 66 self.tool = pykotatool 67 self.debug = pykotatool.config.getDebug() 60 68 self.closed = 1 61 69 try : … … 67 75 else : 68 76 self.closed = 0 77 if self.debug : 78 self.tool.logger.log_message("Database opened (host=%s, dbname=%s, user=%s)" % (host, dbname, user), "debug") 69 79 70 80 def __del__(self) : … … 73 83 del self.database 74 84 self.closed = 1 85 if self.debug : 86 self.tool.logger.log_message("Database closed.", "debug") 75 87 76 88 def doSearch(self, key, fields, base="", scope=ldap.SCOPE_SUBTREE) : … … 78 90 try : 79 91 # prepends something more restrictive at the beginning of the base dn 92 if self.debug : 93 self.tool.logger.log_message("QUERY : BaseDN : %s, Scope : %s, Filter : %s, Attributes : %s" % ((base or self.basedn), scope, key, fields), "debug") 80 94 result = self.database.search_s(base or self.basedn, scope, key, fields) 81 95 except ldap.NO_SUCH_OBJECT : -
pykota/trunk/pykota/tool.py
r973 r1021 21 21 # 22 22 # $Log$ 23 # Revision 1.40 2003/06/10 16:37:54 jalet 24 # Deletion of the second user which is not needed anymore. 25 # Added a debug configuration field in /etc/pykota.conf 26 # All queries can now be sent to the logger in debug mode, this will 27 # greatly help improve performance when time for this will come. 28 # 23 29 # Revision 1.39 2003/04/29 18:37:54 jalet 24 30 # Pluggable accounting methods (actually doesn't support external scripts) … … 188 194 class PyKotaTool : 189 195 """Base class for all PyKota command line tools.""" 190 def __init__(self, asadmin=1,doc="PyKota %s (c) 2003 %s" % (version.__version__, version.__author__)) :196 def __init__(self, doc="PyKota %s (c) 2003 %s" % (version.__version__, version.__author__)) : 191 197 """Initializes the command line tool.""" 192 198 # locale stuff … … 200 206 self.documentation = doc 201 207 self.config = config.PyKotaConfig("/etc") 202 self.logger = logger.openLogger(self .config)203 self.storage = storage.openConnection(self .config, asadmin=asadmin)208 self.logger = logger.openLogger(self) 209 self.storage = storage.openConnection(self) 204 210 self.smtpserver = self.config.getSMTPServer() 205 211 -
pykota/trunk/pykota/version.py
r1018 r1021 21 21 # 22 22 23 __version__ = "1.08alpha 7_unofficial"23 __version__ = "1.08alpha8_unofficial" 24 24 25 25 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""