Best Python code snippet using tempest_python
wb_admin_configuration.py
Source:wb_admin_configuration.py
...55 section.set_enabled(False)56 section.set_size(150, -1)57 content = None58 panel = None59 if self.ctrl_be.is_admin_available():60 panel = WbAdminConfigurationStartup(server_instance_settings, ctrl_be)61 panel.page_activated()62 panel.set_back_color("#FFFFFF")63 content = panel64 dprint_ex(2, "Added start/stop page")65 else:66 dprint_ex(2, "Failed to add start/stop page.")67 panel = newBox(False)68 panel.set_back_color("#FFFFFF")69 panel.set_padding(10)70 panel.add(no_ssh_warning_label(server_instance_settings), False, True)71 self.add_page(content, panel, "admin_start.png", "admin_start_disabled.png", "Startup", "Start/Stop Server")72 content = None73 panel = newBox(False)74 panel.suspend_layout()75 if self.ctrl_be.is_admin_available():76 spacer = newPanel(mforms.TransparentPanel)77 spacer.set_size(100, 10)78 self.config_ui = WbAdminConfigFileUI(server_instance_settings, file_name, section, ctrl_be)79 panel.add(spacer, False, True)80 panel.add(self.config_ui, True, True)81 bottom_box = newBox(True)82 panel.add(bottom_box, False, False)83 accept_btn = newButton()84 accept_btn.set_text("Apply...")85 #accept_btn.set_size(80, -1)86 discard_btn = newButton()87 discard_btn.set_text("Discard")88 #discard_btn.set_size(80, -1)89 bottom_box.add(newLabel("Configuration File:"), False, True)90 bottom_box.add(file_name, True, True)91 bottom_box.add(section, False, True)92 Utilities.add_end_ok_cancel_buttons(bottom_box, accept_btn, discard_btn)93 bottom_box.set_spacing(8)94 bottom_box.set_padding(12)95 accept_btn.add_clicked_callback(self.config_ui.config_apply_changes_clicked)96 discard_btn.add_clicked_callback(self.config_ui.config_discard_changes_clicked)97 panel.set_back_color("#FFFFFF")98 content = self.config_ui99 else:100 panel = newBox(False)101 panel.set_back_color("#FFFFFF")102 panel.set_padding(10)103 panel.add(no_ssh_warning_label(server_instance_settings), False, True)104 self.add_page(content, panel, "admin_options.png", "admin_options_disabled.png", "Configuration", "Edit Configuration File")105 panel.resume_layout()106 panel = WbAdminSecurity(self.ctrl_be)107 panel.set_back_color("#FFFFFF")108 self.add_page(panel, add_top_spacer(panel), "admin_accounts.png", "admin_accounts_disabled.png", "Accounts", "Manage Users")109 panel = WbAdminConnections(server_instance_settings, self.ctrl_be)110 self.connection_list_panel = panel111 panel.set_back_color("#FFFFFF")112 self.add_page(panel, add_top_spacer(panel), "admin_connections.png", "admin_connections_disabled.png", "Connections", "Edit Connection List")113 panel = WbAdminVariables(self.ctrl_be)114 panel.set_back_color("#FFFFFF")115 self.add_page(panel, add_top_spacer(panel), "admin_variables.png", "admin_variables_disabled.png", "Variables", "Status and Server Vars")116 panel = WbAdminExport(server_instance_settings, self.ctrl_be)117 panel.set_back_color("#FFFFFF")118 self.add_page(panel, add_top_spacer(panel), "admin_dump.png", "admin_dump_disabled.png", "Data Dump", "Export / Import Data")119 panel = WbAdminLogs(server_instance_settings, self.shared_db_connection)120 panel.set_back_color("#FFFFFF")121 self.add_page(panel, add_top_spacer(panel), "admin_logs.png", "admin_logs_disabled.png", "Logs", "Server Log Files")122 Utilities.add_timeout(0.5, weakcb(self, "timeout"))123 self.timeout_thread = threading.Thread(target = self.refresh_tasks)124 self.timeout_thread.setDaemon(True)125 self.timeout_thread.start()126 self.switcher.add_changed_callback(self.tab_changed)127 self.timeout() # will call self.connect_mysql() and check if mysql is running128 # if there's no SSH, try at least to connect to MySQL now, this is handled in start/stop events129 if not self.ctrl_be.is_admin_available():130 self.connect_mysql()131 self.ctrl_be.continue_events() # Process events which are queue during init132 dprint_ex(1, "WBA init complete")133 def connect_mysql(self):134 self.connection_error = None135 try:136 self.shared_db_connection.connect()137 self.connection_error = None138 self.ctrl_be.connect_sql()139 dprint("Created mysql connection")140 except MySQLError, e:141 self.connection_error = str(e)142 # we should not display errors about not being able to connect to MySQL if:143 # 1- error is about not being able to connect (as opposed to bad password or something)...
credentials.py
Source:credentials.py
...38 return accounts.NotLockingAccounts(name=name)39# We want a helper function here to check and see if admin credentials40# are available so we can do a single call from skip_checks if admin41# creds area vailable.42def is_admin_available():43 is_admin = True44 # If tenant isolation is enabled admin will be available45 if CONF.auth.allow_tenant_isolation:46 return is_admin47 # Check whether test accounts file has the admin specified or not48 elif os.path.isfile(CONF.auth.test_accounts_file):49 check_accounts = accounts.Accounts(name='check_admin')50 if not check_accounts.admin_available():51 is_admin = False52 else:53 try:54 cred_provider.get_configured_credentials('identity_admin',55 fill_in=False)56 except exceptions.InvalidConfiguration:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!