@Qc@sddlZddlZddlmZddlmZddlZddlZddlm Z m Z ddl m Z ddl m Z defdYZd efd YZd e fd YZdS( iN(tdeque(tpartial(t WizardPagetWizardProgressPage(trequest_password(t DataMigratortTaskcBseZdZdZedZedZedZedZedZ edZ dZ d Z d Z d Zd Zd ZRS(cCs2||_||_||_t|_|jdS(N(townertlabeltfunctTruet_enabledtreset(tselfRR R((s..\modules\db_copy_progress.pyt__init__ s     cCs!|jtjdd|j|jjd|jy|jWntjk r~|jjd|j|jdSt k r}t |t sHddl }|j nd|j|jj|f}|jj||j||nX|jjd|j|jdS(NtWizards Execute '%s' s%s...s %s cancelledisError during %s: %ss%s done(t set_runningtgrttlog_infoRRt send_infoR t UserInterruptt set_abortedt Exceptiont isinstancet ThreadedTaskt tracebackt print_exctformat_exception_textt send_errort set_failedt set_finished(R teRtmsg((s..\modules\db_copy_progress.pytrun)s(      cCs|jS(N(R (R ((s..\modules\db_copy_progress.pyt is_enabledBscCs|jS(N(t_running(R ((s..\modules\db_copy_progress.pyt is_runningFscCs|jS(N(t _finished(R ((s..\modules\db_copy_progress.pyt is_finishedJscCs|jS(N(t_failed(R ((s..\modules\db_copy_progress.pyt is_failedNscCs|jS(N(t_aborted(R ((s..\modules\db_copy_progress.pyt is_abortedRscCs%|jo$|j o$|j o$|j S(N(R"R&R(R*(R ((s..\modules\db_copy_progress.pyt is_pendingVscCs1d|_t|_t|_t|_t|_dS(N(tNonet_error_messagetFalseR#R%R'R)(R ((s..\modules\db_copy_progress.pyR Zs     cCs t|_dS(N(R R#(R ((s..\modules\db_copy_progress.pyRascCst|_t|_dS(N(R R)R.R#(R ((s..\modules\db_copy_progress.pyRds cCst|_t|_||_dS(N(R.R#R R'R-(R R ((s..\modules\db_copy_progress.pyRhs  cCst|_t|_dS(N(R.R#R R%(R ((s..\modules\db_copy_progress.pyRms cCs ||_dS(N(R (R tflag((s..\modules\db_copy_progress.pyt set_enabledqs(t__name__t __module__RR!tpropertyR"R$R&R(R*R+R RRRRR0(((s..\modules\db_copy_progress.pyRs      RcBsEeZdZdejfdYZdZdZdZRS(cCs)tt|j|||d|_dS(N(tsuperRRR,t_thread(R RR R((s..\modules\db_copy_progress.pyRwst TaskThreadcBseZdZdZRS(cCstjj|||_dS(N(t threadingtThreadRR(R R((s..\modules\db_copy_progress.pyR~scCs|jjdS(N(Rt thread_work(R ((s..\modules\db_copy_progress.pyR!s(R1R2RR!(((s..\modules\db_copy_progress.pyR6}s cCs[|j|jjd|jtjdd|j|j||_|jjdS(Ns%s....RsStarting thread for '%s' ( RRRRRRR6R5tstart(R ((s..\modules\db_copy_progress.pyR!s  cCs t|_tt|jdS(N(R.R%R4RR (R ((s..\modules\db_copy_progress.pyR s cCs y|jWntjk rR|jjd|jtjj|j t dSt k r}Hddl }|j tjdd|j|f|jjd|jt|ftjj||dt dSX|jjd|jtjj|jt dS(Ns %s cancellediRsThread '%s' failed: %s s%s: %scSs|jd|jj|S(Ns Error: %s(RRR(R texc((s..\modules\db_copy_progress.pytss %s finished(R RRRRRtmformst Utilitiestperform_from_main_threadRR.RRRt log_errorRtstrR(R R;R((s..\modules\db_copy_progress.pyR9s   #( R1R2RR7R8R6R!R R9(((s..\modules\db_copy_progress.pyRvs    tProgressMainViewcBsIeZedZdZdZdZdZdZdZ dZ edZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%RS(#cCsqtt|j|d||_g|_d|_t|_t|_ t |_ t|_ t |_t|_dS(NsCopy Databases(R4RBRtmaint_tasksR,t_currently_running_task_indexR.t_progress_indeterminatet_tasks_finishedRt _log_queuet _showing_logsR t_log_progress_textt_cancel_requested(R RCtuse_private_message_handling((s..\modules\db_copy_progress.pyRs        cCs}|jjjj|_t|j|_tt|j ||ry|j |j dkry|j ry|jqyndS(N(RCt_schema_selection_pagetschema_selectort get_selectedt _schema_listtlent _schema_countR4RBtpage_activatedR RER,RGR:(R t advancing((s..\modules\db_copy_progress.pyRSs cCsL|jjdtjd|_|jj|jtttjt|_ |j jd|j j dtjd|_ |j j|j tttj |_ |j j|j tt|jj|j tttjt|_|jjd|jj dtjd|_|jj|jtttj |_|jj|jtt|jj|jtttjd|_|jj|jtttjtj|_|jjd|jjdtjtj|_|jjt|jj|j|jjt|jj|jtt|jjddS(Nitiis Message Logi s Show Logs(tcontentt set_paddingR=tnewLabelt _descriptiontaddR.R tnewBoxt_schema_progress_boxt set_spacingt _schema_labeltnewProgressBart_schema_progresst _progress_boxt _status_labelt _progresst _detail_labeltnewPaneltTitledBoxPanelt_log_boxt set_titlet newTextBoxtVerticalScrollBart _log_textt set_read_onlytshowtadvanced_buttontset_text(R ((s..\modules\db_copy_progress.pyt create_uis<cCsg|_|jdS(N(RDR (R ((s..\modules\db_copy_progress.pyt clear_taskss cCs t|S(N(RA(R R((s..\modules\db_copy_progress.pyRscCs||f|_dS(N(t_progress_info(R tpcttstatus((s..\modules\db_copy_progress.pytupdate_progressscCsP|j |_|jr)|jjdn|jjd|jj|jdS(Ns Hide Logss Show Logs(RIRnRoRgRm(R ((s..\modules\db_copy_progress.pyt go_advanceds   cCs t|_dS(N(R RK(R ((s..\modules\db_copy_progress.pyt go_cancelscCst|_t|_d|_d|_|jjt|jj d|j jt|j j d|j j d|jj d|jjt|j|r|jj dndS(NiRU(R.RKRGR,RrRER\RmR`t set_valueRaRcRdRoRbt next_buttonR0R t create_tasksRk(R t clear_log_box((s..\modules\db_copy_progress.pyR s     cCs|jj|||f|dkr|jr|jddd}|r]d||f}n d|}|jjd|dfntS( NtPROGRESSt:iis - %s: %s s- %s tOUTPUTRU(RHtappendRJtsplitR (R tmsg_typettexttdetailt progress_text((s..\modules\db_copy_progress.pyt_handle_task_outputs cCs|jS(N(RK(R ((s..\modules\db_copy_progress.pytquery_cancel_status+scCs|jjd|dfdS(NR~RU(RHR(R R ((s..\modules\db_copy_progress.pytsend_raw.scCs'tjd||jd|ddS(NRtINFORU(Rt log_debugR(R R ((s..\modules\db_copy_progress.pyR1scCs+tjdd||jd|ddS(NRsERROR: tERRORRU(RRR(R R ((s..\modules\db_copy_progress.pyR5scCs+tjdd||jd|ddS(NRs WARNING: tWARNINGRU(RRR(R R ((s..\modules\db_copy_progress.pyt send_warning9scCs*|jddtj||fddS(NR|s%s:%sRU(RtlocaleRA(R RsR ((s..\modules\db_copy_progress.pyt send_progress=scCsd|_d|_t|_g|_g|_d|_d|_|j j |j dk|j j |j jd|jjt|jjt|jjttj|jtj|j|jdtjjd|jdS(NiisKPlease wait while the selected schemas are copied. This may take some time.s Starting...g?(t _warningst_errorsR.RKt_task_warningst _task_errorsR,RrRER\RmRRRaRYRoRyR0t back_buttont cancel_buttonR Rtpush_status_query_handlerRtpush_message_handlerRRR=R>t add_timeoutt update_status(R ((s..\modules\db_copy_progress.pyR:@s"         cCs|j|jr|j\}}d|_|dkrO|jstt|_qtn%|jrdt|_n|jj||jj |n|j |j \}}|j j d||j |j|df|jjt||j |j rx|jrx|jr|jtSy|jWqxtk rt}|jd|j|f|jj d|j||jtSXn|jr|jtS|jr|jtS|js|j rg|_g|_ |j d7_ |j t!|j kr|j"tSntS(Nis,Copying %d of %d schemas. Current schema: %sisException in task '%s': %r s%s(#t_flush_messagesRrR,RFR R.RcRxRbRoRDRER^RRRPR`tfloatR$R+RKt _cancelledR!RRRRR'R(R*R&R"RRRQR%(R RsRt schema_idxttaskR;((s..\modules\db_copy_progress.pyRVsP                 cCsc|jdks|jdkr.|jdn|j|j|j|jdtjtj|jj t |j j t |j j t |_t|_|jjt|jjt|jjt |jjd|js|jn|jdkr#|jjdn<|jdkrE|jjdn|jj|jddS(NisETasks finished with warnings and/or errors, view the logs for detailss RUsIFinished. There were errors during execution, please review log messages.sFinished. There were warnings during execution, please review log messages. Click [Next >] to continue if you think they are not important.s Click [Next >] to continue.(RRRt final_messageRRtpop_message_handlertpop_status_query_handlerR\RmR.RaRctstopRFR RGRyR0RRRbRoRIRvRY(R ((s..\modules\db_copy_progress.pyR%s.         cCs|jd|j|jdtjtj|jjt|jjt|_ |j j t|j j t |jj t|jj|j|js|jndS(NtFaileds (RRRRRRcRmR.RRFRyR0RR RRdRotfailure_messageRIRv(R ((s..\modules\db_copy_progress.pyR's        cCs|jd|j|jdtjtj|jjt|jjt|_ |j j t|j j t |jj t|jjddS(Nt Cancelleds sCancelled by user.(RRRRRRcRmR.RRFRyR0RR RRdRo(R ((s..\modules\db_copy_progress.pyRs       cCs xt|jdkr|jj\}}}d|kr[ddj|jd}n|dkr|r|jjd||ftq|jjd|tq|dkr|r|jjd||ftq|jjd |tq|d kr_|jd \}}}y|j t j ||Wqt k r[t jd d |qXq|dkr|jd7_|jj|n.|dkr|jd7_|jj|n|r|jjd|||ftq|jjd||ftqWdS(Nis s Rs%s: %s s%s R~s%s: %ss%sR|R}RsUException raised when converting "%s" to float using locale.atof(). Exception ignoredRiRs %s: %s: %s (RQRHtpoplefttjoinRRktappend_text_and_scrollR t partitionRuRtatofRRRRRRRR(R tmtypeRRRsty((s..\modules\db_copy_progress.pyRs6         #cCsdS(sYSubclass and override to change the text message to be shown when tasks failed to finish.sA task has failed executing.((R ((s..\modules\db_copy_progress.pyRscCsdS(s\Subclass and override to change the text message to be shown when tasks finish successfully.sFinished performing tasks.((R ((s..\modules\db_copy_progress.pyRscCstjj}||_|jjjj}|j|jj j }|j|jj }d||f|_ ||_|jjj j j |dS(Ns%s.%s(Rtclassest GrtLogObjectt logObjectRCtplantmigrationTargett module_dbtquoteIdentifierRtnametstatetdataTransferLogR(R t target_tabletlogttarget_db_modulet logSchematlogTable((s..\modules\db_copy_progress.pytcreate_transfer_logs  cCs4x-|jjjjD]}||jkr|SqWdS(N(RCRRRR(R RR((s..\modules\db_copy_progress.pytget_log_objectscCsD|j|}tjj}||_||_|jj|dS(N(RRRt GrtLogEntryt entryTypeRtentriesR(R ttypeRtmessageRtentry((s..\modules\db_copy_progress.pyt add_log_entrys   c Csig|_d|jjjjd<|jjjj}|dkrXt|jjjj }n|jjj j}|dkr|jjj j j |jjjj j kr|jjj j j d|jjjj j dkr|}qqn|dkrt|jjj j }nt ||jjjj|jjjj ||jjj j ||_|jjj|j_xt|jjjjD]\}}|jj|dt|t|j|df|dt||jdf|dt||jdf|dt||jdf|dt||jdf|dt||jd f|dt||jd fgqxWdS( Nit LiveDataCopytuserNamesReverse Engineeringt MigratingsGenerating CodesCreating target schemasSelecting tables to copysCounting table rows to copysCopying table data(RDRCRRtdataBulkTransferParamstmigrationSourcetpasswordR,Rt connectionRthostIdentifiertparameterValuesRt _transferertwbcopytables_pathtcopytable_patht enumeratetselectedSchemataNamestextendRRt_rev_eng_schemaRt_migrate_schemat_fwd_eng_schemat_create_schemat _prepare_copyt _row_countt _data_copy(R tsource_passwordttarget_passwordtidxt schema_name((s..\modules\db_copy_progress.pyRzs2   *2 % %cCst|g|jjj_|jjjj|jjjjrpx0|jjjjj dj D]}d|_ qZWndS(NitInnoDB( RCRRRtreverseEngineerRMt innodb_switcht get_activetcatalogtschematattablest tableEngine(R Rttable((s..\modules\db_copy_progress.pyR>s #cCs|jjjdS(N(RCRtmigrate(R ((s..\modules\db_copy_progress.pyREscCs|jjjdS(N(RCRt generateSQL(R ((s..\modules\db_copy_progress.pyRHscCs'|jjjj|jjjdS(N(RCRRtconnectt createTarget(R ((s..\modules\db_copy_progress.pyRKsc Cs|jjjj}|jjjjjdj}|s8dS|jjjj}|jjjj}i|_x:|D]2}|j |j j }|j |j }|j |j j }|j |j } i|d6|d6|d6|d6| d6|d6|j|d||jj D]-}||j dd7}|j |dqUW|j d|jrld}|j dt |_t|_z|jj||j}Wdt|_t |_X|j d|j dd}x|jj D] }|j |d d |d d}|j dd}|rr|\} } n d} t } | r | |kr |d }d |d |d f} d| ||d|df} |jd| | |j d|d |d | |fq#|j d|d |d | |fq#W|j d||f|jjrytjdqyn |j ddS(NisData copy startingt row_countRRUisMigrating data...sData copy results:RRRis%s.%ss+Succeeded : copied %s of %s rows from %s.%sRRs,- %s.%s has succeeded (%s of %s rows copied)s)- %s.%s has FAILED (%s of %s rows copied)s!%i tables of %i were fully copiedsCanceled by usersNothing to be done(RCRRRRRRRQRtvaluesRRRR.RJR t_migrating_dataRt migrate_dataR,Rt interruptedRR( R Rt table_countRt thread_counttsucceeded_taskst fully_copiedtinfoRtoktcountRR((s..\modules\db_copy_progress.pyRxsN         " () (&R1R2R.RRSRpRqRRuRvRwR RRRRRRRR:RR%R'RRRRRRRRzRRRRRRR(((s..\modules\db_copy_progress.pyRBsF  *              7   "        ! (RR7t collectionsRt functoolsRRR=t workbench.uiRRtmigration_source_selectionRRtobjectRRRB(((s..\modules\db_copy_progress.pyts    W5