@Qc@sddlZddlZddlZddlmZmZmZmZmZm Z m Z m Z m Z ddlm Z mZmZmZmZmZddlmZmZmZmZmZmZddlmZmZmZmZddlZddlZddlmZm Z m!Z!m"Z"m#Z#m$Z$ddlm%Z%ddl&m'Z'dd l(m)Z)ej*d Z+e+dk rd<Z-d=Z.d.Z/nd/d0d1d2d3d4d5gZ0d6Z1d7Z2d8e3fd9YZ4d:ej5fd;YZ6dS(>iN( t newTabViewtnewBoxtnewTabletnewPaneltTitledBoxPaneltnewScrollPanelt newCheckBoxt newTextEntryt newTextBox(tnewLabelt HFillFlagt VFillFlagt HExpandFlagt Utilitiest newSelector(t newButtontSmallHelpTextStylet FileChoosert OpenDirectorytOpenFiletSaveFile(t SelectorPopuptSelectorComboboxtFormt newImageBox(t dprint_ext debug_leveltPermissionDeniedErrortInvalidPasswordErrortOperationCancelledErrortUsers(tmulti_separator(tno_remote_admin_warning_label(tserver_os_patht WB_CATOPTStGeneraltAdvancedsMyISAM Parameterst PerformancetLoggingtSecuritysInnoDB Parameterst Networkingt ReplicationsAdvanced log optionssSlave replication objectssSlave default connection valuessActivate LoggingtMemorysFulltext searchsData / Memory sizet Datafilest LocalizationsThread specific settingssAdvanced SettingstVarioussBinlog Optionss Memory usaget DirectoriestLogfiless Relay LogtMasters General slavesActivate InnoDBsSlave Identifications Query cachesInsert delayed settingssSlow query log optionstNamingsTimeout SettingscCs-dGd|d|jd|jGHdS(NtCATOPTt's', '(tget_string_value(tcattgrptenabled((s%..\modules\wb_admin_config_file_ui.pythandle_cat_opt*sg@gffffff@g333333@g@g@gffffff@g@cCst|j}d}t|tkrcx6|D]+}|jsO|dkr1||7}q1q1Wn|r||kr|j|n|S(Ntt.(tstrR4ttypetisdigitt set_value(tversion_selectortset_backtvertnew_vertvch((s%..\modules\wb_admin_config_file_ui.pytverify_selected_version1s csJttj}tt}|jd|jdtt}|jdt}|jdtt}|jdt ddj t d|}|j |ttt d}|j |ttt d}|j |ttt |tk rd}td d ny&t|d t|d d }Wnttfk re}d}nXd} tjt} x$| D]} || kr| } qPqWtt| jjt d| jt| |j ttjfd|j |tt|j |tt|j |ttt} | jdtt} | j| tt|j | tt|j||j | dt"t} | dkst#| d krd} nyIg}| j$d}x!|D]}|j%t|qWt|} Wntk rE}d} nX| S(Niswarning_icon.pngi sSServer version %s is not supported by Workbench configuration file management tool.R:cSs t|S(N(R;(tx((s%..\modules\wb_admin_config_file_ui.pytNssAlthough, you can select different server version for the tool to use. Suggested version is given below. You can either pick version or type one.sYValid version formats are X.Y.ZZ or X.Y. All other variants will resort to default - 5.1.iis)Given version is not a valid tuple objectig$@gffffff@cSs t|S(N(R;(RE((s%..\modules\wb_admin_config_file_ui.pyRFoscs ttS(N(RDtTrue((R?(s%..\modules\wb_admin_config_file_ui.pyRFrstOkR9s5.1(ii(ii(&Rt main_formRtFalset set_paddingt set_spacingRGRt set_imageR tjointmaptaddR<ttupleRtintt ValueErrort IndexErrortcopytsupported_versionsRRtreverset add_itemsR>R;tadd_changed_callbackRtset_texttadd_endt set_contentt run_modaltNoneRDtlentsplittappend(tversiontformttop_vboxt info_hboxtimg_boxt right_vboxt warn_labelt version_majtetguessed_versiontversionstvtokt button_boxtnewvertsplittedtvpart((R?s%..\modules\wb_admin_config_file_ui.pytrun_version_select_form?sr         %  &             tPagecBseZdZdZRS(cCs1||_||_d|_t|_d|_dS(N(t page_namet page_contentR^tpanelRJtcreatedt update_cb(tselfRuRv((s%..\modules\wb_admin_config_file_ui.pyt__init__s     cCs ||_dS(N(Ry(RzRy((s%..\modules\wb_admin_config_file_ui.pyt set_update_cbs(t__name__t __module__R{R|(((s%..\modules\wb_admin_config_file_ui.pyRts tWbAdminConfigFileUIcBseZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZddZdZdZdZdZdZdZdZddZdZdZdZRS(cCs|jjd|jsCt|_|j|j|jn\|jj}|j j ||j j ||j j ||j j ||jj |dS(Ns Options File(t main_viewtset_content_labelt ui_createdRGtsuspend_layoutt create_uit resume_layouttserver_profilet admin_enabledtfile_name_ctrlt set_enabledt section_ctrlt bottom_boxttab_viewt search_panel(Rzton((s%..\modules\wb_admin_config_file_ui.pytpage_activateds      s5.1cCstjj|tt|_||_d|_i|_ t |_ d|_ t|_ |j|j||_||_||_d|_||_i|_|j|jj|dddt }|j|_|j|jttdS(Nt CONFIGURATIONs Options Filetadmin_option_file_win(tmformstBoxR{RJRRRR^tmyoptst opt2ctrl_mapRGtloadingtsectionRt set_managedtset_release_on_addRbtctrl_beRtcfg_betdir_dictt pack_to_toptadd_content_pagetcreate_search_panelRR[(RzRRRRbt container((s%..\modules\wb_admin_config_file_ui.pyR{s(                cstd}t_jjddt}|jd|jddtt}|jd|j d|j |t t |j jt t|j |t t t t j}|j |jjj|dfd }|j||S( NsLocate option:iitFindiFiisoption-search-panelcsjjjdS(N(t locate_optiontoption_lookup_entryR4((Rz(s%..\modules\wb_admin_config_file_ui.pytlookup_option_wrappers(R RRtset_sizeRRZRRGRKRLRPRJRRt FilledPanelRt ui_profilet apply_styletadd_clicked_callback(Rzt search_labelt search_btnt search_boxRR((Rzs%..\modules\wb_admin_config_file_ui.pyRs$         c sOt|_|dks!|dkr.t|_dS||jkrSdG|GHt|_dS|j|}|jtkr|t|_dS|j}tt}|jd|j|j j |j j }t |i|jd6|jd6tjj|jjd6|_x|dD]}|d}t|}|dkrDqnt} | jd | jd | jd | j| jttt} | j| | j|d |j| tt| j || j!d d} xt"d|D]} || } | d7} | d}|j j#|}t$fd|}t|dkr|d}| j%d }|r||kr|j&||| d }|j |} t&t'j(| _)|j*j+| j)| j,qWt-dkrt"dd} t.t'j/| _)| j0|j1| |j t2|j j$d<|j*j+| j)| j,n|j3dt|_|j*j4|j5t6|_dS(NR9isOptions stats: '%s'taddedi RbR:cSs t|S(N(R;(RE((s%..\modules\wb_admin_config_file_ui.pyRFss,Options stats after version correction: '%s'tErrorsWrong version 's'given to admin plugintClosetpositionitFile(7RGRtwb_admin_config_file_betWbAdminConfigFileBERRRRR^RRZRRYtclear_and_loadtget_possible_optionsRtget_option_set_statsRR;R<RRRstset_server_versionRNROtreload_possible_optionstKeyErrorR t show_errorRbtload_options_from_cfgRRRtRRtkeystsortRRtScrollPanelNoFlagsRwRtadd_pageRuRRtBothScrollBarsR|tupdate_file_content_tabtmaxRtadd_tab_changed_callbackRRJ( Rztsys_config_patht option_statsRtuser_selected_versionRuRvtpage_positionstpage_posR((s%..\modules\wb_admin_config_file_ui.pyRzsT    % ! (  $       cCs;|jjx'|jjD]}|jj|qWdS(N(RwtclearRtget_file_contentt append_text(RzRtline((s%..\modules\wb_admin_config_file_ui.pyRs csPt}|jt|jfd|jdtdtd|S(Ncs jS(N(tcontrol_action((RzR(s%..\modules\wb_admin_config_file_ui.pyRFss+To convert option to a multi-line one, use s to separate values. The symbol s should not be the first char(RRRJRYt set_tooltipR(RzRRtte((RRzs%..\modules\wb_admin_config_file_ui.pytcreate_textedits   cstt}|jdtjdtdtdt}|jd|jt |j fd|j tt|j |t t j t |j t ||fS(Nis+To convert option to a multi-line one, use s to separate values. The symbol s should not be the first chars...csjtS(N(topen_file_chooserR((RzRR(s%..\modules\wb_admin_config_file_ui.pyRFs( RRGRLRRRRRZtenable_internal_paddingRJRRPR(RzRRtdir_boxtbtn((RRzRs%..\modules\wb_admin_config_file_ui.pytcreate_dir_file_edits        cCsF|jjr|jjS|jjjdrB|jjdjdSdS(NRiR9(RRRt original_optsRtval(Rz((s%..\modules\wb_admin_config_file_ui.pyRs   cCsF|jjr|jjS|jjjdrB|jjdjdSdS(NRiR9(RRRRRR(Rz((s%..\modules\wb_admin_config_file_ui.pyRs   csfdfdtt}|jdtjd|jttjtt}|j d|jd|j t|j fd|j|ttd}ddkrrtt j}|jt jjjd |jd |j t|j fd |j|tt|jtnd}dd kr tt j}|jt jjjd|jd|j t|j fd|j|tt|jtn||||fS(Ncs(tj}|jjd}|stjjddddd}|tjkrjdrzdj }nTj }|r|j |j |d}n tjj d d ddddS|j|q'dSnB|j|s'j }|r'|j |j ||}q'nt}tjd}}yjjj|}Wntk rd}xtr yLjjjd }|dk rtj}njjj|||}WnBtk r}t|GHjjjd qotk rdSXPqoWnX|sEtjjd d |jj fddddSt!t"} | j#t$j%j&d| j'r$d} yjjj(|||} Wnt)k rF}yjjjd }Wntk r}dSX|dk rtj}nyjjj(|||} Wqtk rB} jjjd | qXn:tk r}tjjd|t|ddddSX| dk r$| j*} yt+| d} Wn:t,k r}tjjd| t|ddddSX| j-| tj.jj/d|jj | fq$ndS(Ns" sSpecify remote locationsNo remote location available. Please specify the path to the file in the server using the line edit control at the left of the download button and try again. Or you can click on the "Use Suggested" button to let Workbench use an appropriate value for the remote locationtOKs Use SuggestedR9Rs%s.txts$Could not find server data directorysRPlease type the full path to the file in the server before attempting to upload ittfilesFile does not exists"The file "%s" does not exist in %st~sError while reading from "%s"tws$Error while opening "%s" for writings+File %s in %s successfully downloaded to %s(0R!RR4tstripRR Rt ResultCancelRRRtabspathRNt show_warningR>tisabsRJRtCURRENTR^Rt server_helpert file_existst ExceptionRGtpassword_handlertget_password_fortADMINRR;treset_password_forRt host_nameRRt set_directoryRRt expanduserR]RRtget_pathtopentIOErrortwritetApptset_status_text(Rtospatht remote_pathtresRR(tas_usert user_passwordRjt filechoosertcontentterrt local_patht local_file(RzRR(s%..\modules\wb_admin_config_file_ui.pytdownload_file_from_server_cbs  "   !                      c s tj}|jjd}|stjjddddd}|tjkrjdrzdj }naj }|r|j |j |d}|j |n tjjd d ddddS|j |q4dSnB|j|s4j }|r4|j |j ||}q4ntt}|jtjjd |jr|j}yt|}Wn:tk r}tjjd |t|ddddSXy5|j} jjj|| d tj ddWnt"k r}yjj#j$d} Wnt%k r4}dSX| dk rMtj&} ny jjj|| | | Wqt'k r} jj#j(d| qXn:t%k r}tjjd|t|ddddSXtj)jj*d|jj+|fndS(Ns" sSpecify remote locations No remote location available. Please specify the path to the file in the server using the line edit control at the left of the upload button and try again. Or you can click on the "Use Suggested" button to let Workbench use an appropriate value for the remote locationRs Use SuggestedR9Rs%s.txts$Could not find server data directorysRPlease type the full path to the file in the server before attempting to upload itRsError while opening "%s"R:R;Rs&Error while uploading the file to "%s"s)File %s successfully uploaded to %s as %s(,R!RR4R!RR RR"RRRR#RNR>R$R%RRR/RRR0R]R1R2R3R;treadRR'tset_file_contentRR&R^RR*R+R)R,RR-R5R6R.( RR7R8R9RR<R?R@RjR=R;R:R>(RzRR(s%..\modules\wb_admin_config_file_ui.pytupload_file_to_server_cbIsr     !      )       is#The path to the file in your servers...sBrowse a file in your server...csjtS(N(RR((RzRR(s%..\modules\wb_admin_config_file_ui.pyRFsR<t filedownloadtfileeditsrecord_export.pngs)Download this file to your local computercs S(N(((RRA(s%..\modules\wb_admin_config_file_ui.pyRFssrecord_import.pngs4Upload a file from your local computer to the servercs S(N(((RRD(s%..\modules\wb_admin_config_file_ui.pyRFs(RERF(RRGRLRRRPRRJRRZRRR^Rt ToolButtontset_iconR5Rtget_resource_path(RzRRRRtbtn_dwntbtn_upl((RRDRzRRARs%..\modules\wb_admin_config_file_ui.pytcreate_fileeditsB`D             cs@t}|jt|jd|jfd|S(NsLFor numeric values, you may specify a K, M or G size suffix, if appropriate.cs jS(N(R((RzR(s%..\modules\wb_admin_config_file_ui.pyRFs(RRRJRRY(RzRRR((RRzs%..\modules\wb_admin_config_file_ui.pytcreate_numerics    c sid}d|kr|d}nt}|dkr:t}nt|}t|tkr|tjkrtj|}t|}g}x6|j dD]"} | j d} |j | qWqnx|D]} |j | qW|j t|jdrF|d} d} x7|D],} | | kr5|j| n| d7} qWn|jfd||fS( Ntchoicetdropdownboxentryt,s Riics jS(N(R((RzR(s%..\modules\wb_admin_config_file_ui.pyRFs(R^RRRR<R;RtpysourcetevalR`R!Ratadd_itemRRJRt set_selectedRY( RzRRtctypetitemststyletdropboxtcodetresulttitemtiRtidx((RzRs%..\modules\wb_admin_config_file_ui.pytcreate_dropdownboxs6            cs`d}d}dt}|jd|jdd|jd|dksm|dkrd||ff}|j<|jtnz|d ks|d ks|d krj}|j |d d ||d t t Bd||ff}|jR(Rztfile_chooser_typet textfieldRRfR<Rw((s%..\modules\wb_admin_config_file_ui.pyRLs   *!*cs|jj|r|j|fd}d}|dk r`|}|dj|n|dj}|dkr|dj|n|dkr|dj||ddk r|dj|qn|dkr|dj|n|dkr5|dj||dj|ns|d kr|dj||dj|y*|d j||d j|Wqtk rqXn|js|r|jj ||j |j q|jj ||j qndS( Ncs d|S(Ni((R](R(s%..\modules\wb_admin_config_file_ui.pytcontrolasiReitspniRoRhRiii( RRR^Rt get_activeRR)RRt option_addedtget_string_value_from_controlRtoption_removed(RzRt force_enabledRttagR7((Rs%..\modules\wb_admin_config_file_ui.pyR]s>          %cCsa|jr dS|jj|r]|j|}|js]|jj||j||jq]ndS(N(RRRRtoption_changedRR(RzRR((s%..\modules\wb_admin_config_file_ui.pyRs    c sKd}d}fd}t}|dj}|dkrLt}n|dkrp|djf}n |dkr|djjd}|d dk r|||d j7}q|n|d kr|dj}n|d kr|dj}|r||jd }q|n]|d krX|dj}|r||jd }q|n$|dkr||djf}nt}t}t|t krt |} | dkr?t|dt kpt|dt k}|r|dj tdk}qq?n9t|t kp't|t k}|j tdk}|tkr|r|r|j rtjddddd} | tjkr|djdqn|r|rt|t krt |dkr|d}qnt|t k rtd|jt}qnt|tk rGt|t k rG|f}n|S(NR9ics d|S(Ni((R](R(s%..\modules\wb_admin_config_file_ui.pyRsitMultipleReRs iRoRht;RiRatConfirmsQMulti-line option format entered. Would you like to convert option to multi-line?tConverttSkipcSs |jtS(N(R!R(RE((s%..\modules\wb_admin_config_file_ui.pyRFs(RJtget_nameRGR4R!R^R`RR<RQR_R;R~tfindRRR t show_messageRtResultOktset_nameROtlist( RzRRRRt is_multiplet control_namet is_stringt has_separatort value_lentanswer((Rs%..\modules\wb_admin_config_file_ui.pyRsd           ,"$"  !$ c s|jd}d}dk rVx2D]'}t|}||kr(|}q(q(Wnd}fd}|dkrt|}xdtd|dD]L} | |kr|| } || } | dk r| }|| }qqqWntd||fS(Ns iR9csC|j}d}x*D]"}||jkr|}PqqW|S(N(tlowerR^(tsfxtsfx2tret_itemR[(t unit_items(s%..\modules\wb_admin_config_file_ui.pytget_units  icSs|jp|dkS(Nt-(R=(RE((s%..\modules\wb_admin_config_file_ui.pyRFs(R!R^R_RR( RzRRtlongest_suffixR[tltsuffixRRt suffix_lengthtcur_sfxtcur_unit((Rs%..\modules\wb_admin_config_file_ui.pytparse_spin_strings&          c sd}fd}t}t|tkr_t|dkr_t}|djdn|djd|dkr|dkst|tt f rd }n|j d }|dj ||j n|d kr|dkrd }nt|tk r n|j d }|j |d |\}}|dj ||d dk r{|dk r{y,|d j|}|d j|Wqtk rqXq{n|dkrByp|d }|dk r*|j} xEt|D]4\} } | j| kr|dj| qqWnWq{tk r>q{Xn9|dkrv|jj|}|dj|ndGHdS(Nics d|S(Ni((R](R(s%..\modules\wb_admin_config_file_ui.pyRsiRtSingleReRhRiR9s RiiRoRaR(stxtsdirsfed(RJR<RQR_RGRR^t isinstanceR;R~R!R>RRtindexRTRSRt enumerateRtnormalize_boolR( RzRRRRRRR]RVt lowcase_valueR\R[((Rs%..\modules\wb_admin_config_file_ui.pyRsP $ "          !  cCsO|jj|j}|r>tjjdd|dddn |jjdS(NsConfiguration ErrorscThe following errors were found in the changes you have made. Please correct them before applying: RR9(Rtvalidate_changesRRR R$t apply_changes(Rzterrors((s%..\modules\wb_admin_config_file_ui.pytconfig_apply_changes_clicked5s  cCs|jdS(N(R(Rz((s%..\modules\wb_admin_config_file_ui.pytconfig_discard_changes_clicked?scCs6|jtkr2|j|j|jjndS(N(RRJt load_defaultsRRR4(Rz((s%..\modules\wb_admin_config_file_ui.pyRDs c Cs:t|_y |jj|jjp$dWnBtk rm}tjj ddt |j |fdddnX|j j d}|dks|dkr|jj}nt}xWt|jjD]@\}}|j j|t}||kr|}||_qqW|tkr9|dk r9|j j|d}n|j j|x|jj|jD]\}}|jj|} | s|jj|} x_| D]T} |jj| } | dk r| |j|<| ddj||j| =PqqWn| dkr q_n|j|t|j| |q_Wt|_dS(NR9s Error opening configuration files%s: %sRii(RGRRtopen_configuration_fileRRR)RR RR<R}RRR^tconfig_file_sectionRJRt get_sectionsRSRRTRRRRRZRR( Rzt given_sectiontexcR]tsection_ctrl_was_filledR\tsecRRRRtalt_name((s%..\modules\wb_admin_config_file_ui.pyRJsL    "  "      cCst|_x|jjD]\}}|dk r|d}|d}|dk r|dk r|djt|j|dt|jdr|d}|dk r|j |t |qq|j |dqqqWt|_dS(NiiiRRR9( RGRRRR^RRJRRRR;(RzRRRRR((s%..\modules\wb_admin_config_file_ui.pyRs      cCs|j|jjj|dtd|_|jjd|jj}|dkr`d}n|jj ||jj ddt |_ |j j ddtt|_t}|j d|j|jt}|j d|j|j|j|jtt|j|jtt|jjtd tt|jj|jtt|jj|j tttj|j|||jjd |jjd |jdS( NRR9slTo change the path to the configuration file, edit the server profile in the Manage Server Instances dialog.i,iis Apply ...tDiscardsConfiguration File:ii (RRRRR RRRRR^RZRRRRRGRRRRRRPRRJR tadd_end_ok_cancel_buttonsRLRKR(RzR t accept_btnt discard_btn((s%..\modules\wb_admin_config_file_ui.pyRs6         cCspt|jdrl|jjrltjdd|jjddd}|tjkr_|j n|tj kSdS(Nt changesetsConfiguration filesaConfiguration file from instance '%s' may contain unsaved changed. Would you like to review them?tReviewtCancelR( thasattrRRR R$RRRRRt ResultOther(RzR9((s%..\modules\wb_admin_config_file_ui.pytshutdowns   N( R}R~RR{RRRRRRRRRRRLRMR^RRR^RRRRRRRRRRRR(((s%..\modules\wb_admin_config_file_ui.pyRs:    u  =       $ U  , J " 5   ;  -( R#R$sMyISAM ParametersR%R&R'sInnoDB ParametersR(R)(R(sAdvanced log optionssSlave replication objectssSlave default connection valuessActivate LoggingR*sFulltext searchsData / Memory sizeR+R,sThread specific settingsR$sAdvanced SettingsR-sBinlog Optionss Memory usageR.R/s Relay LogR0s General slaveR'sActivate InnoDBsSlave Identifications Query cacheR#sInsert delayed settingssSlow query log optionsR1sTimeout Settings(7RtsysRURRRRRRRRRRR R R R R RRRRRRRRRRRRt wb_commonRRRRRRRtwb_admin_utilsR tworkbench.utilsR!tgetenvRrR^RsRtR8RVRDRstobjectRtRR(((s%..\modules\wb_admin_config_file_ui.pyts,   @.."  .    U