本文整理汇总了Python中vistrails.core.configuration.get_vistrails_configuration函数的典型用法代码示例。如果您正苦于以下问题:Python get_vistrails_configuration函数的具体用法?Python get_vistrails_configuration怎么用?Python get_vistrails_configuration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_vistrails_configuration函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendError
def sendError(self):
data = {}
data['platform'] = platform.uname()[0]
data['platform_version'] = platform.uname()[2]
data['hashed_hostname'] = hashlib.sha1(platform.uname()[1]).hexdigest()
data['hashed_username'] = hashlib.sha1(os.getlogin()).hexdigest()
data['source'] = 'UV-CDAT'
data['source_version'] = '1.2.1'
data['description'] = self.getDescription()
data['stack_trace'] = self.errorDetails.toPlainText()
data['severity'] = 'FATAL'
data['comments'] = self.userComments.toPlainText()
if get_vistrails_configuration().output != '':
fname = get_vistrails_configuration().output
# read at most last 5000 chars from output log
with open(fname, "r") as f:
f.seek (0, 2) # Seek @ EOF
fsize = f.tell() # Get Size
f.seek (max (fsize-5000, 0), 0) # Set pos @ last n chars
data['execution_log'] = f.read()
print urlencode(data)
print "http://uvcdat.llnl.gov/UVCDATUsage/log/add/error/"
result = urlopen("http://uvcdat.llnl.gov/UVCDATUsage/log/add/error/",
urlencode(data))
示例2: py_import
def py_import(module_name, dependency_dictionary, store_in_config=False):
"""Tries to import a python module, installing if necessary.
If the import doesn't succeed, we guess which system we are running on and
install the corresponding package from the dictionary. We then run the
import again.
If the installation fails, we won't try to install that same module again
for the session.
"""
try:
result = _vanilla_import(module_name)
return result
except ImportError:
if not getattr(get_vistrails_configuration(), 'installBundles'):
raise
if module_name in _previously_failed_pkgs:
raise PyImportException("Import of Python module '%s' failed again, "
"not triggering installation" % module_name)
if store_in_config:
ignored_packages_list = getattr(get_vistrails_configuration(),
'bundleDeclinedList',
None)
if ignored_packages_list:
ignored_packages = set(ignored_packages_list.split(';'))
else:
ignored_packages = set()
if module_name in ignored_packages:
raise PyImportException("Import of Python module '%s' failed "
"again, installation disabled by "
"configuration" % module_name)
debug.warning("Import of python module '%s' failed. "
"Will try to install bundle." % module_name)
success = vistrails.core.bundles.installbundle.install(
dependency_dictionary)
if store_in_config:
if bool(success):
ignored_packages.discard(module_name)
else:
ignored_packages.add(module_name)
setattr(get_vistrails_configuration(),
'bundleDeclinedList',
';'.join(sorted(ignored_packages)))
setattr(get_vistrails_persistent_configuration(),
'bundleDeclinedList',
';'.join(sorted(ignored_packages)))
if not success:
_previously_failed_pkgs.add(module_name)
raise PyImportException("Installation of Python module '%s' failed." %
module_name)
try:
result = _vanilla_import(module_name)
return result
except ImportError, e:
_previously_failed_pkgs.add(module_name)
raise PyImportBug("Installation of package '%s' succeeded, but import "
"still fails." % module_name)
示例3: __init__
def __init__(self):
d = {"prefix": "vt_tmp"}
if get_vistrails_configuration().check("temporaryDirectory"):
dir = get_vistrails_configuration().temporaryDirectory
if os.path.exists(dir):
d["dir"] = dir
else:
debug.critical("Temporary directory does not exist: %s" % dir)
self.directory = tempfile.mkdtemp(**d)
self.files = {}
示例4: __init__
def __init__(self):
d = {'prefix':'vt_tmp'}
if get_vistrails_configuration().check('temporaryDir'):
dir = get_vistrails_configuration().temporaryDir
if os.path.exists(dir):
d['dir'] = dir
else:
debug.critical("Temporary directory does not exist: %s" % dir)
self.directory = tempfile.mkdtemp(**d)
self.files = {}
示例5: tab_changed
def tab_changed(self, index):
""" tab_changed(index: int) -> None
Keep general and advanced configurations in sync
"""
self._configuration_tab.configuration_changed(
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
self._general_tab.update_state(
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
示例6: __init__
def __init__(self, parent):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle('VisTrails Preferences')
layout = QtGui.QHBoxLayout(self)
layout.setMargin(0)
layout.setSpacing(0)
self.setLayout(layout)
f = QtGui.QFrame()
layout.addWidget(f)
l = QtGui.QVBoxLayout(f)
f.setLayout(l)
self._tab_widget = QtGui.QTabWidget(f)
l.addWidget(self._tab_widget)
self._tab_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
tabs = [("General", ["General", "Packages"]),
("Interface", ["Interface", "Startup"]),
("Paths && URLs", ["Paths", "Web Sharing"]),
("Advanced", ["Upgrades", "Thumbnails", "Advanced"]),
]
for (tab_name, categories) in tabs:
tab = QConfigurationPane(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration(),
[(c, base_config[c]) for c in categories])
self._tab_widget.addTab(tab, tab_name)
output_tab = QOutputConfigurationPane(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
self._tab_widget.addTab(output_tab, "Output")
self._packages_tab = self.create_packages_tab()
self._tab_widget.addTab(self._packages_tab, 'Packages')
self._configuration_tab = self.create_configuration_tab()
self._tab_widget.addTab(self._configuration_tab, 'Expert')
self.connect(self._tab_widget,
QtCore.SIGNAL('currentChanged(int)'),
self.tab_changed)
self.connect(self._configuration_tab._tree.treeWidget,
QtCore.SIGNAL('configuration_changed'),
self.configuration_changed)
示例7: compute
def compute(self):
vt_configuration = get_vistrails_configuration()
if not getattr(vt_configuration, 'interactiveMode', False):
self.set_output('result', True)
return
cell = self.get_input('cell')
label = self.force_get_input('label', None)
# FIXME : This should be done via the spreadsheet, removing it properly
# and then sending a new DisplayCellEvent
# However, there is currently no facility to remove the widget from
# wherever it is
oldparent = cell.parent()
assert isinstance(oldparent, QCellContainer)
ncell = oldparent.takeWidget()
assert ncell == cell
dialog = PromptWindow(cell, label)
result = dialog.exec_() == QtGui.QDialog.Accepted
oldparent.setWidget(cell)
self.set_output('result', result)
if not result and not self.get_input('carry_on'):
raise ModuleError(self, "Execution aborted")
示例8: write
def write(self, s):
"""write(s) -> None
adds the string s to the message list and displays it
"""
# adds the string s to the list and
s = s.strip()
msgs = s.split("\n")
if len(msgs) <= 3:
msgs.append("Error logging message: invalid log format")
s += "\n" + msgs[3]
if not len(msgs[3].strip()):
msgs[3] = "Unknown Error"
s = "\n".join(msgs)
text = msgs[3]
item = QtGui.QListWidgetItem(text)
item.setData(32, s)
item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
self.list.addItem(item)
item.setForeground(CurrentTheme.DEBUG_COLORS[msgs[0]])
self.list.setItemHidden(item, not self.levels[msgs[0]].isChecked())
alwaysShowDebugPopup = getattr(get_vistrails_configuration(), "alwaysShowDebugPopup", False)
if msgs[0] == "CRITICAL":
if self.isVisible() and not alwaysShowDebugPopup:
self.raise_()
self.activateWindow()
modal = get_vistrails_application().activeModalWidget()
if modal:
# need to beat modal window
self.showMessageBox(item)
else:
self.showMessageBox(item)
示例9: addButtonsToToolbar
def addButtonsToToolbar(self):
# button for toggling executions
eye_open_icon = \
QtGui.QIcon(os.path.join(vistrails_root_directory(),
'gui/resources/images/eye.png'))
self.portVisibilityAction = QtGui.QAction(eye_open_icon,
"Show/hide port visibility toggle buttons",
None,
triggered=self.showPortVisibility)
self.portVisibilityAction.setCheckable(True)
self.portVisibilityAction.setChecked(True)
self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
self.portVisibilityAction)
self.showTypesAction = QtGui.QAction(letterIcon('T'),
"Show/hide type information",
None,
triggered=self.showTypes)
self.showTypesAction.setCheckable(True)
self.showTypesAction.setChecked(True)
self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
self.showTypesAction)
self.showEditsAction = QtGui.QAction(
QtGui.QIcon(os.path.join(vistrails_root_directory(),
'gui/resources/images/pencil.png')),
"Show/hide parameter widgets",
None,
triggered=self.showEdits)
self.showEditsAction.setCheckable(True)
self.showEditsAction.setChecked(
get_vistrails_configuration().check('showInlineParameterWidgets'))
self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
self.showEditsAction)
示例10: load_running_jobs
def load_running_jobs(self):
conf = configuration.get_vistrails_configuration()
if conf.has('runningJobsList') and conf.runningJobsList:
for url in conf.runningJobsList.split(';'):
loc, version = url.split('?')
locator = BaseLocator.from_url(loc)
msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Question,
"Running Job Found",
"Running Job Found:\n %s\n"
"Continue now?" % url)
msgBox.addButton("Later", msgBox.ActionRole)
delete = msgBox.addButton("Delete", msgBox.ActionRole)
yes = msgBox.addButton("Yes", msgBox.ActionRole)
msgBox.exec_()
if msgBox.clickedButton() == yes:
from vistrails.gui.vistrails_window import _app
_app.open_vistrail_without_prompt(locator,
int(version.split('=')[1]))
_app.get_current_view().execute()
if msgBox.clickedButton() == delete:
conf_jobs = conf.runningJobsList.split(';')
conf_jobs.remove(url)
conf.runningJobsList = ';'.join(conf_jobs)
configuration.get_vistrails_persistent_configuration(
).runningJobsList = conf.runningJobsList
else:
conf.runningJobsList = ''
configuration.get_vistrails_persistent_configuration(
).runningJobsList = conf.runningJobsList
示例11: create_thumbs_tab
def create_thumbs_tab(self):
""" create_thumbs_tab() -> QThumbnailConfiguration
"""
return QThumbnailConfiguration(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
示例12: create_general_tab
def create_general_tab(self):
""" create_general_tab() -> QGeneralConfiguration
"""
return QGeneralConfiguration(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
示例13: getResultEntity
def getResultEntity(self, controller, versions_to_check):
from vistrails.core.collection.vistrail import VistrailEntity
vistrail_entity = None
for version in versions_to_check:
if version in controller.vistrail.actionMap:
action = controller.vistrail.actionMap[version]
if getattr(get_vistrails_configuration(), 'hideUpgrades',
True):
# Use upgraded version to match
action = controller.vistrail.actionMap[
controller.vistrail.get_upgrade(action.id, False)]
if self.match(controller, action):
# have a match, get vistrail entity
if vistrail_entity is None:
vistrail_entity = VistrailEntity()
# don't want to add all workflows, executions
vistrail_entity.set_vistrail(controller.vistrail)
# only tagged versions should be displayed in the workspace
tagged_version = controller.get_tagged_version(version)
vistrail_entity.add_workflow_entity(tagged_version)
# FIXME this is not done at the low level but in
# Collection class, probably should be reworked
vistrail_entity.wf_entity_map[tagged_version].parent = \
vistrail_entity
return vistrail_entity
示例14: checkJob
def checkJob(self, module, id, monitor):
""" checkJob(module: VistrailsModule, id: str, monitor: instance) -> None
Starts monitoring the job for the current running workflow
module - the module to suspend
id - the job identifier
monitor - a class instance with a finished method for
checking if the job has completed
"""
if not self.currentWorkflow():
if not monitor or not self.isDone(monitor):
raise ModuleSuspended(module, 'Job is running', queue=monitor,
job_id=id)
job = self.getJob(id)
if self.callback:
self.callback.checkJob(module, id, monitor)
return
conf = get_vistrails_configuration()
interval = conf.jobCheckInterval
if interval and not conf.jobAutorun:
if monitor:
# wait for module to complete
try:
while not self.isDone(monitor):
time.sleep(interval)
print ("Waiting for job: %s,"
"press Ctrl+C to suspend") % job.name
except KeyboardInterrupt, e:
raise ModuleSuspended(module, 'Interrupted by user, job'
' is still running', queue=monitor,
job_id=id)
示例15: current_dot_vistrails
def current_dot_vistrails():
""" current_dot_vistrails() -> str
Returns the VisTrails per-user directory.
"""
from vistrails.core.configuration import get_vistrails_configuration
return get_vistrails_configuration().dotVistrails