Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4516 from dciangot/Dash2
Browse files Browse the repository at this point in the history
Fix exception and disconnect for Dashboard script
  • Loading branch information
mmascher authored Nov 1, 2016
2 parents 5a71487 + e8717ef commit f42d729
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
17 changes: 9 additions & 8 deletions bin/DashboardNotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
from __future__ import division
import stomp
import json
import traceback
import os
import sys
import datetime
import logging
from multiprocessing import Process

def reportToAmq(filePath, logging, conn):

def reportToAmq(filePath, log, connect):
"""
"""
jsonData=open(filePath)
message = json.load(jsonData)
logging.debug("Producing...%s" % message)
log.debug("Producing...%s" % message)
try:
messageDict = json.dumps(message)
conn.send(messageDict, destination=authParams['MSG_QUEUE'] )
except Exception as ex:
logging.exception("Error contacting Message Broker or reading json")
connect.send(messageDict, destination=authParams['MSG_QUEUE'] )
except Exception:
log.exception("Error contacting Message Broker or reading json")
sys.exit(1)

logging.basicConfig(filename='/data/srv/asyncstageout/current/config/log.config', level=logging.DEBUG)
Expand All @@ -30,7 +30,7 @@ def reportToAmq(filePath, logging, conn):
f = open(amqAuthFile)
authParams = json.loads(f.read())
f.close()
except Exception as ex:
except Exception:
logging.exception("Error loading auth params")
sys.exit(1)

Expand All @@ -39,8 +39,9 @@ def reportToAmq(filePath, logging, conn):
conn = stomp.Connection(host, authParams['MSG_USER'], authParams['MSG_PWD'])
conn.start()
conn.connect()
except Exception as ex:
except Exception:
logging.exception("Error contacting Message Broker")
conn.disconnect()
sys.exit(1)

for dashboardFile in os.listdir("/tmp/DashboardReport"):
Expand Down
14 changes: 5 additions & 9 deletions src/python/AsyncStageOut/TransferDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,16 @@ def __init__(self, config):
try:
os.makedirs(self.dropbox_dir)
except OSError as e:
if e.errno == errno.EEXIST:
pass
else:
self.logger.error('Unknown error in mkdir' % e.errno)
if not e.errno == errno.EEXIST:
self.logger.exception('Unknown error in mkdir' % e.errno)
raise

if not os.path.isdir("/tmp/DashboardReport"):
if not os.path.isdir("/tmp/DashboardReport"):
try:
os.makedirs("/tmp/DashboardReport")
except OSError as e:
if e.errno == errno.EEXIST:
pass
else:
self.logger.error('Unknown error in mkdir' % e.errno)
if not e.errno == errno.EEXIST:
self.logger.exception('Unknown error in mkdir' % e.errno)
raise

server = CouchServer(dburl=self.config.couch_instance, ckey=self.config.opsProxy, cert=self.config.opsProxy)
Expand Down

0 comments on commit f42d729

Please sign in to comment.