本文整理汇总了Python中util.Util.msg_log方法的典型用法代码示例。如果您正苦于以下问题:Python Util.msg_log方法的具体用法?Python Util.msg_log怎么用?Python Util.msg_log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.msg_log方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CKANBrowserDialogSettings
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import msg_log [as 别名]
class CKANBrowserDialogSettings(QtGui.QDialog, FORM_CLASS):
def __init__(self, settings, iface, parent=None):
"""Constructor."""
super(CKANBrowserDialogSettings, self).__init__(parent)
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
self.iface = iface
self.main_win = parent
self.settings = settings
self.util = Util(self.settings, self.main_win)
self.IDC_leCacheDir.setText(self.settings.cache_dir)
self.IDC_leCkanApi.setText(self.settings.ckan_url)
if QgsAuthConfigSelect is None:
self.IDC_leAuthCfg.hide()
self.IDC_bAuthCfgClear.hide()
self.IDC_bAuthCfgEdit.hide()
self.IDC_lblAuthCfg.hide()
self.IDC_cbAuthPropagate.hide()
else:
if self.settings.authcfg:
self.IDC_leAuthCfg.setText(self.settings.authcfg)
self.IDC_cbAuthPropagate.setChecked(self.settings.auth_propagate)
else:
self.IDC_cbAuthPropagate.setChecked(False)
self.cc = CkanConnector(self.settings, self.util)
self.pre_ckan_apis = None
self.fill_combobox();
def fill_combobox(self):
""" Fill Combobox with predefined CKAN API Urls """
try:
json_path = self.util.resolve(u'CKAN_APIs.json')
with open(json_path) as json_file:
self.pre_ckan_apis = json.load(json_file, object_pairs_hook=OrderedDict)
for key in self.pre_ckan_apis.keys():
self.IDC_cbPreCkanApi.addItem(key)
value = self.pre_ckan_apis.itervalues().next()
self.IDC_lblPreCkan.setText(value)
except IOError as err:
self.util.dlg_warning(self.util.tr(u"py_dlg_set_warn_urls_not_load").format(err))
def select_cache_dir(self):
cache_dir = QFileDialog.getExistingDirectory(
self.main_win,
self.settings.DLG_CAPTION,
self.settings.cache_dir,
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks
)
if '' == cache_dir:
self.util.msg_log('no cachedir selected')
else:
self.IDC_leCacheDir.setText(cache_dir)
def test_ckan_url(self):
""" Test if URL in LineEdit is a valid CKAN API URL """
api_url = self.IDC_leCkanApi.text()
self.util.msg_log('URL: {0}'.format(api_url))
QApplication.setOverrideCursor(Qt.WaitCursor)
ok, result = self.cc.test_groups(api_url)
QApplication.restoreOverrideCursor()
if ok is False:
self.util.dlg_warning(result)
return
else:
self.util.dlg_information(self.util.tr(u'py_dlg_set_info_conn_succs'))
# for entry in result:
# self.util.msg_log('Item: {0}'.format(entry))
def pre_ckan_api(self):
"""select CKAN API from predefined file"""
try:
key = self.IDC_cbPreCkanApi.currentText()
value = self.pre_ckan_apis[key]
self.IDC_lblPreCkan.setText(value)
except TypeError as err:
self.util.msg_log('Error: No items in Preselected-Combo-Box: {0}'.format(err))
pass
def choose_pre_api(self):
value = self.IDC_lblPreCkan.text()
self.IDC_leCkanApi.setText(value)
def cancel(self):
#.........这里部分代码省略.........
示例2: CKANBrowserDialog
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import msg_log [as 别名]
class CKANBrowserDialog(QtGui.QDialog, FORM_CLASS):
def __init__(self, settings, iface, parent=None):
"""Constructor."""
super(CKANBrowserDialog, self).__init__(parent)
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
self.iface = iface
self.main_win = parent
self.search_txt = ''
self.cur_package = None
self.result_count = 0
self.current_page = 1
self.page_count = 0
self.current_group = None
# TODO:
# * create settings dialog
# * read SETTINGS
self.settings = settings
self.util = Util(self.settings, self.main_win)
self.IDC_lblApiUrl.setText(self.util.tr('py_dlg_base_server') + self.settings.ckan_url)
self.IDC_lblCacheDir.setText(self.util.tr('py_dlg_base_cache_path') + self.settings.cache_dir)
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# TODO: automatically populate version
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111
self.IDC_lblVersion.setText(self.util.tr('py_dlg_base_version').format(self.settings.version))
self.IDC_lblSuchergebnisse.setText(self.util.tr('py_dlg_base_search_result'))
self.IDC_lblPage.setText(self.util.tr('py_dlg_base_page_1_1'))
icon_path = self.util.resolve(u'icon-copy.png')
self.IDC_bCopy.setIcon(QtGui.QIcon(icon_path))
self.cc = CkanConnector(self.settings, self.util)
self.timer = QTimer()
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.window_loaded)
QApplication.setOverrideCursor(Qt.WaitCursor)
def showEvent(self, event):
self.util.msg_log('showevent')
QDialog.showEvent(self, event)
if self.timer is not None:
self.timer.start(500)
self.util.msg_log('showevent finished')
def window_loaded(self):
try:
self.util.msg_log('window_loaded')
self.util.msg_log('before stop')
self.timer.stop()
self.timer = None
self.util.msg_log('before get_groupds')
ok, result = self.cc.get_groups()
if ok is False:
QApplication.restoreOverrideCursor()
self.util.dlg_warning(result)
return
if not result:
self.list_all_clicked()
else:
for entry in result:
item = QListWidgetItem(entry['display_name'])
item.setData(Qt.UserRole, entry)
#item.setCheckState(Qt.Checked)
item.setCheckState(Qt.Unchecked)
self.IDC_listGroup.addItem(item)
finally:
QApplication.restoreOverrideCursor()
def close_dlg(self):
QDialog.reject(self)
def show_disclaimer(self):
self.dlg_disclaimer = CKANBrowserDialogDisclaimer(self.settings)
self.dlg_disclaimer.show()
def searchtextchanged(self, search_txt):
self.search_txt = search_txt
def suchen(self):
self.current_page = 1
self.current_group = None
self.__search_package()
def list_all_clicked(self):
self.current_page = 1
self.current_group = None
# don't hint on wildcards, empty text works as well, as CKAN uses *:* as
# default when ?q= has not text
# self.IDC_lineSearch.setText('*:*')
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import msg_log [as 别名]
#.........这里部分代码省略.........
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if add_to_toolbar:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToMenu(
self.menu,
action)
self.actions.append(action)
return action
def initGui(self):
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
icon_path = ':/plugins/CKANBrowser/icon.png'
self.add_action(
icon_path,
text=self.util.tr(u'Open Data (CKAN) Browser'),
callback=self.run,
parent=self.iface.mainWindow()
)
icon_settings = ':/plugins/CKANBrowser/icon-settings.png'
self.add_action(
icon_settings,
text=self.util.tr(u'ckan_browser_settings'),
callback=self.open_settings,
parent=self.iface.mainWindow()
)
def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions:
self.iface.removePluginMenu(
self.util.tr(u'&Open Data (CKAN) Browser'),
action)
self.iface.removeToolBarIcon(action)
def run(self):
"""Run method that performs all the real work"""
is_open = QSettings().value("ckan_browser/isopen", False)
#Python treats almost everything as True````
#is_open = bool(is_open)
self.util.msg_log(u'isopen: {0}'.format(is_open))
#!!!string comparison - Windows and Linux treat it as string, Mac as bool
# so we convert string to bool
if isinstance(is_open, basestring):
is_open = self.util.str2bool(is_open)
if is_open:
self.util.msg_log(u'Dialog already opened')
return
# auf URL testen
dir_check = self.util.check_dir(self.settings.cache_dir)
api_url_check = self.util.check_api_url(self.settings.ckan_url)
if dir_check is False or api_url_check is False:
dlg = CKANBrowserDialogSettings(self.settings, self.iface, self.iface.mainWindow())
dlg.show()
result = dlg.exec_()
if result != 1:
return
# self.util.msg_log('cache_dir: {0}'.format(self.settings.cache_dir))
try:
QSettings().setValue("ckan_browser/isopen", True)
self.dlg = CKANBrowserDialog(self.settings, self.iface, self.iface.mainWindow())
# show the dialog
self.dlg.show()
#self.dlg.open()
# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
if result:
# Do something useful here - delete the line containing pass and
# substitute with your code.
pass
finally:
QSettings().setValue("ckan_browser/isopen", False)
def open_settings(self):
dlg = CKANBrowserDialogSettings(self.settings, self.iface, self.iface.mainWindow())
dlg.show()
dlg.exec_()