示例#1
0
 def _get_store_internal(self, dbname):
     from stoqlib.database.runtime import StoqlibStore
     uri = self._create_uri(dbname)
     try:
         self._log_connect(uri)
         store = StoqlibStore(create_database(uri))
     except OperationalError as e:
         log.info('OperationalError: %s' % e)
         raise DatabaseError(e.args[0])
     except Exception as e:
         value = sys.exc_info()[1]
         raise DatabaseError(
             _("Could not connect to %s database. The error message is "
               "'%s'. Please fix the connection settings you have set "
               "and try again.") % (DEFAULT_RDBMS, value))
     return store
示例#2
0
 def _get_store_internal(self, dbname):
     from stoqlib.database.runtime import StoqlibStore
     uri = self._create_uri(dbname)
     try:
         if uri.host == "":
             pair = test_local_database()
             if pair is None:
                 raise DatabaseError(
                     _("Could not find a database server on this computer"))
             uri.host = pair[0]
             uri.port = int(pair[1])
         self._log_connect(uri)
         store = StoqlibStore(create_database(uri))
     except OperationalError as e:
         log.info('OperationalError: %s' % e)
         raise DatabaseError(e.args[0])
     except Exception as e:
         value = sys.exc_info()[1]
         raise DatabaseError(
             _("Could not connect to %s database. The error message is "
               "'%s'. Please fix the connection settings you have set "
               "and try again.") % (DEFAULT_RDBMS, value))
     return store