@Qc@snddlZddlZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZmZddlmZmZmZmZmZddlmZmZmZmZmZmZejjeZ ddl!m"Z"ddl#m$Z$iZ%de%dd$Z?d%Z@d&ZAd'ZBd(ZBd)ZCd*ZDdS(+iN(t UtilitiestFormtnewBoxtnewLabelt newTextBoxt newButtontApp(tOperationCancelledErrortInvalidPasswordErrortPermissionDeniedErrort splitpathtUsers(tlog_infot log_errort log_warningt log_debugt log_debug2t log_debug3(t ServerProfile(tserver_version_str2tuples@grt.root.wb.options.options["@db.mysql.Table:tableEngine/Items"]s engine-listt;cCs6tt|t|}t|d|!|d|!S(Ni(tmintlentcmp(tv1tv2tminlen((s%..\modules\wb_admin_config_file_be.pytver_cmp-sc Cs|\}}}t}d}x3|D]+}t||dkr"|}t}Pq"q"W|r |dk rxG|D]<}|d |d krjt||dkrt}nPqjqjWn|dk r d} xG|D]<} |d | d krt|| dkrt}nPqqWq n|S(Nii(tFalsetNoneRtTrue( tversiont versions_listtinvertvlisttoutvertrettmatched_versiontvtivtout_vertov((s%..\modules\wb_admin_config_file_be.pytoption_is_for_version2s.        cCst}|dk r|dk rt|}t|}||krZ||krt}qq||kr||| krt}q||| krt}qqn|S(N(RRRR(tvdtvstskiptvdltvsl((s%..\modules\wb_admin_config_file_be.pytis_opt_deprecatedVs       cCsd}ytjd|}|r|j}|ddk rmt|dt|dt|df}qt|dt|df}nWn*tk r}d|dGt|GHnX|S( Ns/([0-9]+)\.([0-9]+)\.([0-9]+)|([0-9]+)\.([0-9]+)iiiiis*ERROR! incorrect version attribute value 's', (Rtretmatchtgroupstintt ValueErrorttype(t version_strRtresttokenste((s%..\modules\wb_admin_config_file_be.pytparse_version_strjs 0'c Csd}d|krx|dD]}|jd}|jd}|dkrVd}n|dkrkd }n||kr||krt}d|kr|d}||ks|dks|dkrt}qnt}|r|}PqqqWn|S( Ntvaluest inversiont outversioniictplatformtall(iii(icii(RtgetRR( toptRR?tvaluet cur_valueR=R>tplatform_matchtpl((s%..\modules\wb_admin_config_file_be.pyt pick_valuezs*       $ tOptioncBsheZd d dZdZdZdZdZdZdZ dZ dZ d Z RS( cCsG||_g|_|dk rC|dk rC|jj||fndS(N(tsectionR<Rtappend(tselfRItlineRC((s%..\modules\wb_admin_config_file_be.pyt__init__s  cCs|jj||fdS(N(R<RJ(RKRLRC((s%..\modules\wb_admin_config_file_be.pyRJscCst|jdkS(Ni(RR<(RK((s%..\modules\wb_admin_config_file_be.pyt is_multilinescCs7t}t|jdkr3t|jtk}n|S(Ni(RRR<R6tbool(RKR$((s%..\modules\wb_admin_config_file_be.pyt is_switch_optscCs|j|dS(Ni(R<(RKti((s%..\modules\wb_admin_config_file_be.pytvalscCs|j|dS(Ni(R<(RKRQ((s%..\modules\wb_admin_config_file_be.pyRLscCs t|jS(N(titerR<(RK((s%..\modules\wb_admin_config_file_be.pyt__iter__scCs t|jS(N(RR<(RK((s%..\modules\wb_admin_config_file_be.pyt__len__scCs-tjg|jD]}t|d^qS(Ni(tmulti_separatortjoinR<tstr(RKtx((s%..\modules\wb_admin_config_file_be.pyt__str__scCstj|jS(N(tpprinttpformatR<(RK((s%..\modules\wb_admin_config_file_be.pyt__repr__sN( t__name__t __module__RRMRJRNRPRRRLRTRURZR](((s%..\modules\wb_admin_config_file_be.pyRHs        iiit ApplyWizardcBs8eZdZdZdZdZddZRS(c Cstj|d|jd||_||_|j|_tt }|j d|j d|jj }d|}|d7}|d7}|j t|t tttj|_|jjtttj|_|jjt|j |jtt|j |jtttt}|j dt}|jdt|_|jjd|jj|jt|_|jj|j|j |jt t|j|t t|j|jt t|j |t t |j||j|j dd |j|j!dS( Ns)Apply Changes to MySQL Configuration Filei shThe following changes were made to the configuration file "%s" and will be saved when you click [Apply].sI You may edit the File Preview if you wish to make more changes manually.sW Please review carefully as some mistakes could prevent the MySQL server from starting.tApplytCancelii("RRMRt set_titletserver_profiletctrl_bettarget_is_windowstis_winRRt set_paddingt set_spacingtconfig_file_pathtaddRRRtmformstBothScrollBarst file_textboxt set_borderedtdiff_view_textboxRtset_textt cancel_btntadd_clicked_callbacktcancel_clickedtview_btnt switch_viewtadd_endt set_contenttcentertset_sizet apply_clicked( RKtownerReRdtcontenttfiletmsgt button_boxt apply_btn((s%..\modules\wb_admin_config_file_be.pyRMsH                   cCs|jtkrK|jjt|jjt|jjdt|_n9|jjd|jjt|jjtt|_dS(NsView File Previews View Changes(t view_diffRRntshowRpRRuRq(RK((s%..\modules\wb_admin_config_file_be.pyRvs cCs|jdk r|jj}||jkrctjddddd}|tjkrcd}qcn|rt j j dnt j j dx t ry$|j|t j j dWnt k r}tjd d d d d}|tjkrqqntk r2}tjd d ddd}dStk r}ddl}|jt j j dtjd dt|j|fdddnXPqWn|jdS(NsConfirm Changes from PreviewsYou have made additional edits to the configuration file in preview. If you wish to save these changes click [Yes], or if you wish to ignore these changes click [No].tYestNots.Saving Configuration File with Manual Edits...sSaving Configuration File...sConfiguration File Saved.s!Could not Save Configuration FilesmThere was a permission error while saving the configuration file: %s Click Retry to enter the password again.tRetryRbs5Password input was cancelled. The file was not saved.tOKis Error Saving Configuration File.s8There was an error saving the configuration file. %s: %s(t accept_actionRRntget_string_valuetcfgfileRt show_messageRltResultOkRRAtset_status_textRRt show_errorRt Exceptiont tracebackt print_excR6R^tclose(RKt text_from_boxtanswertexctrR((s%..\modules\wb_admin_config_file_be.pyR{s@         0cCs*tjjdd|_|jdS(Ns$Cancelled Save of Configuration File(RRARRRR(RK((s%..\modules\wb_admin_config_file_be.pyRtFs cCs_||_t|_||_|jj|j|jj||j|jd|j dS(N( RRRRRnt set_valueRpRvt show_modalRRr(RKt changes_textttemp_file_contentR((s%..\modules\wb_admin_config_file_be.pyRKs    N(R^R_RMRvR{RtRR(((s%..\modules\wb_admin_config_file_be.pyR`s  <  ( tWbAdminConfigFileBEcBseZdddYZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZddZdZdZdZdZdZdZdZdZdZRS(t ChangesetItemcBseZdZdZRS(cCs1||_||_||_||_d|_dS(N(tmodRIRCtnameRtorig_opt(RKtmtstnR&((s%..\modules\wb_admin_config_file_be.pyRM[s     cCs|jtkrd}n0|jtkr0d}n|jtkrHd}n||jd|jdt|j7}|jr|dt|jd7}n|dS( Nt+t-t*t:t=s;[t]s ( RtADDtDELETEtCHANGERIRRXRCR(RKR((s%..\modules\wb_admin_config_file_be.pyR]bs   ) (R^R_RMR](((s%..\modules\wb_admin_config_file_be.pyRZs cCs}g|_i|_d|_t|_i|_g|_d|_||_ ||_ |j |_ i|_ d|_|jdS(NR(t file_linest original_optst file_nameRtneeds_root_for_file_readt changesettsectionsRt apply_formRdReRfRgt opt_rindextoption_set_statstreload_possible_options(RKRdRe((s%..\modules\wb_admin_config_file_be.pyRMos            cCs|jS(N(R(RK((s%..\modules\wb_admin_config_file_be.pytget_file_contentscCs|jS(N(R(RK((s%..\modules\wb_admin_config_file_be.pytget_option_set_statsscCs|jj}|rHt|dkrHt|tk rHt|}qHn| sat|dkr|jj}tdt |j j fdt|ndt|GH|j ||jj |_dS(NRs%s:%s.reload_possible_options()s(Got server version "%s" from the server sNote! Workbench uses server version '%s' from the server instance profile. Make the entry empty to auto pick version from the server.(Rdtserver_versionRXR6ttupleRRetget_server_versionRt _this_filet __class__R^ttransform_opts_fort target_ostpossible_options(RKR((s%..\modules\wb_admin_config_file_be.pyRs cCs|jS(N(R(RK((s%..\modules\wb_admin_config_file_be.pytget_possible_optionsscCstdt|jjfdt||fd}i}i|_d\}}}}xtjD] \} } i} g} x| D]\} }i}| |dstcontrolsR3tpositionRtaddedtskippedtskipped_no_valuesPrepared options set for server version '%s' on '%s' platform: added - %i, skipped - %i, skipped with no value - %i, deprecated - %i(iiii(RRRR^RXRtoptst opts_listR*R0RGtcopytupdateRJRAtnormalize_booltoption_alt_namesRtsortRR(RKRR?tposttabsRRRtno_valuettabnamettabcontt new_tab_contR3tgrpnametgrpconttgrpRRBRCtcoptR((s%..\modules\wb_admin_config_file_be.pyRsZ-            !  ,cCsG|jdd|jddg}||krC|jd|n|S(NRt_i(treplacetinsert(RKRtnames((s%..\modules\wb_admin_config_file_be.pyRs$ cCs5d}|jj|}|dk r1|d}n|S(Ni(RRRA(RKRtodeftoption((s%..\modules\wb_admin_config_file_be.pytget_option_defs   cCs|jj|ddS(Ni(NNN(RRAR(RKR((s%..\modules\wb_admin_config_file_be.pytget_option_locationscCs,g|jjD]}||kr|^qS(N(Rtkeys(RKtfragmentR((s%..\modules\wb_admin_config_file_be.pytget_options_containingsc Cst}t|tkr!|}n|rZt|tksKt|tkrZ|j}n|dks|dks|dks|dkrt}nE|dks|dks|dks|dks|d krt}n|S( Ntcheckedtonttruet1t uncheckedtofftfalseRt0(RR6RORXtunicodetlowerR(RKRCR$((s%..\modules\wb_admin_config_file_be.pyRs *0 < cCs|j|}d}d}|dk rd|krU|d}|rU|j}qUnd|kr|d}|rt|tk r|j}qn|dkr|j|}qn||fS(NR6RR(RRRR6ROR(RKRt option_deft option_typetoption_default((s%..\modules\wb_admin_config_file_be.pytget_option_type_and_default s      cCs||_t|_yt|Wn7tk rS}|jtjkrZt|_qZnnXg}d}y|j |}WnKtk r}|jtj kr|}qt j dd|dddnX|j ||r|ndS(NsRead Configuration FilesWConfiguration file '%s' can not be found. New file will be created on apply of changes.RR(RRRtopentIOErrorterrnotEACCESRRtread_mysql_cfg_filetENOENTRt show_warningtparse_file_contents(RKRterrorR}t exceptionR:((s%..\modules\wb_admin_config_file_be.pytopen_configuration_files,     cCstdt|jjfd|d}|jsyrtdt|jjfd|jjj|dt j dd}tdt|jjfdt |pgWqt k r}tdt|jjfd|t |_qXn|jrtdt|jjfd|jjjd }|dk r8t j}ny<tdt|jjfd |jjj|||}Wqtk r}tdt|jjfd ||jjjd |qXntdt|jjfd |rg|jd D]}|jd^qSgSdS(Ns%s:%s.read_mysql_cfg_file()sReading config file "%s" sTrying to read without sudo tas_usert user_passwords%i bytes read from file s8Permissin denied, sudo needed to read config file: "%r" sTrying to read with sudo R~s Reading... sInvalid password error: "%r" sConfig file read s s (RRRR^RRRet server_helperRR tCURRENTRR Rtpassword_handlertget_password_fortADMINRtreset_password_fortsplittrstrip(RKRR}R:RRterrRL((s%..\modules\wb_admin_config_file_be.pyR<s>  $    ! )cCs|sd}n|jjr6dj|jd}n|jj}t|j\}}y|j|d}Wn&t k r|jj j d}nXy&|j |j|d|dk |Wn,tk r}|jj jd|nX|j|j}|j|dS(NRs s R~s.wba.bak(RdRfRWR ReRR Rtcheck_dir_writableRRRR tset_file_content_and_backupRR RR(RKtuser_modified_file_contentthelpert directorytfilenametpasswordRtdata((s%..\modules\wb_admin_config_file_be.pytsave_config_fileds$      & c sFi|_t|tks-t|tkr9||_n td|jj}|s`d}ntdt |j j fd|g|_ |j dk ri}d}xt|jD]\}}|jd}t|dkr|ddk r|dd k r|dd kr:|jd }|j j||fqv|jjd dkrXqv|jd }||krv|djd} d} | |kr|| } nt|} | || ssRead Configuration FilesConfiguration file did not contain section [%s], so a new one was added. If that is not correct, please fix the section name in the Server Instance Editor and reopen the administrator.Rs] (!RR6tlistRRRRdtconfig_file_sectionRRRR^RRRt enumeratetstripRRJRtfindR RHRWRRRARtsortedt admin_enabledtanyRR( RKt file_datatfilter_by_sectiontcur_file_original_optstcurrent_sectionRQRLtslineRBt option_nameRR((RIs%..\modules\wb_admin_config_file_be.pyRsb $      2     )     ,  c Cs&tdt|jjfd|||f|dkr?t}n|dkrZ|jj}n|j|}|j d}|j j |}|j d}|dkrf|j d}t dt|jjfd||||||f|dk r^||j kr^t j t||d} |j || _| |j||jj|rr|j|}|j|krr|j|=qrndS(Ns%s:%s.option_removed()sopt removed "%s" R6RRRRs>removing "%s", orig_opt = "%s", off_value = "%r", odef = "%s" s0Error, option definition does not have disbledbys got orig optiRtdel(RRRR^RRARRRRRRRRRRRRRRR/RI( RKRRIteciRRRRR0Rt off_valuet orig_valueRC((s%..\modules\wb_admin_config_file_be.pytoption_removed6sl!            cCstdt|jjfd||ft|tk rMdG|GdG|GHn|jj|r|j|}tj t |||}||_ ||j |k r}d|j0dt|}nX|j9j?|||j@dS(NicSs+|}t|tkr't|}n|S(N(R6ROR4(R&trv((s%..\modules\wb_admin_config_file_be.pytmap_boolscs\t|j|j}|jtkrX|dkrXt|jd|jd}n|S(Ni(RRRRI(RYRR(t sections_map(s%..\modules\wb_admin_config_file_be.pytsort_fns(s%s:%s.apply_changes()sApplying change "%r" sline_nr "%r", "%r" s s = RRs = 0 iRsCan't add optionsmysql_workbench_config.tempsw+bs tatbRsThere are no changes.RsCan not read file (ARRtdictRRBR&RRCRtdeepcopyRRRR6RCR!RtmapRRRRRR^RRtrangeRRLRRXRRRRIRJRRRRRARR$Rttempfilet gettempdirtostpathRWttemp_file_nameRRdRfR twriteRR`ReRtdifflibt unified_difftendswithtreadt BaseExceptionRR( RKRYRMRORItsecond_pass_changesRtcRRtorig_values_lentmodified_values_lenRQtline_nrtrvalueR0RLRCt lines_rangetlinenoR&tvtypettempdirtoutfteoltltchanges_for_applytsecond_pass_changes_for_applyRtdRR:((RNs%..\modules\wb_admin_config_file_be.pyt apply_changess 9  *!* % **  +)   ))      11 ('  cCscy#|j|j}|j|Wn9tk r^}tjdd|j|fdddnXdS(Ns$Could not Re-read configuration files&An error occurred while reading %s: %sRR(RRRRRR(RKRR((s%..\modules\wb_admin_config_file_be.pytrevert_s (N(R^R_RRMRRRRRRRRRRRRRRRRR3R8R9R=R>RBRKRqRr(((s%..\modules\wb_admin_config_file_be.pyRXs4      ?       ( 0 ^ D P      cCsdS(N((tctxtlines((s%..\modules\wb_admin_config_file_be.pytrecreate_cfg_withlscCs|d}|d}|d}|j}d}d|krI|d}ntd}|rh||dChecking turn on bool opt with disabledby=skip-* (opt in file)RRws!tmp/wb_admin_config_file_be12.cnfssys.config.pathRs [mysqld] s skip-new ReRvRRRismerge is not set.(R(R^RRXRYRWRRyRR[RRRRzRRR3RqRRRR(RsRRRRwRRRv((s%..\modules\wb_admin_config_file_be.pyt unit_test_12s(  &   %      c Cs1tdf}t}d}|d}tjjtjd|jd<}t|d}|jd|j |d}|j }d|_ t t |d|d|d <} t ||| _| j| jd d| j| jd| jjd krt}|d7}n||_ |||fS(NsDisabling innodbRRws!tmp/wb_admin_config_file_be13.cnfssys.config.pathRs [mysqld] ReiiiRvtinnodbRs,innodb option appeared in file after removal(iii(R^RRXRYRWRRyRR[RRRRRzRRR8RqRRRAR( RsRRRRwRRReRRv((s%..\modules\wb_admin_config_file_be.pyt unit_test_13s.  &     %       c Cs1tdf}t}d}|d}tjjtjd|jd<}t|d}|jd|j |d}|j }d|_ t t |d|d|d <} t ||| _| j| jd d| j| jd| jjd krt}|d7}n||_ |||fS(NsDisabling innodbRRws!tmp/wb_admin_config_file_be13.cnfssys.config.pathRs [mysqld] ReiiiRvRRs,innodb option appeared in file after removal(iii(R^RRXRYRWRRyRR[RRRRRzRRR8RqRRRAR( RsRRRRwRRReRRv((s%..\modules\wb_admin_config_file_be.pyR s.  &     %       c Csjtdf}t}d}|d}tjjtjd|jd<}t|d}|jd|j |d}|j }d|_ t t |d|d|d <} t ||| _| j| jd dd| j| j| jjd } | jGHd| kr,t}|d7}n(d| jdkrTt}|d7}n||_ |||fS(Ns<Disabling innodb. File has bool innodb, WBA uses enum innodbRRws!tmp/wb_admin_config_file_be14.cnfssys.config.pathRs[mysqld] innodb ReiiiRvRtOFFRs&innodb option disappeared after changeis$innodb option was not changed to OFF(iii(R(R^RRXRYRWRRyRR[RRRRRzRRR9RqRRARRRR( RsRRRRwRRReRRvR((s%..\modules\wb_admin_config_file_be.pyt unit_test_14?s8  &     %         cCs'|dt_d|kr#|d=ndS(NR{Rv(R`R(Rs((s%..\modules\wb_admin_config_file_be.pytunit_test_10000ds  (ERRR[RXRVR\R1RRlRRRRRRRt wb_commonRRR R R tgrtR R RRRRRYtbasenamet__file__Rtwb_server_controlRtworkbench.utilsRtpysourceRVRR*R0R;RGtobjectRHRRRR`RRuRzR|R~RRRRRRRRRRRRRR(((s%..\modules\wb_admin_config_file_be.pytsd         4(.   $   $'     5    & 5      %