本文整理汇总了Python中mforms.Utilities.show_error方法的典型用法代码示例。如果您正苦于以下问题:Python Utilities.show_error方法的具体用法?Python Utilities.show_error怎么用?Python Utilities.show_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mforms.Utilities
的用法示例。
在下文中一共展示了Utilities.show_error方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_open_administrator
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def do_open_administrator(server_instance):
validate_setting(
server_instance.serverInfo, "sys.usesudo", norm_to_switch, None
) # "Server profile has no indication of sudo usage")
validate_setting(server_instance.serverInfo, "sys.usesudostatus", norm_to_switch, None)
if server_instance.serverInfo["sys.system"] != "Windows":
# validate_setting(server_instance.serverInfo, "sys.sudo", make_str_existing, "Server profile has no privileges elevation command defined")
# if server_instance.serverInfo.has_key("sys.sudo") and server_instance.serverInfo["sys.sudo"].strip(" \r\t\n") == "":
# Utilities.show_warning("WB Administrator", "Server profile has empty privileges elevation command defined. Some functionality maybe unavailable", "OK", "", "")
try:
if not server_instance.serverInfo["sys.sudo"]:
# don't break settings that were working perfectly before, assume a valid default
server_instance.serverInfo["sys.sudo"] = "/usr/bin/sudo -p EnterPasswordHere /bin/bash -c"
except:
server_instance.serverInfo["sys.sudo"] = "/usr/bin/sudo -p EnterPasswordHere /bin/bash -c"
app = App.get()
try:
adminTab = AdministratorTab(server_instance)
except wb_admin_ssh.ConnectionError, exc:
Utilities.show_error(
"Error Connecting to Server (%[email protected]%s)"
% (server_instance.loginInfo["ssh.userName"], server_instance.loginInfo["ssh.hostName"]),
str(exc),
"OK",
"",
"",
)
app.set_status_text("Could not Open WB Admin")
return None
示例2: create_ui
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def create_ui(self):
self.loading = True
self.cfg_be = wb_admin_config_file_be.WbAdminConfigFileBE(self.server_profile, self.ctrl_be)
sys_config_path = self.server_profile.config_file_path
if sys_config_path is None:
sys_config_path = ""
self.file_name_ctrl.set_value(sys_config_path)
self.section_ctrl.add_changed_callback(self.clear_and_load)
try:
self.myopts = self.cfg_be.get_possible_options()
option_stats = self.cfg_be.get_option_set_stats()
dprint_ex(1, "Options stats: '%s'" % str(option_stats))
if option_stats and type(option_stats) is dict:
added = option_stats.get("added", None)
if added is not None and added < 10:
user_selected_version = run_version_select_form(option_stats["version"])
self.server_profile.set_server_version(".".join(map(lambda x: str(x), user_selected_version)))
self.cfg_be.reload_possible_options()
self.myopts = self.cfg_be.get_possible_options()
option_stats = self.cfg_be.get_option_set_stats()
dprint_ex(1, "Options stats after version correction: '%s'" % str(option_stats))
except KeyError:
Utilities.show_error("Error", "Wrong version '" + self.version + "'given to admin plugin", "Close", None, None)
self.load_options_from_cfg()
#build ordered list of pages. Initially only skeleton pages are created, means only names.
# Values into pages will be load as soon as page is switched to.
self.pages = {}
for page_name, page_content in self.myopts.iteritems():
self.pages[int(page_content['position'])] = Page(page_name, page_content) # False means page not created
# page key is its position in UI. As we can have pages positions set like (1,2,4,5)
# the position set needs to be sorted so pages appear in specified order
page_positions = self.pages.keys()
page_positions.sort()
# Create dummy pages according to assigned position
for page_pos in page_positions:
page = self.pages[page_pos]
page.panel = newScrollPanel(mforms.ScrollPanelNoFlags)
self.tab_view.add_page(page.panel, page.page_name)
if debug_level > 0:
# Create file page
page = Page("File", None)
page.panel = newTextBox(mforms.BothScrollBars)
page.set_update_cb(self.update_file_content_tab)
self.pages[max(self.pages.keys()) + 1] = page
self.tab_view.add_page(page.panel, page.page_name)
# Create first page, so we display something from start
self.create_page(1)
self.loading = True # create_page resets loading flag
self.tab_view.add_tab_changed_callback(self.tab_changed)
self.loading = False
示例3: _sidebar_entry_clicked
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def _sidebar_entry_clicked(self, entry_id):
if entry_id == "configure":
openConnectionSettings(self.editor)
else:
if entry_id in self.disabled_pages:
Utilities.show_error(self.page_titles[entry_id],
self.disabled_pages[entry_id],
"OK", "", "")
return
self.open_into_section(entry_id)
示例4: _dock_admin_tab
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def _dock_admin_tab(self):
app = mforms.App.get()
try:
self.ctrl_be = wb_admin_control.WbAdminControl(self.server_profile, connect_sql=True)
self.ctrl_be.init()
self.admin_tab = wb_admin_main.AdministratorTab(self.ctrl_be, self.server_profile, self, self.editor)
except MySQLError, exc:
if exc.message:
Utilities.show_error("Error Connecting to MySQL Server (%s)" % exc.location, str(exc), "OK", "", "")
app.set_status_text("Could not Open WB Admin")
return None
示例5: start_stop_clicked
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def start_stop_clicked(self):
try:
self.start_error_log_tracking()
except OperationCancelledError:
# we could abort everything if we knew that start/stop server also needs sudo password
# to avoid user having to cancel that twice, but since we're not sure if the start/stop will
# indeed require the sudo password, we can't give up yet
pass
status = self.ctrl_be.is_server_running(verbose=1)
# Check if server was started/stoped from outside
if self.is_server_running_prev_check == status:
if status == "running" or status == "offline":
if status == "offline":
self.print_output("Server is in offline mode.")
self.start_stop_btn.set_enabled(False)
self.refresh_button.set_enabled(False)
try:
if self.server_control and not self.server_control.stop_async(self.async_stop_callback, True):
if self.ctrl_be.target_version and self.ctrl_be.target_version.is_supported_mysql_version_at_least(5, 7, 5):
self.offline_mode_btn.show(True)
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
return
except Exception, exc:
if self.ctrl_be.target_version and self.ctrl_be.target_version.is_supported_mysql_version_at_least(5, 7, 5):
self.offline_mode_btn.show(True)
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
Utilities.show_error("Stop Server",
"An error occurred while attempting to stop the server.%s %s\n" % (type(exc).__name__, exc),
"OK", "", "")
return
elif status == "stopped":
self.start_stop_btn.set_enabled(False)
self.refresh_button.set_enabled(False)
self.offline_mode_btn.set_enabled(False)
try:
if self.server_control and not self.server_control.start_async(self.async_start_callback, True):
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
return
except Exception, exc:
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
Utilities.show_error("Stop Server",
"An error occurred while attempting to stop the server.%s %s\n" % (type(exc).__name__, exc),
"OK", "", "")
return
示例6: _check_server_version
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def _check_server_version(self):
version = self.ctrl_be.get_server_version()
if type(version) is tuple:
valid_versions = ((4,0), (4,1), (5,0), (5,1), (5,2), (5,4), (5,5), (5,6), (5, 7))
if version[:2] not in valid_versions:
log_warning(_this_file, "%s: Server version %s is NOT supported\n" % (self.__class__.__name__, str(version)) )
Utilities.show_error("Unsupported Server Version", "The version of the server you're trying to connect to is %i.%i, which is not supported by Workbench."%version[:2],
"Close", "Ignore", "")
return False
else:
log_info(_this_file, "%s: Server version %s is supported\n" % (self.__class__.__name__, str(version)) )
return True
return None
示例7: openDocLib
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def openDocLib():
global docLibTab
global server_port
if docLibTab:
if docLibTab is True: # this will be True if an external browser is used
Utilities.open_url("http://localhost:%i"%server_port)
return 1
App.get().select_view("wb.doclib")
return 1
app = App.get()
try:
import mysqldoclib
except ImportError:
Utilities.show_error("Cannot Open Documentation Library",
'''pysqlite2 is not installed, please install python-sqlite2 or pysqlite2 to be able to use this feature.
Try running "easy_install pysqlite" with superuser privileges in the command line shell or, if using
Ubuntu, enable the Universe repository and install the python-pysqlite2 package from there.''',
"OK", "", "")
return 0
if server_port is None:
ready_event = Event()
#datadir = "./modules/data/DocLibrary/"
datadir = os.path.join(app.get_resource_path(""), "modules/data/DocLibrary")
thread.start_new_thread(run_server, (datadir, ready_event))
# wait up to 1s for the doclib server to start
ready_event.wait(1)
if platform.system() == "Linux":
docLibTab = True
Utilities.open_url("http://localhost:%i"%server_port)
return 1
docLibTab = DocLibTab(server_port)
docLibTab.set_identifier("wb.doclib")
app.dock_view(docLibTab, "maintab")
app.set_view_title(docLibTab, "Doc Library (loading)")
app.set_status_text("Opening Doc Library...")
return 1
示例8: async_start_finished
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def async_start_finished(self, status):
if status == "success":
self.print_output("Server start done.")
elif status == "bad_password":
r = Utilities.show_error("Start Server",
"A permission error occurred while attempting to start the server.\n"
"Administrator password was possibly wrong.",
"Retry", "Cancel", "")
if r == mforms.ResultOk:
pass
else:
self.print_output("Could not stop server. Permission denied")
else:
self.print_output("Could not start server: %s" % (status or "unknown error"))
Utilities.show_error("Could not start server", str(status), "OK", "", "")
self.refresh()
self.refresh_button.set_enabled(True)
self.start_stop_btn.set_enabled(True)
示例9: _acquire_admin_access
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def _acquire_admin_access(self):
if not self._validate_remote_admin_settings():
self.admin_access_status = "Remote management settings are invalid"
return
while True:
try:
mforms.App.get().set_status_text("Acquiring management access to target host...")
self.ctrl_be.acquire_admin_access()
mforms.App.get().set_status_text("Management support for target host enabled successfully.")
return True
except wb_admin_ssh.ConnectionError, exc:
self.admin_access_status = "Remote management capabilities are currently unavailable.\nSSH connection could not be established\n\n%s" % str(exc)
Utilities.show_error("Error opening SSH connection to server (%[email protected]%s)" % (self.instance_profile.loginInfo["ssh.userName"], self.instance_profile.loginInfo["ssh.hostName"]), str(exc), "OK", "", "")
return None
except OperationCancelledError, exc:
self.admin_access_status = "Remote management capabilities are currently unavailable.\nSSH connection was cancelled"
mforms.App.get().set_status_text("Cancelled SSH connection (%s)"%exc)
return None
示例10: async_stop_finished
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def async_stop_finished(self, status): # status can be one of success, bad_password or error message
if status == "success":
self.print_output("Server stop done.")
elif status == "bad_password":
r = Utilities.show_error("Stop Server",
"A permission error occurred while attempting to stop the server.\n"
"Administrator password was possibly wrong.",
"Retry", "Cancel", "")
if r == mforms.ResultOk:
if self.server_control.stop_async(self.async_stop_callback):
return
else:
self.print_output("Could not stop server. Permission denied")
elif status == "need_password":
if self.server_control.stop_async(self.async_stop_callback, False):
return
else:
self.print_output("Could not stop server: %s" % (status or "unknown error"))
Utilities.show_error("Could not stop server", str(status), "OK", "", "")
self.refresh()
self.refresh_button.set_enabled(True)
self.start_stop_btn.set_enabled(True)
self.print_new_error_log_entries()
示例11: start_stop_clicked
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
def start_stop_clicked(self):
self.start_error_log_tracking()
status = self.ctrl_be.is_server_running(verbose=1)
# Check if server was started/stoped from outside
if self.is_server_running_prev_check == status:
if status == "running":
self.start_stop_btn.set_enabled(False)
self.refresh_button.set_enabled(False)
try:
if self.server_control and not self.server_control.stop_async(self.async_stop_callback):
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
return
except Exception, exc:
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
Utilities.show_error("Stop Server",
"An error occurred while attempting to stop the server.%s %s\n" % (type(exc).__name__, exc),
"OK", "", "")
return
elif status == "stopped":
self.start_stop_btn.set_enabled(False)
self.refresh_button.set_enabled(False)
try:
if self.server_control and not self.server_control.start_async(self.async_start_callback):
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
return
except Exception, exc:
self.start_stop_btn.set_enabled(True)
self.refresh_button.set_enabled(True)
Utilities.show_error("Stop Server",
"An error occurred while attempting to stop the server.%s %s\n" % (type(exc).__name__, exc),
"OK", "", "")
return
示例12: connection
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
except OperationCancelledError, exc:
self.admin_access_status = "Remote management capabilities are currently unavailable.\nSSH connection was cancelled"
mforms.App.get().set_status_text("Cancelled SSH connection (%s)"%exc)
return None
except InvalidPasswordError, exc:
self.admin_access_status = "Remote management capabilities are currently unavailable.\nCould not acquire management access to the server\n\n%s" % exc
if Utilities.show_error("Could not acquire management access for administration", "%s" % exc, "Retry", "Cancel", "") == mforms.ResultOk:
continue
mforms.App.get().set_status_text("Could not Open WB Admin")
return None
except Exception, exc:
import traceback
traceback.print_exc()
self.admin_access_status = "Remote management capabilities are currently unavailable.\nCould not acquire management access to the server\n\n%s" % exc
mforms.App.get().set_status_text("Could not Open WB Admin")
if Utilities.show_error("Could not acquire management access for administration", "%s: %s" % (type(exc).__name__, exc), "Settings...", "Cancel", "") == mforms.ResultOk:
grt.modules.Workbench.showInstanceManagerFor(self.connection)
return None
def acquire_admin_access(self, ignore_failure=False):
if not self._acquire_admin_access():
if ignore_failure:
return True
if not self.error_box:
self.error_box = mforms.newBox(True)
self.error_box.set_padding(50)
error_label = mforms.newLabel(self.admin_access_status)
error_label.set_style(mforms.BigBoldStyle)
self.error_box.add(error_label, False, True)
self.admin_tab.add_page(self.error_box)
else:
示例13: AdministratorTab
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_error [as 别名]
try:
adminTab = AdministratorTab(server_instance)
except wb_admin_ssh.ConnectionError, exc:
Utilities.show_error(
"Error Connecting to Server (%[email protected]%s)"
% (server_instance.loginInfo["ssh.userName"], server_instance.loginInfo["ssh.hostName"]),
str(exc),
"OK",
"",
"",
)
app.set_status_text("Could not Open WB Admin")
return None
except MySQLError, exc:
if exc.message:
Utilities.show_error("Error Connecting to MySQL Server (%s)" % exc.location, str(exc), "OK", "", "")
app.set_status_text("Could not Open WB Admin")
return None
except OperationCancelledError, exc:
app.set_status_text("Cancelled (%s)" % exc)
return None
except Exception, exc:
import traceback
traceback.print_exc()
Utilities.show_error(
"Error Starting Workbench Administrator", "%s: %s" % (type(exc).__name__, exc), "OK", "", ""
)
app.set_status_text("Could not Open WB Admin")
return None