本文整理汇总了Python中vistrails.core.debug.format_exception函数的典型用法代码示例。如果您正苦于以下问题:Python format_exception函数的具体用法?Python format_exception怎么用?Python format_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute
def compute(self):
url = URL(drivername=self.get_input('protocol'),
username=self.force_get_input('user', None),
password=self.force_get_input('password', None),
host=self.force_get_input('host', None),
port=self.force_get_input('port', None),
database=self.get_input('db_name'))
try:
engine = create_engine(url)
except ImportError, e:
driver = url.drivername
installed = False
if driver == 'sqlite':
raise ModuleError(self,
"Python was built without sqlite3 support")
elif (driver == 'mysql' or
driver == 'drizzle'): # drizzle is a variant of MySQL
installed = install({
'pip': 'mysql-python',
'linux-debian': 'python-mysqldb',
'linux-ubuntu': 'python-mysqldb',
'linux-fedora': 'MySQL-python'})
elif (driver == 'postgresql' or
driver == 'postgre'): # deprecated alias
installed = install({
'pip': 'psycopg2',
'linux-debian':'python-psycopg2',
'linux-ubuntu':'python-psycopg2',
'linux-fedora':'python-psycopg2'})
elif driver == 'firebird':
installed = install({
'pip': 'fdb',
'linux-fedora':'python-fdb'})
elif driver == 'mssql' or driver == 'sybase':
installed = install({
'pip': 'pyodbc',
'linux-debian':'python-pyodbc',
'linux-ubuntu':'python-pyodbc',
'linux-fedora':'pyodbc'})
elif driver == 'oracle':
installed = install({
'pip': 'cx_Oracle'})
else:
raise ModuleError(self,
"SQLAlchemy couldn't connect: %s" %
debug.format_exception(e))
if not installed:
raise ModuleError(self,
"Failed to install required driver")
try:
engine = create_engine(url)
except Exception, e:
raise ModuleError(self,
"Couldn't connect to the database: %s" %
debug.format_exception(e))
示例2: compute
def compute(self):
# create dict of inputs
cacheable = False
if self.has_input('cacheable'):
cacheable = self.get_input('cacheable')
self.is_cacheable = lambda *args, **kwargs: cacheable
params = {}
mname = self.wsmethod.qname[0]
for name in self.wsmethod.inputs:
name = str(name)
if self.has_input(name):
params[name] = self.get_input(name)
if params[name].__class__.__name__ == 'UberClass':
params[name] = params[name].value
params[name] = self.service.makeDictType(params[name])
try:
#import logging
#logging.basicConfig(level=logging.INFO)
#logging.getLogger('suds.client').setLevel(logging.DEBUG)
#print "params:", str(params)[:400]
#self.service.service.set_options(retxml = True)
#result = getattr(self.service.service.service, mname)(**params)
#print "result:", str(result)[:400]
#self.service.service.set_options(retxml = False)
result = getattr(self.service.service.service, mname)(**params)
except Exception, e:
debug.unexpected_exception(e)
raise ModuleError(self, "Error invoking method %s: %s" % (
mname, debug.format_exception(e)))
示例3: download
def download(self, response):
try:
dl_size = 0
CHUNKSIZE = 4096
f2 = open(self.local_filename, 'wb')
while True:
if self.size_header is not None:
self.module.logging.update_progress(
self.module,
dl_size * 1.0/self.size_header)
chunk = response.read(CHUNKSIZE)
if not chunk:
break
dl_size += len(chunk)
f2.write(chunk)
f2.close()
response.close()
except Exception, e:
try:
os.unlink(self.local_filename)
except OSError:
pass
raise ModuleError(
self.module,
"Error retrieving URL: %s" % debug.format_exception(e))
示例4: get_vt_graph
def get_vt_graph(vt_list, tree_info, pdf=False):
"""get_vt_graph(vt_list: list of locator, tree_info:str)
Load all vistrails in vt_list and dump their tree to tree_info.
"""
result = []
if is_running_gui():
from vistrails.gui.vistrail_controller import VistrailController as \
GUIVistrailController
for locator in vt_list:
try:
(v, abstractions , thumbnails, mashups) = load_vistrail(locator)
controller = GUIVistrailController(v, locator, abstractions,
thumbnails, mashups)
if tree_info is not None:
from vistrails.gui.version_view import QVersionTreeView
version_view = QVersionTreeView()
version_view.scene().setupScene(controller)
if pdf:
base_fname = "graph_%s.pdf" % locator.short_filename
filename = os.path.join(tree_info, base_fname)
version_view.scene().saveToPDF(filename)
else:
base_fname = "graph_%s.png" % locator.short_filename
filename = os.path.join(tree_info, base_fname)
version_view.scene().saveToPNG(filename)
del version_view
result.append((True, ""))
except Exception, e:
result.append((False, debug.format_exception(e)))
示例5: run_parameter_exploration
def run_parameter_exploration(locator, pe_id, extra_info = {},
reason="Console Mode Parameter Exploration Execution"):
"""run_parameter_exploration(w_list: (locator, version),
pe_id: str/int,
reason: str) -> (pe_id, [error msg])
Run parameter exploration in w, and returns an interpreter result object.
version can be a tag name or a version id.
"""
if is_running_gui():
from vistrails.gui.vistrail_controller import VistrailController as \
GUIVistrailController
try:
(v, abstractions , thumbnails, mashups) = load_vistrail(locator)
controller = GUIVistrailController(v, locator, abstractions,
thumbnails, mashups)
try:
pe_id = int(pe_id)
pe = controller.vistrail.get_paramexp(pe_id)
except ValueError:
pe = controller.vistrail.get_named_paramexp(pe_id)
controller.change_selected_version(pe.action_id)
controller.executeParameterExploration(pe, extra_info=extra_info,
showProgress=False)
except Exception, e:
return (locator, pe_id,
debug.format_exception(e), debug.format_exc())
示例6: evaluate
def evaluate(i):
try:
v = d['value'](i)
if v is None:
return self._ptype.default_value
return v
except Exception, e:
return debug.format_exception(e)
示例7: evaluate
def evaluate(i):
try:
v = d['value'](i)
if v is None:
return module.default_value
return v
except Exception, e:
debug.unexpected_exception(e)
return debug.format_exception(e)
示例8: saveVistrailFileHook
def saveVistrailFileHook(self, vistrail, tmp_dir):
if hasattr(self._init_module, 'saveVistrailFileHook'):
try:
self._init_module.saveVistrailFileHook(vistrail, tmp_dir)
except Exception, e:
debug.unexpected_exception(e)
debug.critical("Got exception in %s's saveVistrailFileHook(): "
"%s\n%s" % (self.name,
debug.format_exception(e),
traceback.format_exc()))
示例9: menu_items
def menu_items(self):
try:
callable_ = self._module.menu_items
except AttributeError:
return None
else:
try:
return callable_()
except Exception, e:
debug.unexpected_exception(e)
debug.critical("Couldn't load menu items for %s: %s\n%s" % (
self.name, debug.format_exception(e),
traceback.format_exc()))
示例10: can_handle_vt_file
def can_handle_vt_file(self, name):
""" Asks package if it can handle a file inside a zipped vt file
"""
try:
return (hasattr(self.init_module, 'can_handle_vt_file') and
self.init_module.can_handle_vt_file(name))
except Exception, e:
debug.unexpected_exception(e)
debug.critical("Got exception calling %s's can_handle_vt_file: "
"%s\n%s" % (self.name,
debug.format_exception(e),
traceback.format_exc()))
return False
示例11: can_handle_identifier
def can_handle_identifier(self, identifier):
""" Asks package if it can handle this package
"""
try:
return (hasattr(self.init_module, 'can_handle_identifier') and
self.init_module.can_handle_identifier(identifier))
except Exception, e:
debug.unexpected_exception(e)
debug.critical("Got exception calling %s's can_handle_identifier: "
"%s\n%s" % (self.name,
debug.format_exception(e),
traceback.format_exc()))
return False
示例12: runAndGetCellEvents
def runAndGetCellEvents(self, useDefaultValues=False):
spreadsheetController.setEchoMode(True)
#will run to get Spreadsheet Cell events
cellEvents = []
errors = []
try:
(res, errors) = self.run(useDefaultValues)
if res:
cellEvents = spreadsheetController.getEchoCellEvents()
except Exception, e:
import traceback
debug.unexpected_exception(e)
print "Executing pipeline failed:", debug.format_exception(e), traceback.format_exc()
示例13: dependencies
def dependencies(self):
deps = []
try:
callable_ = self._module.package_dependencies
except AttributeError:
pass
else:
try:
deps = callable_()
except Exception, e:
debug.critical(
"Couldn't get dependencies of %s: %s\n%s" % (
self.name, debug.format_exception(e),
traceback.format_exc()))
deps = []
示例14: finalize
def finalize(self):
if not self._initialized:
return
debug.log("Finalizing %s" % self.name)
try:
callable_ = self._module.finalize
except AttributeError:
pass
else:
try:
callable_()
except Exception, e:
debug.unexpected_exception(e)
debug.critical("Couldn't finalize %s: %s\n%s" % (
self.name, debug.format_exception(e),
traceback.format_exc()))
示例15: get_wf_graph
def get_wf_graph(w_list, output_dir, pdf=False):
"""run_and_get_results(w_list: list of (locator, version),
output_dir:str, pdf:bool)
Load all workflows in wf_list and dump their graph to output_dir.
"""
result = []
if is_running_gui():
from vistrails.gui.vistrail_controller import VistrailController as \
GUIVistrailController
for locator, workflow in w_list:
try:
(v, abstractions , thumbnails, mashups) = load_vistrail(locator)
controller = GUIVistrailController(v, locator, abstractions,
thumbnails, mashups,
auto_save=False)
# FIXME TE: why is this needed
controller.current_pipeline_view.set_controller(controller)
version = None
if isinstance(workflow, basestring):
version = v.get_version_number(workflow)
elif isinstance(workflow, (int, long)):
version = workflow
elif workflow is None:
version = controller.get_latest_version_in_graph()
else:
msg = "Invalid version tag or number: %s" % workflow
raise VistrailsInternalError(msg)
controller.change_selected_version(version)
if controller.current_pipeline is not None:
controller.updatePipelineScene()
if pdf:
base_fname = "%s_%s_pipeline.pdf" % \
(locator.short_filename, version)
filename = os.path.join(output_dir, base_fname)
controller.current_pipeline_scene.saveToPDF(filename)
else:
base_fname = "%s_%s_pipeline.png" % \
(locator.short_filename, version)
filename = os.path.join(output_dir, base_fname)
controller.current_pipeline_scene.saveToPNG(filename)
result.append((True, ""))
except Exception, e:
result.append((False, debug.format_exception(e)))