本文整理汇总了Python中vistrails.core.debug.format_exception函数的典型用法代码示例。如果您正苦于以下问题:Python format_exception函数的具体用法?Python format_exception怎么用?Python format_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_exception函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:Nikea,项目名称:VisTrails,代码行数:56,代码来源:init.py
示例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)))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:29,代码来源:init.py
示例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))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:26,代码来源:init.py
示例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)))
开发者ID:Nikea,项目名称:VisTrails,代码行数:30,代码来源:console_mode.py
示例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())
开发者ID:Nikea,项目名称:VisTrails,代码行数:27,代码来源:console_mode.py
示例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)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:8,代码来源:paramexplore.py
示例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)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:9,代码来源:paramexplore.py
示例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()))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:10,代码来源:package.py
示例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()))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:13,代码来源:package.py
示例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
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:13,代码来源:package.py
示例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
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:13,代码来源:package.py
示例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()
开发者ID:pradal,项目名称:VisTrails,代码行数:13,代码来源:mashup_app.py
示例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 = []
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:15,代码来源:package.py
示例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()))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:16,代码来源:package.py
示例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)))
开发者ID:hjanime,项目名称:VisTrails,代码行数:47,代码来源:console_mode.py
示例16: contextMenuEvent
def contextMenuEvent(self, event):
"""Just dispatches the menu event to the widget item"""
item = self.itemAt(event.pos())
if item:
# find top level
p = item
while p.parent():
p = p.parent()
# get package identifier
assert isinstance(p, QPackageTreeWidgetItem)
identifier = p.identifier
registry = get_module_registry()
package = registry.packages[identifier]
try:
if package.has_context_menu():
if isinstance(item, QPackageTreeWidgetItem):
text = None
elif isinstance(item, QNamespaceTreeWidgetItem):
return # no context menu for namespaces
elif isinstance(item, QModuleTreeWidgetItem):
text = item.descriptor.name
if item.descriptor.namespace:
text = '%s|%s' % (item.descriptor.namespace, text)
else:
assert False, "fell through"
menu_items = package.context_menu(text)
if menu_items:
menu = QtGui.QMenu(self)
for text, callback in menu_items:
act = QtGui.QAction(text, self)
act.setStatusTip(text)
QtCore.QObject.connect(act,
QtCore.SIGNAL("triggered()"),
callback)
menu.addAction(act)
menu.exec_(event.globalPos())
return
except Exception, e:
debug.unexpected_exception(e)
debug.warning("Got exception trying to display %s's "
"context menu in the palette: %s\n%s" % (
package.name,
debug.format_exception(e),
traceback.format_exc()))
item.contextMenuEvent(event, self)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:46,代码来源:module_palette.py
示例17: _open_ssh
def _open_ssh(self, username, password, hostname, portnum, path):
paramiko = py_import('paramiko', {
'pip': 'paramiko',
'linux-debian': 'python-paramiko',
'linux-ubuntu': 'python-paramiko',
'linux-fedora': 'python-paramiko'})
scp = py_import('scp', {
'pip': 'scp'})
local_filename = os.path.join(package_directory,
cache_filename(self.url))
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
try:
ssh.connect(hostname, port=portnum,
username=username, password=password)
except paramiko.SSHException, e:
raise ModuleError(self.module, debug.format_exception(e))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:19,代码来源:init.py
示例18: call_it
def call_it(function, p):
# Translate between VisTrails objects and VTK objects
if p is None:
# None indicates a call with no parameters
params = []
elif isinstance(p, tuple):
# A tuple indicates a call with many parameters
params = list(p)
else:
# Otherwise, it's a single parameter
params = [p]
# Unwraps VTK objects
for i in xrange(len(params)):
if hasattr(params[i], 'vtkInstance'):
params[i] = params[i].vtkInstance
try:
self.call_input_function(function, params)
except Exception, e:
raise ModuleError(
self,
"VTK Exception: %s" % debug.format_exception(e))
开发者ID:tacaswell,项目名称:VisTrails,代码行数:22,代码来源:base_module.py
示例19: cleanup
def cleanup(self):
"""cleanup() -> None
Cleans up the file pool, by removing all temporary files and
the directory they existed in. Module developers should never
call this directly.
"""
if not os.path.isdir(self.directory):
# cleanup has already happened
return
try:
for root, dirs, files in os.walk(self.directory, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(self.directory)
except OSError, e:
debug.unexpected_exception(e)
raise VistrailsInternalError("Can't remove %s: %s" %
(self.directory,
debug.format_exception(e)))
开发者ID:danielballan,项目名称:VisTrails,代码行数:23,代码来源:module_utils.py
示例20: execute
def execute(self):
""" Tries to download a file from url.
Returns the path to the local file.
"""
self.local_filename = os.path.join(package_directory,
cache_filename(self.url))
# Before download
self.pre_download()
# Send request
try:
response = self.send_request()
except urllib2.URLError, e:
if self.is_in_local_cache:
debug.warning("A network error occurred. DownloadFile will "
"use a cached version of the file")
return self.local_filename
else:
raise ModuleError(
self.module,
"Network error: %s" % debug.format_exception(e))
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:23,代码来源:init.py
注:本文中的vistrails.core.debug.format_exception函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论