- Timestamp:
- 10/04/08 10:33:28 (16 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r3413 r3419 76 76 for tryit in range(3) : 77 77 try : 78 self.tool.logdebug("Trying to open database (host=%s, dbname=%s, user=%s)..." % (self.savedhost, self.saveddbname, self.saveduser)) 78 self.tool.logdebug("Trying to open database (host=%s, dbname=%s, user=%s)..." \ 79 % (repr(self.savedhost), 80 repr(self.saveddbname), 81 repr(self.saveduser))) 79 82 self.database = ldap.initialize(self.savedhost) 80 83 if self.info["ldaptls"] : … … 91 94 time.sleep(2) 92 95 except ldap.LDAPError : 93 message = "Unable to connect to LDAP server %s as %s." % (self.savedhost, self.saveduser) 96 message = "Unable to connect to LDAP server %s as %s." \ 97 % (repr(self.savedhost), repr(self.saveduser)) 94 98 self.tool.printInfo("%s" % message, "error") 95 99 self.tool.printInfo("Trying again in 2 seconds...", "warn") … … 100 104 self.tool.logdebug("Low-Level LDAP Caching enabled.") 101 105 self.ldapcache = {} # low-level cache specific to LDAP backend 102 self.closed = 0 103 self.tool.logdebug("Database opened (host=%s, dbname=%s, user=%s)" % (self.savedhost, self.saveddbname, self.saveduser)) 106 self.closed = False 107 self.tool.logdebug("Database opened (host=%s, dbname=%s, user=%s)" \ 108 % (repr(self.savedhost), 109 repr(self.saveddbname), 110 repr(self.saveduser))) 104 111 return # All is fine here. 105 112 raise PyKotaStorageError, message … … 109 116 if not self.closed : 110 117 self.database.unbind_s() 111 self.closed = 1118 self.closed = True 112 119 self.tool.logdebug("Database closed.") 113 120 -
pykota/trunk/pykota/storages/mysqlstorage.py
r3413 r3419 44 44 port = 3306 # Use the default MySQL port 45 45 46 self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." % (host, port, dbname, user)) 46 self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." \ 47 % (repr(host), 48 repr(port), 49 repr(dbname), 50 repr(user))) 47 51 try : 48 self.database = MySQLdb.connect(host=host, port=port, db=dbname, user=user, passwd=passwd, charset="utf8") 52 self.database = MySQLdb.connect(host=host, 53 port=port, 54 db=dbname, 55 user=user, 56 passwd=passwd, 57 charset="utf8") 49 58 except TypeError : 50 59 self.tool.logdebug("'charset' argument not allowed with this version of python-mysqldb, retrying without...") 51 self.database = MySQLdb.connect(host=host, port=port, db=dbname, user=user, passwd=passwd) 60 self.database = MySQLdb.connect(host=host, 61 port=port, 62 db=dbname, 63 user=user, 64 passwd=passwd) 52 65 53 66 try : … … 59 72 self.cursor.execute("SET TRANSACTION ISOLATION LEVEL READ COMMITTED;") # Same as PostgreSQL and Oracle's default 60 73 self.closed = False 61 self.tool.logdebug("Database opened (host=%s, port=%s, dbname=%s, user=%s)" % (host, port, dbname, user)) 74 self.tool.logdebug("Database opened (host=%s, port=%s, dbname=%s, user=%s)" \ 75 % (repr(host), 76 repr(port), 77 repr(dbname), 78 repr(user))) 62 79 try : 63 80 # Here we try to select a string (an é) which is -
pykota/trunk/pykota/storages/pgstorage.py
r3413 r3419 53 53 port = 5432 # Use PostgreSQL's default tcp/ip port (5432). 54 54 55 self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." % (host, port, dbname, user)) 55 self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." % (repr(host), 56 repr(port), 57 repr(dbname), 58 repr(user))) 56 59 try : 57 self.database = pg.connect(host=host, port=port, dbname=dbname, user=user, passwd=passwd) 60 self.database = pg.connect(host=host, 61 port=port, 62 dbname=dbname, 63 user=user, 64 passwd=passwd) 58 65 except PGError, msg : 59 66 msg = "%(msg)s --- the most probable cause of your problem is that PostgreSQL is down, or doesn't accept incoming connections because you didn't configure it as explained in PyKota's documentation." % locals() 60 67 raise PGError, msg 61 self.closed = 068 self.closed = False 62 69 try : 63 70 self.database.query("SET CLIENT_ENCODING TO 'UTF-8';") 64 71 except PGError, msg : 65 72 self.tool.logdebug("Impossible to set database client encoding to UTF-8 : %s" % msg) 66 self.tool.logdebug("Database opened (host=%s, port=%s, dbname=%s, user=%s)" % (host, port, dbname, user)) 73 self.tool.logdebug("Database opened (host=%s, port=%s, dbname=%s, user=%s)" % (repr(host), 74 repr(port), 75 repr(dbname), 76 repr(user))) 67 77 68 78 def close(self) : … … 70 80 if not self.closed : 71 81 self.database.close() 72 self.closed = 182 self.closed = True 73 83 self.tool.logdebug("Database closed.") 74 84 -
pykota/trunk/pykota/storages/sqlitestorage.py
r3413 r3419 39 39 BaseStorage.__init__(self, pykotatool) 40 40 41 self.tool.logdebug("Trying to open database (dbname=%s)..." % dbname)41 self.tool.logdebug("Trying to open database (dbname=%s)..." % repr(dbname)) 42 42 self.database = sqlite.connect(dbname, isolation_level=None) 43 43 self.cursor = self.database.cursor() 44 self.closed = 045 self.tool.logdebug("Database opened (dbname=%s)" % dbname)44 self.closed = False 45 self.tool.logdebug("Database opened (dbname=%s)" % repr(dbname)) 46 46 47 47 def close(self) : … … 50 50 self.cursor.close() 51 51 self.database.close() 52 self.closed = 152 self.closed = True 53 53 self.tool.logdebug("Database closed.") 54 54