From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EA31F1381F3 for ; Wed, 19 Dec 2012 02:17:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7D33221C011; Wed, 19 Dec 2012 02:17:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EE88D21C011 for ; Wed, 19 Dec 2012 02:17:03 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B666433DB53 for ; Wed, 19 Dec 2012 02:17:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 4C784E543C for ; Wed, 19 Dec 2012 02:17:01 +0000 (UTC) From: "Magnus Granberg" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Magnus Granberg" Message-ID: <1355883407.87dcaa229a66fa9253083c5f1418efd858a5d069.zorry@gentoo> Subject: [gentoo-commits] dev/zorry:master commit in: gobs/pym/ X-VCS-Repository: dev/zorry X-VCS-Files: gobs/pym/ConnectionManager.py X-VCS-Directories: gobs/pym/ X-VCS-Committer: zorry X-VCS-Committer-Name: Magnus Granberg X-VCS-Revision: 87dcaa229a66fa9253083c5f1418efd858a5d069 X-VCS-Branch: master Date: Wed, 19 Dec 2012 02:17:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0a58e13f-7250-4e12-89be-035f69a42e44 X-Archives-Hash: 33238ea1cea78a964922325384ef1186 commit: 87dcaa229a66fa9253083c5f1418efd858a5d069 Author: Magnus Granberg gentoo org> AuthorDate: Wed Dec 19 02:16:47 2012 +0000 Commit: Magnus Granberg gentoo org> CommitDate: Wed Dec 19 02:16:47 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=87dcaa22 fix invalid syntax --- gobs/pym/ConnectionManager.py | 22 ++++++++++------------ 1 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gobs/pym/ConnectionManager.py b/gobs/pym/ConnectionManager.py index a06e2cd..9d345c1 100644 --- a/gobs/pym/ConnectionManager.py +++ b/gobs/pym/ConnectionManager.py @@ -6,9 +6,9 @@ from gobs.readconf import get_conf_settings reader = get_conf_settings() gobs_settings_dict=reader.read_gobs_settings_all() -if settings_dict['sql_backend']=='pgsql': +if settings_dict['sql_backend'] == 'pgsql': from gobs.pgsql_querys import * -if settings_dict['sql_backend']=='mysql': +if settings_dict['sql_backend'] == 'mysql': from gobs.mysql_querys import * class connectionManager(object): @@ -25,7 +25,7 @@ class connectionManager(object): cls._password=settings_dict['sql_passwd'] cls._database=settings_dict['sql_db'] #shouldnt we include port also? - if cls._backend == 'pgsql' + if cls._backend == 'pgsql': try: from psycopg2 import pool, extensions except ImportError: @@ -35,8 +35,7 @@ class connectionManager(object): cls._connectionNumber=numberOfconnections #always create 1 connection cls._pool=pool.ThreadedConnectionPool(1,cls._connectionNumber,host=cls._host,database=cls._database,user=cls._user,password=cls._password) - cls._name=cls._backend - if cls._backend == 'mysql' + if cls._backend == 'mysql': try: import mysql.connector from mysql.connector import errorcode @@ -58,24 +57,23 @@ class connectionManager(object): print("Database does not exists") else: print(err) - cls._name=cls._backend return cls._instance ## returns the name of the database pgsql/mysql etc def getName(self): - return self._name + return self._backend def getConnection(self): - if self._name == 'pgsql' + if self._backend == 'pgsql': return self._pool.getconn() - if self._name == 'mysql' + if self._backend == 'mysql': return self._cnx def putConnection(self, connection): - if self._name == 'pgsql' + if self._backend == 'pgsql': self._pool.putconn(connection , key=None, close=True) - if self._name == 'mysql' - return self._cnx.close() + if self._backend == 'mysql': + self._cnx.close() def closeAllConnections(self): self._pool.closeall()