本文整理汇总了Python中vistrails.core.thumbnails.ThumbnailCache.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python ThumbnailCache.getInstance方法的具体用法?Python ThumbnailCache.getInstance怎么用?Python ThumbnailCache.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vistrails.core.thumbnails.ThumbnailCache
的用法示例。
在下文中一共展示了ThumbnailCache.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_as
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def save_as(self, save_bundle, version=None):
save_bundle = _ZIPFileLocator.save(self, save_bundle, True, version)
for obj in save_bundle.get_db_objs():
klass = self.get_convert_klass(obj.vtType)
klass.convert(obj)
obj.locator = self
# Need to update thumbnail cache since files have moved
ThumbnailCache.getInstance().add_entries_from_files(save_bundle.thumbnails)
return save_bundle
示例2: clear_clicked
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def clear_clicked(self, checked=False):
thumbnail_dir = system.get_vistrails_directory("thumbs.cacheDir")
res = show_question('VisTrails',
("All files in %s will be removed. "
"Are you sure? " % thumbnail_dir),
buttons = [YES_BUTTON,NO_BUTTON],
default = NO_BUTTON)
if res == YES_BUTTON:
ThumbnailCache.getInstance().clear()
示例3: setupVersion
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def setupVersion(self, node, action, tag, description):
""" setupPort(node: DotNode,
action: DBAction,
tag: str,
description: str) -> None
Update the version dimensions and id
"""
# Lauro:
# what was this hacking??? the coordinates inside
# the input "node" should come to this point ready. This is
# not the point to do layout calculations (e.g. -node.p.y/2)
# Carlos:
# This is not layout as much as dealing with the way Qt
# specifies rectangles. Besides, moving this back here reduces
# code duplication, and allows customized behavior for
# subclasses.
rect = QtCore.QRectF(node.p.x-node.width/2.0,
node.p.y-node.height/2.0,
node.width,
node.height)
validLabel = True
if tag is None:
label = ''
validLabel=False
else:
label = tag
self.id = node.id
self.label = label
if description is None:
self.descriptionLabel = ''
else:
self.descriptionLabel = description
if validLabel:
textToDraw=self.label
else:
textToDraw=self.descriptionLabel
if (ThumbnailCache.getInstance().conf.mouseHover and
action and action.thumbnail is not None):
fname = ThumbnailCache.getInstance().get_abs_name_entry(action.thumbnail)
self.setToolTip('<img src="%s" height="128" border="1"/>'%fname)
else:
self.setToolTip('')
self.text.changed(node.p.x, node.p.y, textToDraw, validLabel)
self.setRect(rect)
示例4: save_vistrail
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def save_vistrail(self, locator_class,
vistrailView=None,
force_choose_locator=False):
"""
force_choose_locator=True triggers 'save as' behavior
"""
global bobo
if not vistrailView:
vistrailView = self.currentWidget()
vistrailView.flush_changes()
if vistrailView:
gui_get = locator_class.save_from_gui
# get a locator to write to
if force_choose_locator:
locator = gui_get(self, Vistrail.vtType,
vistrailView.controller.locator)
else:
locator = (vistrailView.controller.locator or
gui_get(self, Vistrail.vtType,
vistrailView.controller.locator))
if locator == untitled_locator():
locator = gui_get(self, Vistrail.vtType,
vistrailView.controller.locator)
# if couldn't get one, ignore the request
if not locator:
return False
# update collection
vistrailView.controller.flush_delayed_actions()
try:
vistrailView.controller.write_vistrail(locator)
except Exception, e:
debug.critical('An error has occurred', str(e))
raise
return False
try:
thumb_cache = ThumbnailCache.getInstance()
vistrailView.controller.vistrail.thumbnails = \
vistrailView.controller.find_thumbnails(
tags_only=thumb_cache.conf.tagsOnly)
vistrailView.controller.vistrail.abstractions = \
vistrailView.controller.find_abstractions(
vistrailView.controller.vistrail, True)
collection = Collection.getInstance()
url = locator.to_url()
# create index if not exist
entity = collection.fromUrl(url)
if entity:
# find parent vistrail
while entity.parent:
entity = entity.parent
else:
entity = collection.updateVistrail(url, vistrailView.controller.vistrail)
# add to relevant workspace categories
collection.add_to_workspace(entity)
collection.commit()
except Exception, e:
debug.critical('Failed to index vistrail', str(e))
示例5: add_mashup_entity
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def add_mashup_entity(self, mashuptrail, version_id, tag=None):
if not hasattr(self.vistrail, 'mashups'):
return
if mashuptrail not in self.vistrail.mashups:
return
action = mashuptrail.actionMap[version_id]
mashup = mashuptrail.getMashup(version_id)
if tag:
mashup.name = tag
mashup.id = action.id
entity_key = (mashuptrail.id,version_id)
self.mshp_entity_map[entity_key] = \
self.create_mashup_entity(mashuptrail.id, mashup, action)
# get thumbnail for the workflow it points
thumb_version = mashuptrail.vtVersion
thumbnail = self.vistrail.get_thumbnail(thumb_version)
if thumbnail is not None:
cache = ThumbnailCache.getInstance()
path = cache.get_abs_name_entry(thumbnail)
if path:
entity = ThumbnailEntity(path)
mshp_entity = self.mshp_entity_map[entity_key]
mshp_entity.children.append(entity)
entity.parent = mshp_entity
return self.mshp_entity_map[entity_key]
示例6: add_mashup_entities_from_mashuptrail
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def add_mashup_entities_from_mashuptrail(self, mashuptrail):
added_entry_keys = set()
inv_tag_map = {}
tagMap = mashuptrail.getTagMap()
tags = tagMap.keys()
if len(tags) > 0:
tags.sort()
for tag in tags:
version_id = tagMap[tag]
inv_tag_map[version_id] = tag
action = mashuptrail.actionMap[version_id]
mashup = mashuptrail.getMashup(version_id)
mashup.name = tag
#make sure we identify a mashup by its version
mashup.id = action.id
entity_key = (mashuptrail.id,version_id)
self.mshp_entity_map[entity_key] = \
self.create_mashup_entity(mashuptrail.id, mashup, action)
added_entry_keys.add(entity_key)
# get thumbnail for the workflow it points
thumb_version = mashuptrail.vtVersion
thumbnail = self.vistrail.get_thumbnail(thumb_version)
if thumbnail is not None:
cache = ThumbnailCache.getInstance()
path = cache.get_abs_name_entry(thumbnail)
if path:
entity = ThumbnailEntity(path)
mshp_entity = self.mshp_entity_map[entity_key]
mshp_entity.children.append(entity)
entity.parent = mshp_entity
return inv_tag_map
示例7: add_workflow_entity
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def add_workflow_entity(self, version_id):
if version_id not in self.vistrail.actionMap:
return
action = self.vistrail.actionMap[version_id]
tag = None
if self.vistrail.has_tag(version_id):
tag = self.vistrail.get_tag(version_id)
try:
workflow = self.vistrail.getPipeline(version_id)
except:
import traceback
debug.critical("Failed to construct pipeline '%s'" %
(tag if tag else version_id),
traceback.format_exc())
workflow = self.vistrail.getPipeline(0)
if tag:
workflow.name = tag
# if workflow already exists, we want to update it...
# spin through self.children and look for matching
# workflow entity?
# self.children.append(WorkflowEntity(workflow))
self.wf_entity_map[version_id] = \
self.create_workflow_entity(workflow, action)
# get thumbnail
thumbnail = self.vistrail.get_thumbnail(version_id)
if thumbnail is not None:
cache = ThumbnailCache.getInstance()
path = cache.get_abs_name_entry(thumbnail)
if path:
entity = ThumbnailEntity(path)
self.wf_entity_map[action.id].children.append(entity)
entity.parent = self.wf_entity_map[action.id]
return self.wf_entity_map[version_id]
示例8: __init__
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def __init__(self, parent, persistent_config, temp_config):
"""
QThumbnailConfiguration(parent: QWidget,
configuration_object: ConfigurationObject) -> None
"""
QtGui.QWidget.__init__(self, parent)
self._configuration = None
self._temp_configuration = None
self._cache = ThumbnailCache.getInstance()
self.create_widgets()
self.update_state(persistent_config, temp_config)
self.connect_signals()
示例9: load
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def load(self, klass=None):
from vistrails.core.vistrail.vistrail import Vistrail
if klass is None:
klass = Vistrail
save_bundle = _DBLocator.load(self, klass.vtType, ThumbnailCache.getInstance().get_directory())
if klass.vtType == DBWorkflow.vtType:
wf = save_bundle
klass = self.get_convert_klass(wf.vtType)
klass.convert(wf)
wf.locator = self
return wf
for obj in save_bundle.get_db_objs():
klass = self.get_convert_klass(obj.vtType)
klass.convert(obj)
obj.locator = self
return save_bundle
示例10: update
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def update(self, thumbnail):
self.thumbnail = thumbnail
if self.thumbnail is not None:
# store in cache if not already there
cache = ThumbnailCache.getInstance()
cache._copy_thumbnails([thumbnail])
self.name = os.path.basename(thumbnail)
statinfo = os.stat(self.thumbnail)
self.user = statinfo[stat.ST_UID]
self.size = statinfo[stat.ST_SIZE]
time = datetime(*localtime(statinfo[stat.ST_MTIME])[:6])
self.mod_time = time
self.create_time = time
self.description = ""
self.url = "test"
self.was_updated = True
示例11: add_parameter_exploration_entity
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def add_parameter_exploration_entity(self, pe):
if not hasattr(self.vistrail, 'parameter_explorations'):
return
self.pe_entity_map[pe.name] = \
self.create_parameter_exploration_entity(pe)
# get thumbnail for the workflow it points
thumbnail = self.vistrail.get_thumbnail(pe.action_id)
if thumbnail is not None:
cache = ThumbnailCache.getInstance()
path = cache.get_abs_name_entry(thumbnail)
if path:
entity = ThumbnailEntity(path)
pe_entity = self.pe_entity_map[pe.name]
pe_entity.children.append(entity)
entity.parent = self
return self.pe_entity_map[pe.name]
示例12: open_vistrail
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def open_vistrail(self, locator=None, version=None, is_abstraction=False):
if isinstance(locator, basestring):
locator = BaseLocator.from_url(locator)
elif locator is None:
locator = UntitledLocator()
controller = self.ensure_vistrail(locator)
if controller is None:
# vistrail is not already open
try:
loaded_objs = vistrails.core.db.io.load_vistrail(locator, is_abstraction)
controller = self.add_vistrail(loaded_objs[0], locator,
*loaded_objs[1:])
if locator.is_untitled():
return controller
controller.is_abstraction = is_abstraction
thumb_cache = ThumbnailCache.getInstance()
controller.vistrail.thumbnails = controller.find_thumbnails(
tags_only=thumb_cache.conf.tagsOnly)
controller.vistrail.abstractions = controller.find_abstractions(
controller.vistrail, True)
controller.vistrail.mashups = controller._mashups
collection = Collection.getInstance()
url = locator.to_url()
entity = collection.updateVistrail(url, controller.vistrail)
# add to relevant workspace categories
if not controller.is_abstraction:
collection.add_to_workspace(entity)
collection.commit()
except VistrailsDBException as e:
debug.unexpected_exception(e)
debug.critical("Exception from the database: %s" % e,
debug.format_exc())
return None
version = self.convert_version(version)
if version is None:
controller.select_latest_version()
version = controller.current_version
self.select_version(version)
return controller
示例13: updateVersion
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def updateVersion(self, versionNumber):
""" updateVersion(versionNumber: int) -> None
"""
if self.controller:
vistrail = self.controller.vistrail
if versionNumber in vistrail.actionMap.keys():
action = vistrail.actionMap[versionNumber]
if action and vistrail.has_thumbnail(action.id):
cache = ThumbnailCache.getInstance()
fname = cache.get_abs_name_entry(
vistrail.get_thumbnail(action.id))
if fname is not None:
pixmap = QtGui.QPixmap(fname)
self.thumbs.setPixmap(pixmap)
self.thumbs.adjustSize()
self.thumbs.setFrameShape(QtGui.QFrame.StyledPanel)
return
self.thumbs.setPixmap(QtGui.QPixmap())
self.thumbs.setFrameShape(QtGui.QFrame.NoFrame)
示例14: open_vistrail
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
def open_vistrail(self, locator=None, version=None, is_abstraction=False):
if isinstance(locator, basestring):
locator = BaseLocator.from_url(locator)
elif locator is None:
locator = UntitledLocator()
controller = self.ensure_vistrail(locator)
if controller is None:
# vistrail is not already open
try:
loaded_objs = vistrails.core.db.io.load_vistrail(locator, False)
controller = self.add_vistrail(loaded_objs[0], locator,
*loaded_objs[1:])
if locator.is_untitled():
return True
controller.is_abstraction = is_abstraction
thumb_cache = ThumbnailCache.getInstance()
controller.vistrail.thumbnails = controller.find_thumbnails(
tags_only=thumb_cache.conf.tagsOnly)
controller.vistrail.abstractions = controller.find_abstractions(
controller.vistrail, True)
controller.vistrail.mashups = controller._mashups
collection = Collection.getInstance()
url = locator.to_url()
entity = collection.updateVistrail(url, controller.vistrail)
# add to relevant workspace categories
if not controller.is_abstraction:
collection.add_to_workspace(entity)
collection.commit()
except VistrailsDBException, e:
import traceback
debug.critical("Exception from the database",
traceback.format_exc())
return None
except Exception, e:
#debug.critical('An error has occurred', e)
#print "An error has occurred", str(e)
raise
示例15:
# 需要导入模块: from vistrails.core.thumbnails import ThumbnailCache [as 别名]
# 或者: from vistrails.core.thumbnails.ThumbnailCache import getInstance [as 别名]
old_locator = controller.locator
controller.flush_delayed_actions()
try:
controller.write_vistrail(locator, export=export)
except Exception, e:
debug.unexpected_exception(e)
debug.critical("Failed to save vistrail", traceback.format_exc())
raise
if export:
return controller.locator
self.update_locator(old_locator, controller.locator)
# update collection
try:
thumb_cache = ThumbnailCache.getInstance()
controller.vistrail.thumbnails = controller.find_thumbnails(
tags_only=thumb_cache.conf.tagsOnly)
controller.vistrail.abstractions = controller.find_abstractions(
controller.vistrail, True)
controller.vistrail.mashups = controller._mashups
collection = Collection.getInstance()
url = locator.to_url()
entity = collection.updateVistrail(url, controller.vistrail)
# add to relevant workspace categories
collection.add_to_workspace(entity)
collection.commit()
except Exception, e:
debug.critical('Failed to index vistrail', traceback.format_exc())
return controller.locator