Skip to content

Commit

Permalink
Added logging exception tracking to a few try/excepts
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Blumberg committed Sep 21, 2019
1 parent 5a66959 commit f70d4ca
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion sharppy/databases/pwv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import datetime
import numpy as np
import os
import logging

## written by Greg Blumberg - CIMMS
## and
Expand Down Expand Up @@ -193,7 +194,8 @@ def __init__(self, data_path=os.path.dirname(__file__)):
self._pwv_mn['lon'] = stns[stn_idx]['lon']
self._pwv_st['lat'] = stns[stn_idx]['lat']
self._pwv_st['lon'] = stns[stn_idx]['lon']
except IndexError:
except IndexError as e:
logging.exception(e)
pass

def getStddev(self, stddev, loc, month=None):
Expand Down
8 changes: 6 additions & 2 deletions sharppy/viz/SPCWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ def setProfileCollection(self, prof_id):

try:
self.pc_idx = self.prof_ids.index(prof_id)
except ValueError:
except ValueError as e:
logging.exception(e)
print("Hmmm, that profile doesn't exist to be focused ...")
return

Expand All @@ -338,7 +339,8 @@ def rmProfileCollection(self, prof_id):
logging.debug("Removing Profile Collection from SPCWindow.")
try:
pc_idx = self.prof_ids.index(prof_id)
except ValueError:
except ValueError as e:
logging.exception(e)
print("Hmmm, that profile doesn't exist to be removed ...")
return

Expand Down Expand Up @@ -881,6 +883,7 @@ def addProfileCollection(self, prof_col, focus=True, check_integrity=True):
try:
self.spc_widget.addProfileCollection(prof_col, menu_name, focus=focus)
except Exception as exc:
logging.exception(exc)
print("OOPS:", exc)
### TODO: This may be a good place to output a copy of the offending data (useful for debugging observed data).
if len(self.menu_items) == 1:
Expand All @@ -894,6 +897,7 @@ def testDataIntegrity(self, prof):
try:
prof.checkDataIntegrity()
except Exception as e:
logging.exception(e)
msgBox = QMessageBox()
msgBox.setText("SHARPpy has detected that the data you are attempting to load may have errors.")
msgBox.setInformativeText("Do you want to still try and load the data?")
Expand Down
9 changes: 6 additions & 3 deletions sharppy/viz/skew.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,9 @@ def plotData(self):
self.drawTrace(profile.dwpc, dewp_color, qp, p=profile.pres, width=1)
try:
self.drawBarbs(profile, qp, color="#666666")
except:
except Exception as e:
logging.debug("Couldn't draw wind barbs in skew.py")
logging.exception(e)
bg_color_idx = 0
for idx, prof_col in enumerate(self.prof_collections):
if idx != self.pc_idx and (prof_col.getCurrentDate() == cur_dt or self.all_observed):
Expand All @@ -990,7 +991,8 @@ def plotData(self):
self.drawTrace(profile.dwpc, color, qp, p=profile.pres)
try:
self.drawBarbs(profile, qp, color=color)
except:
except Exception as e:
logging.exception(e)
logging.debug("Couldn't draw wind barbs in skew.py")
bg_color_idx = (bg_color_idx + 1) % len(self.background_colors)

Expand Down Expand Up @@ -1040,7 +1042,8 @@ def plotData(self):
qp.setRenderHint(qp.Antialiasing, False)
try:
self.drawBarbs(self.prof, qp)
except:
except Exception as e:
logging.exception(e)
logging.debug("Couldn't draw wind barbs in skew.py")
qp.setRenderHint(qp.Antialiasing)

Expand Down
1 change: 1 addition & 0 deletions utils/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def run(self):
try:
ret_val = func(*args, **kwargs)
except Exception as e:
logging.exception(e)
if self.debug:
print(traceback.format_exc())
ret_val = e
Expand Down
3 changes: 2 additions & 1 deletion utils/async_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Queue
except ImportError:
import queue as Queue

import logging
import hashlib
from datetime import datetime
import traceback
Expand Down Expand Up @@ -121,6 +121,7 @@ def run(self):
try:
ret_val = func(*args, **kwargs)
except Exception as e:
logging.exception(e)
if self.debug:
print(traceback.format_exc())
ret_val = e
Expand Down

0 comments on commit f70d4ca

Please sign in to comment.