Commit 2322c4a6 authored by Paul Rich's avatar Paul Rich
Browse files

More Spacing Fixes

parent 1378fb7e
...@@ -54,7 +54,7 @@ class MessageQueue(Component): ...@@ -54,7 +54,7 @@ class MessageQueue(Component):
config = _config._sections['cdbwriter'] config = _config._sections['cdbwriter']
mfields = [field for field in _configfields if not config.has_key(field)] mfields = [field for field in _configfields if not config.has_key(field)]
if mfields: if mfields:
logger.error("Missing option(s) in cobalt config file [cdbwriter] section: %s" % (" ".join(mfields))) logger.error("Missing option(s) in cobalt config file [cdbwriter] section: %s", " ".join(mfields))
sys.exit(1) sys.exit(1)
...@@ -126,7 +126,7 @@ class MessageQueue(Component): ...@@ -126,7 +126,7 @@ class MessageQueue(Component):
self.database_writer = DatabaseWriter(database, user, pwd, schema) self.database_writer = DatabaseWriter(database, user, pwd, schema)
except: except:
#make this a log statement #make this a log statement
logging.error("Unable to connect to %s as %s" % (database, user)) logging.error("Unable to connect to %s as %s", database, user)
self.connected = False self.connected = False
logging.debug(traceback.format_exc()) logging.debug(traceback.format_exc())
else: else:
...@@ -160,11 +160,11 @@ class MessageQueue(Component): ...@@ -160,11 +160,11 @@ class MessageQueue(Component):
self.database_writer.addMessage(msg) self.database_writer.addMessage(msg)
except db2util.adapterError: except db2util.adapterError:
logger.error("Error updating databse. Unable to add message due to adapter error. Message dropped.") logger.error("Error updating databse. Unable to add message due to adapter error. Message dropped.")
logging.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
self.msg_queue.pop(0) self.msg_queue.pop(0)
except: except:
logger.error("Error updating databse. Unable to add message. %s", msg) logger.error("Error updating databse. Unable to add message. %s", msg)
logging.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
self.connected = False self.connected = False
#if we were clearing an overflow, here we go again. #if we were clearing an overflow, here we go again.
if ((self.max_queued != None) and if ((self.max_queued != None) and
...@@ -207,7 +207,7 @@ class MessageQueue(Component): ...@@ -207,7 +207,7 @@ class MessageQueue(Component):
msgDict = self.decoder.decode(msg) msgDict = self.decoder.decode(msg)
except ValueError: except ValueError:
logger.error("Bad message recieved. Failed to decode string %s" % msg) logger.error("Bad message recieved. Failed to decode string %s", msg)
return return
except: except:
logging.debug(traceback.format_exc()) logging.debug(traceback.format_exc())
...@@ -249,8 +249,7 @@ class MessageQueue(Component): ...@@ -249,8 +249,7 @@ class MessageQueue(Component):
self.overflow_file.write(json.dumps(msg, cls=LogMessageEncoder)+'\n') self.overflow_file.write(json.dumps(msg, cls=LogMessageEncoder)+'\n')
elements_written += 1 elements_written += 1
except IOError: except IOError:
logger.error('Could only partially empty queue, %d messages written' % logger.error('Could only partially empty queue, %d messages written', elements_written)
elements_written)
self.msg_queue.insert(0, msg) self.msg_queue.insert(0, msg)
if elements_written > 0: if elements_written > 0:
...@@ -275,7 +274,7 @@ class DatabaseWriter(object): ...@@ -275,7 +274,7 @@ class DatabaseWriter(object):
try: try:
self.db.connect(dbName, username, password) self.db.connect(dbName, username, password)
except: except:
logger.error("Failed to open a connection to database %s as user %s" %(dbName, username)) logger.error("Failed to open a connection to database %s as user %s", dbName, username)
raise raise
self.schema = schema self.schema = schema
...@@ -292,7 +291,7 @@ class DatabaseWriter(object): ...@@ -292,7 +291,7 @@ class DatabaseWriter(object):
self.daos = {} self.daos = {}
try: try:
for table_name in table_names: for table_name in table_names:
logger.info("Accessing table: %s" % table_name) logger.info("Accessing table: %s", table_name)
if table_name in ['RESERVATION_EVENTS', 'JOB_EVENTS', if table_name in ['RESERVATION_EVENTS', 'JOB_EVENTS',
'JOB_COBALT_STATES']: 'JOB_COBALT_STATES']:
...@@ -317,7 +316,7 @@ class DatabaseWriter(object): ...@@ -317,7 +316,7 @@ class DatabaseWriter(object):
self.daos[table_name] = db2util.dao(self.db, schema, self.daos[table_name] = db2util.dao(self.db, schema,
table_name) table_name)
except: except:
logger.error("Error accessing table %s!" % table_name) logger.error("Error accessing table %s!", table_name)
self.db.close() self.db.close()
raise raise
...@@ -326,7 +325,7 @@ class DatabaseWriter(object): ...@@ -326,7 +325,7 @@ class DatabaseWriter(object):
self.db.prepExec("set current schema %s" % schema) self.db.prepExec("set current schema %s" % schema)
def addMessage(self, logMsg): def addMessage(self, logMsg):
logger.debug("Inserting Data message of type: %s.%s " % (logMsg.item_type, logMsg.state)) logger.debug("Inserting Data message of type: %s.%s ", logMsg.item_type, logMsg.state)
#print logMsg #print logMsg
if logMsg.item_type == 'reservation': if logMsg.item_type == 'reservation':
...@@ -394,8 +393,8 @@ class DatabaseWriter(object): ...@@ -394,8 +393,8 @@ class DatabaseWriter(object):
reservation_event_record = self.daos['RESERVATION_EVENTS'].table.getRecord({'NAME': logMsg.state}) reservation_event_record = self.daos['RESERVATION_EVENTS'].table.getRecord({'NAME': logMsg.state})
match = self.daos['RESERVATION_EVENTS'].search(reservation_event_record) match = self.daos['RESERVATION_EVENTS'].search(reservation_event_record)
if not match: if not match:
logger.warning("Received message with a nonexistent event for resid %s. Event was: %s" % logger.warning("Received message with a nonexistent event for resid %s. Event was: %s",
(logMsg.item.res_id, logMsg.state)) logMsg.item.res_id, logMsg.state)
else: else:
reservation_event_record.v.ID = match[0]['ID'] reservation_event_record.v.ID = match[0]['ID']
...@@ -419,8 +418,8 @@ class DatabaseWriter(object): ...@@ -419,8 +418,8 @@ class DatabaseWriter(object):
reservation_event_record = self.daos['RESERVATION_EVENTS'].table.getRecord({'NAME': logMsg.state}) reservation_event_record = self.daos['RESERVATION_EVENTS'].table.getRecord({'NAME': logMsg.state})
match = self.daos['RESERVATION_EVENTS'].search(reservation_event_record) match = self.daos['RESERVATION_EVENTS'].search(reservation_event_record)
if not match: if not match:
logger.warning("Received message with a nonexistent event for resid %s. Event was: %s" % logger.warning("Received message with a nonexistent event for resid %s. Event was: %s",
(logMsg.item.res_id, logMsg.state)) logMsg.item.res_id, logMsg.state)
else: else:
reservation_event_record.v.ID = match[0]['ID'] reservation_event_record.v.ID = match[0]['ID']
...@@ -573,8 +572,8 @@ class DatabaseWriter(object): ...@@ -573,8 +572,8 @@ class DatabaseWriter(object):
job_event_record = self.daos['JOB_EVENTS'].table.getRecord({'NAME': logMsg.state}) job_event_record = self.daos['JOB_EVENTS'].table.getRecord({'NAME': logMsg.state})
match = self.daos['JOB_EVENTS'].search(job_event_record) match = self.daos['JOB_EVENTS'].search(job_event_record)
if not match: if not match:
logger.warning("Received message with a nonexistent event for jobid %s. Event was: %s" % logger.warning("Received message with a nonexistent event for jobid %s. Event was: %s",
(job_data_id, logMsg.state)) job_data_id, logMsg.state)
else: else:
job_event_record.v.ID = match[0]['ID'] job_event_record.v.ID = match[0]['ID']
...@@ -584,8 +583,8 @@ class DatabaseWriter(object): ...@@ -584,8 +583,8 @@ class DatabaseWriter(object):
job_cobalt_states_record = self.daos['JOB_COBALT_STATES'].table.getRecord({'NAME': job_prog_msg.cobalt_state}) job_cobalt_states_record = self.daos['JOB_COBALT_STATES'].table.getRecord({'NAME': job_prog_msg.cobalt_state})
match = self.daos['JOB_COBALT_STATES'].search(job_cobalt_states_record) match = self.daos['JOB_COBALT_STATES'].search(job_cobalt_states_record)
if not match: if not match:
logger.warning("Received message with a nonexistent cobalt state for jobid %s. Event was: %s" % logger.warning("Received message with a nonexistent cobalt state for jobid %s. Event was: %s",
(job_data_id, job_prog_msg.cobalt_state)) job_data_id, job_prog_msg.cobalt_state)
else: else:
job_cobalt_states_record.v.ID = match[0]['ID'] job_cobalt_states_record.v.ID = match[0]['ID']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment