本文整理汇总了Python中mforms.Utilities类的典型用法代码示例。如果您正苦于以下问题:Python Utilities类的具体用法?Python Utilities怎么用?Python Utilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utilities类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: do_open_administrator
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
开发者ID:Arrjaan,项目名称:Cliff,代码行数:32,代码来源:wb_admin_grt.py
示例2: create_ui
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
开发者ID:aoyanglee,项目名称:Travel-Inc,代码行数:59,代码来源:wb_admin_config_file_ui.py
示例3: validate_setting
def validate_setting(settings, option, norm_cb, msg):
if settings.has_key(option):
if norm_cb is not None:
norm_cb(settings, option)
else:
if msg is not None:
Utilities.show_warning("WB Administrator", msg, "OK", "", "")
norm_cb(settings, option)
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:8,代码来源:wb_admin_grt.py
示例4: update_refresh_rate
def update_refresh_rate(self):
index = int(self.refresh_selector.get_selected_index())
grt.root.wb.options.options['Administrator:refresh_connections_rate_index'] = index
self.serial += 1
if self._refresh_timeout:
Utilities.cancel_timeout(self._refresh_timeout)
self._refresh_timeout = None
if (index < self.refresh_values_size):
self._refresh_timeout = Utilities.add_timeout(self.refresh_values[index], partial(self.refresh, my_serial = self.serial))
开发者ID:Roguelazer,项目名称:mysql-workbench,代码行数:9,代码来源:wb_admin_connections.py
示例5: GenerateDrupalSchema
def GenerateDrupalSchema(catalog):
output = ''
# Add all schema.
for schema in catalog.schemata :
hook_created = False
comment_replace = {}
# Collect the comment replacement strings.
for table in schema.tables :
comment_replace[(' %s table ' % table.name)] = ' {%s} table ' % table.name
comment_replace[(' %s table.' % table.name)] = ' {%s} table.' % table.name
for column in table.columns :
comment_replace[(' %s.%s ' % (table.name, column.name))] = ' {%s}.%s ' % (table.name, column.name)
comment_replace[(' %s.%s.' % (table.name, column.name))] = ' {%s}.%s.' % (table.name, column.name)
# Add all tables.
for table in schema.tables :
if len(table.columns) > 0 :
if not hook_created :
''' Create the hook '''
if len(output) > 0 :
output += "\n\n"
output += "/**\n"
output += " * Implements hook_schema().\n"
output += " */\n"
output += "function %s_schema() {\n" % re.sub(r'([^a-z0-9_]+|^[^a-z]+)', '', schema.name.lower().replace(' ', '_'))
output += " $schema = array();\n\n"
hook_created = True
''' Add the table '''
output += generateTableDefinition(table, comment_replace)
output += "\n"
if hook_created :
''' Close the hook '''
output += " return $schema;\n"
output += '}'
if len(output) > 0 :
# Should the output be copied to the clipboard?
answer = Utilities.show_message('Copy to clipboard?', "Would you like to copy the schema to your clipboard?\nIt can also be viewed in the output window.", 'Yes', 'No', '')
if answer == mforms.ResultOk :
grt.modules.Workbench.copyToClipboard(output)
# MySQL specific fields warning.
if "'mysql_type' => '" in output :
Utilities.show_message('MySQL specific fields used', 'Note that the schema definition contains MySQL specific fields!', 'OK', '', '')
print output
else :
Utilities.show_warning('No valid tables found', 'The schema was not generated because no valid tables were found.', 'OK', '', '')
return 0
开发者ID:matthijs-va,项目名称:mysql-workbench-drupal-schema-generator,代码行数:56,代码来源:wb_drupal_schema.py
示例6: _sidebar_entry_clicked
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)
开发者ID:alMysql,项目名称:mysql-workbench,代码行数:10,代码来源:wb_admin_grt.py
示例7: _dock_admin_tab
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
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:12,代码来源:wb_admin_grt.py
示例8: start_stop_clicked
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
开发者ID:alMysql,项目名称:mysql-workbench,代码行数:52,代码来源:wb_admin_configuration_startup.py
示例9: _check_server_version
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
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:13,代码来源:wb_admin_grt.py
示例10: get_db_connection
def get_db_connection(server_instance_settings):
if server_instance_settings.connection:
db_connection = MySQLConnection(server_instance_settings.connection)
ignore_error = False
error_location = None
the_error = None
try:
db_connection.connect()
except MySQLError, exc:
# errors that probably just mean the server is down can be ignored (ex 2013)
# errors from incorrect connect parameters should raise an exception
# ex 1045: bad password
if exc.code in (1045,):
raise exc
elif exc.code in (2013,):
ignore_error = True
error_location = exc.location
the_error = str(exc)
if not ignore_error:
if Utilities.show_warning("Could not connect to MySQL Server at %s" % error_location,
"%s\nYou can continue but some functionality may be unavailable." % the_error,
"Continue Anyway", "Cancel", "") != mforms.ResultOk:
raise MySQLError("", 0, "")
return db_connection
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:25,代码来源:wb_admin_utils.py
示例11: handle_on_close
def handle_on_close(self):
log_debug("Closing admin\n")
if self._timeout_tm:
Utilities.cancel_timeout(self._timeout_tm)
self._timeout_tm = None
nc.remove_observer(self.handle_server_state_changed)
App.get().set_status_text("Closing Administator.")
self.shutdown()
if not self.closing:
log_debug("Admin close cancelled\n")
return False
self.ctrl_be.shutdown()
self.release()
self.owner.handle_close()
return True
开发者ID:Roguelazer,项目名称:mysql-workbench,代码行数:16,代码来源:wb_admin_main.py
示例12: async_start_finished
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)
开发者ID:Arrjaan,项目名称:Cliff,代码行数:18,代码来源:wb_admin_configuration_startup.py
示例13: _acquire_admin_access
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
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:18,代码来源:wb_admin_grt.py
示例14: pack_to_top
def pack_to_top(self):
self.suspend_layout()
self.main_view.ui_profile.apply_style(self, 'page')
#if self.server_profile.admin_enabled:
self.file_name_ctrl = newTextEntry()
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.file_name_ctrl.set_size(300, -1)
self.file_name_ctrl.set_read_only(True)
self.section_ctrl = newSelector()
self.section_ctrl.set_size(150, -1)
#spacer = newPanel(mforms.TransparentPanel)
#spacer.set_size(100, 10)
self.bottom_box = newBox(True)
accept_btn = newButton()
accept_btn.set_text("Apply ...")
discard_btn = newButton()
discard_btn.set_text("Discard")
#self.add(self.search_panel, False, True)
self.add(self.tab_view, True, True)
self.add(self.bottom_box, False, False)
self.bottom_box.add(newLabel("Configuration File:"), False, True)
self.bottom_box.add(self.file_name_ctrl, True, True)
self.bottom_box.add(self.section_ctrl, False, True)
Utilities.add_end_ok_cancel_buttons(self.bottom_box, accept_btn, discard_btn)
self.bottom_box.set_spacing(8)
self.bottom_box.set_padding(12)
accept_btn.add_clicked_callback(self.config_apply_changes_clicked)
discard_btn.add_clicked_callback(self.config_discard_changes_clicked)
self.resume_layout()
开发者ID:aoyanglee,项目名称:Travel-Inc,代码行数:44,代码来源:wb_admin_config_file_ui.py
示例15: __init__
def __init__(self, ctrl_be, server_profile, main_view, editor):
mforms.AppView.__init__(self, False, "administrator", False)
self.editor = editor
self.owner = main_view
self.tabs = []
self.name2page = {}
self.config_ui = None
self.closing = False
self.tabview = newTabView(True)
self.ctrl_be = ctrl_be
self.old_active_tab = None
self.server_profile = server_profile
self.refresh_tasks_sleep_time = 2
# if we're in the Mac, we need to set the background color of the main view of the tab to white,
# so that MTabSwitcher will take the cue and set the tab color to white too
if self.server_profile.host_os == wbaOS.darwin:
self.set_back_color("#ffffff")
# Setup self
self.set_managed()
self.set_release_on_add()
self.on_close(wb_admin_utils.weakcb(self, "handle_on_close"))
self.ctrl_be.add_me_for_event("server_started", self)
self.ctrl_be.add_me_for_event("server_stopped", self)
self.add(self.tabview, True, True)
Utilities.add_timeout(0.5, weakcb(self, "timeout"))
self.timeout_thread = threading.Thread(target = self.refresh_tasks_thread)
self.timeout_thread.setDaemon(True)
self.timeout_thread.start()
self.tabview.add_tab_changed_callback(self.tab_changed)
self.timeout() # will call self.connect_mysql() and check if mysql is running
self.ctrl_be.continue_events() # Process events which are queue during init
dprint_ex(1, "WBA init complete")
开发者ID:verflucht,项目名称:unlock_repo_feria,代码行数:41,代码来源:wb_admin_main.py
示例16: async_stop_finished
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()
开发者ID:Roguelazer,项目名称:mysql-workbench,代码行数:23,代码来源:wb_admin_configuration_startup.py
示例17: start_stop_clicked
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
开发者ID:aoyanglee,项目名称:Travel-Inc,代码行数:37,代码来源:wb_admin_configuration_startup.py
示例18: __init__
def __init__(self, ctrl_be, server_profile, main_view, editor):
mforms.AppView.__init__(self, False, "administrator", False)
self.editor = editor
self.owner = main_view
self.tabs = []
self.name2page = {}
self.config_ui = None
self.closing = False
self.tabview = newTabView(True)
self.ctrl_be = ctrl_be
self.old_active_tab = None
self.server_profile = server_profile
# if we're in the Mac, we need to set the background color of the main view of the tab to white,
# so that MTabSwitcher will take the cue and set the tab color to white too
if self.server_profile.host_os == wbaOS.darwin:
self.set_back_color("#ffffff")
# Setup self
self.set_managed()
self.set_release_on_add()
self.on_close(wb_admin_utils.weakcb(self, "handle_on_close"))
nc.add_observer(self.handle_server_state_changed, "GRNServerStateChanged", editor)
self.ctrl_be.add_me_for_event("server_started", self)
self.ctrl_be.add_me_for_event("server_stopped", self)
self.add(self.tabview, True, True)
self._timeout_tm = Utilities.add_timeout(0.5, weakcb(self, "timeout"))
self.tabview.add_tab_changed_callback(self.tab_changed)
self.timeout()
# check initial state
if editor.isConnected == 1:
self.ctrl_be.event_from_main("server_started")
elif editor.isConnected == -1:
self.ctrl_be.event_from_main("server_offline")
self.ctrl_be.continue_events() # Process events which are queue during init
log_debug("WBA init complete\n")
开发者ID:alMysql,项目名称:mysql-workbench,代码行数:44,代码来源:wb_admin_main.py
示例19: openDocLib
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
开发者ID:aoyanglee,项目名称:Travel-Inc,代码行数:46,代码来源:wb_doclib_grt.py
示例20: copy_to_clipboard
def copy_to_clipboard(self):
Utilities.set_clipboard_text(self.startup_msgs_log.get_string_value())
开发者ID:Arrjaan,项目名称:Cliff,代码行数:2,代码来源:wb_admin_configuration_startup.py
注:本文中的mforms.Utilities类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论