View | Details | Raw Unified | Return to bug 35700
Collapse All | Expand All

(-)umc/python/pkgdb/__init__.py (-6 / +10 lines)
 Lines 201-207    Link Here 
201
201
202
PAGES = ('systems', 'packages')
202
PAGES = ('systems', 'packages')
203
203
204
SERVER_NOT_RUNNING_MSG = _('Maybe the PostgreSQL server is not running.\nIt can be started in the UMC module "System services".')
204
def _server_not_running_msg():
205
	return _('Maybe the PostgreSQL server is not running.\nIt can be started in the UMC module "System services".')
205
206
206
class Instance(Base):
207
class Instance(Base):
207
	def init(self):
208
	def init(self):
 Lines 218-224    Link Here 
218
				self.connect()
219
				self.connect()
219
			else:
220
			else:
220
				self.test_connection()
221
				self.test_connection()
221
			func(self, *args, **kwargs)
222
			return func(self, *args, **kwargs)
222
223
223
		return _connect
224
		return _connect
224
225
 Lines 227-234    Link Here 
227
		try:
228
		try:
228
			self.dbConnection = updb.open_database_connection(self.ucr, pkgdbu=True)
229
			self.dbConnection = updb.open_database_connection(self.ucr, pkgdbu=True)
229
		except pgdb.InternalError as ex:
230
		except pgdb.InternalError as ex:
230
			MODULE.error('Could not establish connection to the PostgreSQL server: %s' % ex)
231
			MODULE.error('Could not establish connection to the PostgreSQL server: %s' % (ex,))
231
			raise UMC_CommandError(_('Could not establish connection to the database.\n\n%s') % SERVER_NOT_RUNNING_MSG)
232
			raise UMC_CommandError(_('Could not establish connection to the database.\n\n%s') % (_server_not_running_msg(),))
232
		else:
233
		else:
233
			self.cursor = self.dbConnection.cursor()
234
			self.cursor = self.dbConnection.cursor()
234
235
 Lines 237-245    Link Here 
237
		try:
238
		try:
238
			self.cursor.execute('SELECT TRUE')
239
			self.cursor.execute('SELECT TRUE')
239
		except pgdb.OperationalError as ex:
240
		except pgdb.OperationalError as ex:
240
			MODULE.error('Connection to the PostgreSQL server lost: %s' % ex)
241
			MODULE.error('Connection to the PostgreSQL server lost: %s' % (ex,))
241
			self.dbConnection = None
242
			self.dbConnection = None
242
			raise UMC_CommandError(_('Connection to the dabase lost.\n\n%s') % SERVER_NOT_RUNNING_MSG)
243
			try:
244
				self.connect()
245
			except UMC_CommandError:
246
				raise UMC_CommandError(_('Connection to the dabase lost.\n\n%s') % (_server_not_running_msg(),))
243
247
244
	@simple_response
248
	@simple_response
245
	def reinit(self):
249
	def reinit(self):

Return to bug 35700