Skip to content

Commit

Permalink
Fixes except: blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Apr 17, 2014
1 parent d4c7dbe commit 3eeb599
Show file tree
Hide file tree
Showing 61 changed files with 168 additions and 149 deletions.
2 changes: 1 addition & 1 deletion vistrails/core/analogy/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def smart_sum(v):
try:
fst = v.next()
return sum(v, fst)
except:
except Exception:
pass
fst = v[0]
return sum(v[1:], fst)
Expand Down
4 changes: 3 additions & 1 deletion vistrails/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import vistrails.core.application
from vistrails.core.db.locator import FileLocator, untitled_locator
import vistrails.core.db.io
from vistrails.core import debug
from vistrails.core.modules.basic_modules import identifier as basic_pkg
from vistrails.core.modules.module_registry import get_module_registry
from vistrails.core.modules.utils import create_port_spec_string
Expand Down Expand Up @@ -401,7 +402,8 @@ def _convert_version(self, version):
try:
version = \
self.controller.vistrail.get_version_number(version)
except:
except Exception, e:
debug.unexpected_exception(e)
raise ValueError('Cannot locate version "%s"' % version)
return version

Expand Down
6 changes: 4 additions & 2 deletions vistrails/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ def convert_version(self, version):
try:
version = \
self.get_controller().vistrail.get_version_number(version)
except:
except Exception, e:
debug.unexpected_exception(e)
version = None
return version

Expand Down Expand Up @@ -749,7 +750,8 @@ def save_vistrail(self, locator=None, controller=None, export=False):
controller.flush_delayed_actions()
try:
controller.write_vistrail(locator, export=export)
except Exception:
except Exception, e:
debug.unexpected_exception(e)
import traceback
debug.critical("Failed to save vistrail", traceback.format_exc())
raise
Expand Down
9 changes: 6 additions & 3 deletions vistrails/core/collection/vistrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def add_workflow_entity(self, version_id):
tag = self.vistrail.get_tag(version_id)
try:
workflow = self.vistrail.getPipeline(version_id)
except:
except Exception, e:
debug.unexpected_exception(e)
import traceback
debug.critical("Failed to construct pipeline '%s'" %
(tag if tag else version_id),
Expand Down Expand Up @@ -259,7 +260,8 @@ def add_wf_exec_entity(self, wf_exec, add_to_map=False):
action = self.vistrail.actionMap[version_id]
try:
workflow = self.vistrail.getPipeline(version_id)
except:
except Exception, e:
debug.unexpected_exception(e)
import traceback
if self.vistrail.has_tag(version_id):
tag_str = self.vistrail.get_tag(version_id)
Expand Down Expand Up @@ -346,7 +348,8 @@ def reload(self, vistrail):
# read persisted log entries
try:
log = vistrail.get_persisted_log()
except:
except Exception, e:
debug.unexpected_exception(e)
import traceback
debug.critical("Failed to read log", traceback.format_exc())

Expand Down
4 changes: 2 additions & 2 deletions vistrails/core/data_structures/bijectivedict.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def __copy__(self):
return r

def update(self, other):
try:
if hasattr(other, 'iterkeys'):
for i in other.iterkeys():
self[i] = other[i]
except:
else:
for (k,v) in other:
self[k] = v

Expand Down
4 changes: 2 additions & 2 deletions vistrails/core/db/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def update_from_console(self):
f.write("\nConnect to db with username [%s]: "%self._user)
f.close()
user = raw_input()
except:
except IOError:
debug.warning("Couldn't write to terminal. Will try stdout")
user = raw_input("Connecting to db with username[%s]: "%self._user)
try:
Expand Down Expand Up @@ -677,7 +677,7 @@ def guess_extension_from_contents(contents):
showSpreadsheetOnly = False
try:
version = int(version)
except:
except ValueError:
pass

if tag is None:
Expand Down
2 changes: 1 addition & 1 deletion vistrails/core/interpreter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def evaluate_exp(self, atype, base, exps, aliases):
base = '0'
try:
base = eval(base,None,None)
except:
except Exception:
pass
return base

Expand Down
6 changes: 3 additions & 3 deletions vistrails/core/mashup/mashup.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def remapPipelineObjects(self, id_remap):
alias.component.vtparent_id = new_pid
new_id = id_remap[(alias.component.vttype,alias.component.vtid)]
alias.component.vtid = new_id
except:
except Exception:
pass

def validateForPipeline(self, pipeline):
"""validateForPipeline(pipeline) -> None
This will make sure that the parameters in the alias list are present
Expand All @@ -202,7 +202,7 @@ def validateForPipeline(self, pipeline):
try:
param = pipeline.db_get_object(alias.component.vttype,
alias.component.vtid)
except:
except Exception:
to_remove.append(alias)
for a in to_remove:
self.alias_list.remove(a)
Expand Down
9 changes: 4 additions & 5 deletions vistrails/core/mashup/mashup_trail.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,11 @@ def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
return cp

def getLatestVersion(self):
try:
max_ver = max(a.id for a in self.actions)
return max_ver
except:
if not self.actions:
return 0

max_ver = max(a.id for a in self.actions)
return max_ver

def getMashup(self, version):
if version in self.actionMap.keys():
return self.actionMap[version].mashup
Expand Down
2 changes: 1 addition & 1 deletion vistrails/core/modules/basic_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def string_compare(value_a, value_b, query_method):
m = re.match(value_b, value_a)
if m is not None:
return (m.end() ==len(value_a))
except:
except re.error:
pass
return False

Expand Down
7 changes: 4 additions & 3 deletions vistrails/core/modules/module_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,10 @@ def convert_port_val(self, val, sig=None, cls=None):
desc = self.get_descriptor_by_name(*sig)
else:
desc = self.get_descriptor(cls)
except:
raise Exception('Cannot convert value "%s" due to missing '
'descriptor for port' % val)
except Exception, e:
debug.unexpected_exception(e)
raise VistrailsInternalError("Cannot convert value %r due to "
"missing descriptor for port" % val)
constant_desc = self.get_descriptor_by_name(basic_pkg, 'Constant')
if not self.is_descriptor_subclass(desc, constant_desc):
raise TypeError("Cannot convert value for non-constant type")
Expand Down
3 changes: 2 additions & 1 deletion vistrails/core/modules/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ def initialize(self):

if hasattr(self._init_module, 'initialize'):
self._init_module.initialize()
except Exception:
except Exception, e:
debug.unexpected_exception(e)
self.unload()
raise

Expand Down
10 changes: 5 additions & 5 deletions vistrails/core/modules/vistrails_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,15 @@ def get_default_value(self, port_name):
d = None
try:
d = reg.get_descriptor(self.__class__)
except:
except Exception:
pass
if not d:
return None

ps = None
try:
ps = reg.get_port_spec_from_descriptor(d, port_name, 'input')
except:
except Exception:
pass
if not ps:
return None
Expand Down Expand Up @@ -677,9 +677,9 @@ def create_instance_of_type(self, ident, name, ns=''):
reg = get_module_registry()
m = reg.get_module_by_name(ident, name, ns)
return m()
except:
msg = "Cannot get module named " + str(name) + \
" with identifier " + str(ident) + " and namespace " + ns
except Exception:
msg = ("Cannot get module named %s with identifier %s and "
"namespace %s" % (name, ident, ns))
raise ModuleError(self, msg)

@classmethod
Expand Down
8 changes: 4 additions & 4 deletions vistrails/core/paramexplore/paramexplore.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,24 @@ def convert(_parameter_exploration):
def get_dims(self):
try:
return eval(self._dims)
except:
except Exception:
return []
def set_dims(self, d):
try:
_dims = repr(d)
except:
except Exception:
_dims = []
dims = property(get_dims, set_dims)

def get_layout(self):
try:
return eval(self._layout)
except:
except Exception:
return {}
def set_layout(self, l):
try:
_layout = repr(l)
except:
except Exception:
_layout = '{}'
layout = property(get_layout, set_layout)

Expand Down
2 changes: 1 addition & 1 deletion vistrails/core/repository/poster/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __init__(self, name, value=None, filename=None, filetype=None,
fileobj.seek(0, 2)
self.filesize = fileobj.tell()
fileobj.seek(0)
except:
except IOError:
raise ValueError("Could not determine filesize")

def __cmp__(self, other):
Expand Down
Loading

0 comments on commit 3eeb599

Please sign in to comment.