本文整理汇总了Python中vistrails.core.configuration.get_vistrails_persistent_configuration函数的典型用法代码示例。如果您正苦于以下问题:Python get_vistrails_persistent_configuration函数的具体用法?Python get_vistrails_persistent_configuration怎么用?Python get_vistrails_persistent_configuration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_vistrails_persistent_configuration函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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())
示例3: clicked_on_login
def clicked_on_login(self):
"""
Attempts to log into web repository
stores auth cookie for session
"""
from vistrails.gui.application import get_vistrails_application
self.dialog.loginUser = self.loginUser.text()
params = urllib.urlencode({'username':self.dialog.loginUser,
'password':self.loginPassword.text()})
self.dialog.cookiejar = cookielib.CookieJar()
# set base url used for cookie
self.dialog.cookie_url = self.config.webRepositoryURL
self.loginOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.dialog.cookiejar))
# FIXME doesn't use https
login_url = "%s/account/login/" % self.config.webRepositoryURL
request = urllib2.Request(login_url, params)
url = self.loginOpener.open(request)
# login failed
if not 'sessionid' in [cookie.name for cookie in self.dialog.cookiejar]:
debug.critical("Incorrect username or password")
self.dialog.cookiejar = None
else: # login successful
self._login_status = "login successful"
self.loginUser.setEnabled(False)
self.loginPassword.setEnabled(False)
self._login_button.setEnabled(False)
self.saveLogin.setEnabled(False)
# add association between VisTrails user and web repository user
if self.saveLogin.checkState():
if not (self.config.check('webRepositoryLogin') and self.config.webRepositoryLogin == self.loginUser.text()):
self.config.webRepositoryLogin = str(self.loginUser.text())
pers_config = get_vistrails_persistent_configuration()
pers_config.webRepositoryLogin = self.config.webRepositoryLogin
get_vistrails_application().save_configuration()
# remove association between VisTrails user and web repository user
else:
if self.config.check('webRepositoryLogin') and self.config.webRepositoryLogin:
self.config.webRepositoryLogin = ""
pers_config = get_vistrails_persistent_configuration()
pers_config.webRepositoryLogin = ""
get_vistrails_application().save_configuration()
self.close_dialog(0)
示例4: __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)
示例5: 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)
示例6: create_thumbs_tab
def create_thumbs_tab(self):
""" create_thumbs_tab() -> QThumbnailConfiguration
"""
return QThumbnailConfiguration(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
示例7: create_general_tab
def create_general_tab(self):
""" create_general_tab() -> QGeneralConfiguration
"""
return QGeneralConfiguration(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
示例8: tab_changed
def tab_changed(self, index):
""" tab_changed(index: int) -> None
Keep general and advanced configurations in sync
"""
# FIXME Need to fix this
self._configuration_tab.configuration_changed(
get_vistrails_persistent_configuration(),
get_vistrails_configuration())
示例9: setUpClass
def setUpClass(cls):
get_vistrails_configuration().jobAutorun = True
get_vistrails_persistent_configuration().jobAutorun = True
QJobView.instance().set_refresh()
cls.filename = (vistrails.core.system.vistrails_root_directory() +
'/tests/resources/jobs.vt')
pm = vistrails.core.packagemanager.get_package_manager()
if pm.has_package('org.vistrails.vistrails.myjobs'):
return
d = {'myjob': 'vistrails.tests.resources.'}
pm.late_enable_package('myjob', d)
示例10: get_load_file_locator_from_gui
def get_load_file_locator_from_gui(parent, obj_type):
suffixes = "*" + " *".join(suffix_map[obj_type])
fileName = QtGui.QFileDialog.getOpenFileName(
parent,
"Open %s..." % obj_type.capitalize(),
vistrails.core.system.vistrails_file_directory(),
"VisTrails files (%s)\nOther files (*)" % suffixes)
if not fileName:
return None
filename = os.path.abspath(str(QtCore.QFile.encodeName(fileName)))
dirName = os.path.dirname(filename)
setattr(get_vistrails_persistent_configuration(), 'fileDirectory', dirName)
setattr(get_vistrails_configuration(), 'fileDirectory', dirName)
vistrails.core.system.set_vistrails_file_directory(dirName)
return FileLocator(filename)
示例11: get_save_file_locator_from_gui
def get_save_file_locator_from_gui(parent, obj_type, locator=None):
# Ignore current locator for now
# In the future, use locator to guide GUI for better starting directory
suffixes = "*" + " *".join(suffix_map[obj_type])
fileName = QtGui.QFileDialog.getSaveFileName(
parent,
"Save Vistrail...",
vistrails.core.system.vistrails_file_directory(),
filter="VisTrails files (%s)" % suffixes, # filetypes.strip()
options=QtGui.QFileDialog.DontConfirmOverwrite)
if not fileName:
return None
f = str(QtCore.QFile.encodeName(fileName))
# check for proper suffix
found_suffix = False
for suffix in suffix_map[obj_type]:
if f.endswith(suffix):
found_suffix = True
break
if not found_suffix:
if obj_type == 'vistrail':
f += get_vistrails_configuration().defaultFileType
else:
f += suffix_map[obj_type][0]
if os.path.isfile(f):
msg = QtGui.QMessageBox(QtGui.QMessageBox.Question,
"VisTrails",
"File exists. Overwrite?",
(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
parent)
if msg.exec_() == QtGui.QMessageBox.No:
return None
dirName = os.path.dirname(f)
setattr(get_vistrails_persistent_configuration(), 'fileDirectory', dirName)
setattr(get_vistrails_configuration(), 'fileDirectory', dirName)
vistrails.core.system.set_vistrails_file_directory(dirName)
return FileLocator(f)
示例12: __init__
def __init__(self):
Module.__init__(self)
config = get_vistrails_persistent_configuration()
if config.check('webRepositoryURL'):
self.base_url = config.webRepositoryURL
else:
raise ModuleError(self,
("No webRepositoryURL value defined"
" in the Expert Configuration"))
# check if we are running in server mode
# this effects how the compute method functions
if config.check('isInServerMode'):
self.is_server = bool(config.isInServerMode)
else:
self.is_server = False
# TODO: this '/' check should probably be done in core/configuration.py
if self.base_url[-1] == '/':
self.base_url = self.base_url[:-1]
示例13: delete_job
def delete_job(self, controller, version_id=None, all=False):
if all:
for k in self.workflowItems.keys():
workflow = self.workflowItems[k]
if workflow.controller is controller:
self.jobView.takeTopLevelItem(
self.jobView.indexOfTopLevelItem(
self.workflowItems[k]))
del self.workflowItems[k]
return
if not version_id:
version_id = controller.current_version
if controller.locator:
conf = configuration.get_vistrails_configuration()
if not conf.has('runningJobsList') or not conf.runningJobsList:
conf_jobs = []
else:
conf_jobs = conf.runningJobsList.split(';')
if not conf_jobs:
conf_jobs = []
url = controller.locator.to_url()
if '?' in url:
url += '&workflow=%s' % version_id
else:
url += '?workflow=%s' % version_id
if url in conf_jobs:
conf_jobs.remove(url)
conf.runningJobsList = ';'.join(conf_jobs)
configuration.get_vistrails_persistent_configuration(
).runningJobsList = conf.runningJobsList
name = controller.vistrail.locator.short_name
else:
name = 'Untitled.vt'
if (name, version_id) in self.workflowItems:
self.jobView.takeTopLevelItem(
self.jobView.indexOfTopLevelItem(
self.workflowItems[(name, version_id)]))
del self.workflowItems[(name, version_id)]
示例14: set_refresh
def set_refresh(self, refresh=0):
"""Changes the timer time.
Called when the QComboBox self.interval changes. Updates the
configuration and restarts the timer.
"""
self.updating_now = True
refresh = str(refresh) if refresh else '0'
if refresh in dict(refresh_states):
refresh = dict(refresh_states)[refresh]
self.interval.setEditText(str(refresh))
else:
refresh = int(refresh)
if refresh:
if self.timer_id is not None:
self.killTimer(self.timer_id)
self.timer_id = self.startTimer(refresh*1000)
else:
if self.timer_id:
self.killTimer(self.timer_id)
self.timer_id = None
get_vistrails_configuration().jobCheckInterval = refresh
get_vistrails_persistent_configuration().jobCheckInterval = refresh
self.updating_now = False
示例15: create_configuration_tab
def create_configuration_tab(self):
return QConfigurationWidget(self,
get_vistrails_persistent_configuration(),
get_vistrails_configuration())