@Qc@s~ddlZddlZddlmZddlmZdefdYZdefdYZdefd YZ dS( iN(tdb_utils(treplace_string_parameterstMigrationTargetcBseZdZdZdZeeeZdZdZeeeZ dZ ee Z dZ dZ dZd Zd Zd Zd Zd ZdZRS(cCs,||_d|_d|_|j|dS(N(tstatetNonet_rdbmstpasswordt_set_connection(tselfRt connection((s..\modules\migration.pyt__init__s   cCs|jS(N(R(R((s..\modules\migration.pyt _get_rdbms scCs2|jdkr%td|jn||_dS(NtMysqlsUnsupported target RDBMS "%s"(tnamet ValueErrorR(Rtrdbms((s..\modules\migration.pyt _set_rdbms"scCs |jjS(N(Rt targetCatalog(R((s..\modules\migration.pyt _get_catalog)scCs||j_dS(N(RR(Rtcatalog((s..\modules\migration.pyt _set_catalog+scCs |jjS(N(RttargetConnection(R((s..\modules\migration.pyt_get_connection0scCsE|j s|jj r&tdn||j_|jj|_dS(NsInvalid connection object(tdrivertownerRRRR(RR ((s..\modules\migration.pyR5s cCs&|jj|j|jpdtS(Nt(t module_fetconnectR RtTrue(R((s..\modules\migration.pytcheckConnection;s"cCs|jj|j|j_tjj|j_|jjj |jj_ |jjj |jj_ |jjj |jj_ |jjj |jj_ dS(N( RtgetServerVersionR RttargetDBVersiontgrttclassest GrtVersiont targetVersionR t majorNumbert minorNumbert releaseNumber(R((s..\modules\migration.pyt checkVersion?s cCs"tjjj|j|jpdS(NR(R tmodulest DbMySQLFERR R(R((s..\modules\migration.pyRHscCstjjj|jS(N(R R(R)t disconnectR (R((s..\modules\migration.pyR*KscCs tjjS(N(R R(R)(R((s..\modules\migration.pyRNscCs tjjS(N(R R(t DbMySQLRE(R((s..\modules\migration.pyt module_reQscCs tjjS(N(R R(tDbMySQLMigration(R((s..\modules\migration.pytmodule_migrationTscCs tjjS(N(R R(tDbMySQL(R((s..\modules\migration.pyt module_dbWs(t__name__t __module__R R RtpropertyRRRRRR RRR'RR*RR,R.R0(((s..\modules\migration.pyRs$              tMigrationSourcecBseZdZdZdZeeeZdZeeZdZ dZ ee e Z dZ dZ ee e ZdZd ZeeeZd Zd ZeeeZd Zd ZdZdZdZdZdZdZdZedZgdZedZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(RS( cCsY||_d|_d|_d|_d|_d|_d|_d|_|j |dS(N( RRRt_rev_eng_modulet_migration_modulet _db_modulet _catalog_nameRt migrationR(RRR ((s..\modules\migration.pyR \s        cCs|jS(N(R(R((s..\modules\migration.pyR iscCsF||_d|_d|_d|_xttjD]}ttj|}t |d s4|j |j krwq4n|j }|j drt |dr||_n|j drt |dr||_n|j dr4t |dr4||_q4q4W|j s |j s |j r6td|j n|j|_dS(NtgetTargetDBMSNametDbtreverseEngineertmigrateCatalogtfullyQualifiedObjectNamesSource RDBMS "%s" not supported(RRR5R7R6tdirR R(tgetattrthasattrR:R R1t startswithRR9(RRtmnametmodR ((s..\modules\migration.pyRks$    %   cCs |jjS(N(Rt sourceCatalog(R((s..\modules\migration.pyRscCs |jjS(N(RtsourceConnection(R((s..\modules\migration.pyRscCsI|j s|jj r&tdn||j_|j|jjdS(NsInvalid connection object(RRRRRFR(RR ((s..\modules\migration.pyRs cCs |jjS(N(RtselectedSchemataNames(R((s..\modules\migration.pyt_get_selected_schematascCs8|jjjx!|D]}|jjj|qWdS(N(RRGt remove_alltappend(RtnamesR ((s..\modules\migration.pyt_set_selected_schematas cCs ||_dS(N(R8(RR ((s..\modules\migration.pyt_set_selected_catalogscCs|jS(N(R8(R((s..\modules\migration.pyt_get_selected_catalogscCs |jjS(N(Rt ignoreList(R((s..\modules\migration.pyt_get_ignore_listscCs||j_dS(N(RRO(Rtilist((s..\modules\migration.pyt_set_ignore_listscCs|jj|j|jpdS(NR(R5RR R(R((s..\modules\migration.pyRscCs|jj|jS(N(R5R*R (R((s..\modules\migration.pyR*scCs"|jj|j|j_dS(N(R,RR RtsourceDBVersion(R((s..\modules\migration.pyR'scCs|jj|jS(N(R5tgetCatalogNamesR (R((s..\modules\migration.pyRTscCs|jj|j|pdS(NR(R5tgetSchemaNamesR (RR((s..\modules\migration.pyRUscCs|jj|j|pd|S(NR(R5t getTableNamesR (RRtschema((s..\modules\migration.pyRVscCs|jS(N(R5(R((s..\modules\migration.pyR,scCs|jS(N(R6(R((s..\modules\migration.pyR.scCs|jS(N(R7(R((s..\modules\migration.pyR0scCs |jjS(N(RtsourceSchemataNames(R((s..\modules\migration.pyt schemaNamessc CsQtjdd|j|jjrltjdd|jjj|j}|rt |j |}|rtj ddj t |nt t |j |p|j}n||_tjddd}d}dt|d }xA|D]e}tj|d ||j|}x+|D]#} |jjjd || fq0W|d |7}qWntjdd|jd }|rt |j |} | rtj ddj t | nt t |j | p|jd }ng|_|jjjx%|D]} |jjjd| qWtjdddS(smFetch list of schema names in catalog.schema format and stores them in the migration.sourceSchemataNames nodegsChecking connection...g?sFetching catalog names...s(The following catalogs where not found: s, sFetching schema names...g?g|=s Fetching schema names from %s...s%s.%sg?Rs(The following schemata where not found: sdef.%stFinishedN(R t send_progressRRtdoesSupportCatalogsRRXRIRTtsett differencet send_warningtjointlistt_catalog_namestlenRURJ( Rtonly_these_catalogst catalog_namestinexistent_catalogstitaccumulated_progresststep_progress_shareRt schema_namesRWtinexistent_schemata((s..\modules\migration.pytdoFetchSchemaNamessD   #*   !#-  c Cst|jdr*t|jj}ndddddddg}|d }xn|dD]b}|d}xO|jjD]A}t||t}|rwt|dkrw|j |PqwqwWqZW|S( NtgetSupportedObjectTypesttablessdb.TabletTablestviewssdb.ViewtViewstroutiness db.RoutinetRoutinest routineGroupssdb.RoutineGroupsRoutine Groupstsynonymss db.SynonymtSynonymststructuredTypessdb.StructuredTypesStructured Typest sequencess db.Sequencet Sequencesii(Rnsdb.TableRo(Rpsdb.ViewRq(Rrs db.RoutineRs(Rtsdb.RoutineGroupsRoutine Groups(Rus db.SynonymRv(Rwsdb.StructuredTypesStructured Types(Rxs db.SequenceRy( RAR5RaRmRtschemataR@tFalseRcRJ(RtallTypest supportedtitemttRWtobjects((s..\modules\migration.pytsupportedObjectTypess$     cCs[g}xN|jjD]@}t||}x(|D] }|jd|j|jq/WqW|S(Ns%s.%s(RRzR@RJR (RtotypetlRWRtobj((s..\modules\migration.pytallObjectsOfTypes  "cCsRg}xE|jD]:}|jd\}}}||kr|j|qqW|S(Nt:(ROtsplitRJ(RRRt ignore_specRtsepR((s..\modules\migration.pytavailableObjectsOfTypes  cCsg}x||jjD]n}t||}xV|D]N}d||j|jf}||jkr/|jd|j|jfq/q/WqW|S(Ns%s:%s.%ss%s.%s(RRzR@R RORJ(RRRRWRRR((s..\modules\migration.pytselectedObjectsOfType$s (cCs|xJttt|jD]-}|j|j|dr|j|=qqWx(|D] }|jjd||fqTWdS(NRs%s:%s(treversedtrangeRcRORBRJ(RRtiglistRgR~((s..\modules\migration.pytsetIgnoredObjectsOfType/s " cCsnxJttt|jD]-}|j|j|dr|j|=qqW|rj|jjd|ndS(NRs%s:*(RRRcRORBRJ(RRtflagRg((s..\modules\migration.pytsetIgnoreObjectType7s "cCsd||jkS(Ns%s:*(RO(RR((s..\modules\migration.pytisObjectTypeIgnored?scCs@d||jks8d||jj|jf|jkr<tStS(Ns%s:*s%s:%s.%s(RORR RR{(RRR((s..\modules\migration.pytisObjectIgnoredBs8cCsd|jtjddj|j|jf|jj|j|j|j|j j |j _ dS(sUPerform reverse engineering of selected schemas into the migration.sourceCatalog nodesReverse engineering %s from %ss, N( RR t send_infoR`RGtselectedCatalogNameR5R<R RtapplicationDataRE(R((s..\modules\migration.pyR<Gs &()R1R2R R RR3RRRRRR RHRLRGRMRNRRPRRRORR*R'RTRURVR,R.R0RYRlRRRRRRRRR<(((s..\modules\migration.pyR4[sL                      (      t MigrationPlancBseZdZdZedZedZedZdZdZ e dZ e dZ d Z d Zd Zd ZRS( cCs0tjjj|_|jstjj|_tjj|j_|jtjj_tj j j }|d}ddl }|j j|r|jjjtj|qtj j jd}|d7}|j j|r|jjjtj|qnd|_d|_ddl}|jdkrNtj j jd|_n|jdkr{tj j jd|_ntj j jd|_|j j|js|j j|j jtjjjjd|_n|j j|jsd|_nt|jtkr,|jj d |_ndS( Ns/migration_generic_typemap.xmliRs+/modules/data/migration_generic_typemap.xmltwin32swbcopytables.exetdarwint wbcopytablessUTF-8(!R troottwbR9RR!tdb_migration_MigrationRtmformstApptgettget_user_data_foldertostpathtexiststgenericDatatypeMappingstextendt unserializetget_resource_pathRtmigrationSourcetmigrationTargettsystplatformtget_executable_pathtwbcopytables_pathR`tdirnametregistrytappExecutablePathttypetunicodetencode(RtdatadirRRt global_pathR((s..\modules\migration.pyR Rs8    "   3 cCs:d|j_dtjj_d|_d|_d|_dS(N( RRRR RRR9RR(R((s..\modules\migration.pytcloseus    cCsWd}d}d}xttjD]}ttj|}t|d s"|j|jkreq"n|j}|j drt|dr|}n|j drt|dr|}n|j dr"t|dr"|}q"q"W|stj dd|jn|s'tj dd|jn|sGtj dd |jn|oV|oV|S( NR:R;R<R=R>t MigrationsGRDBMS %s cannot be a migration source because it's missing a RE module sNRDBMS %s cannot be a migration source because it's missing a Migration module sSRDBMS %s cannot be a migration source because it's missing a Db information module ( RR?R R(R@RAR:R R1RBt log_debug2(Rtrev_eng_moduletmigration_modulet db_moduleRCRDR ((s..\modules\migration.pytis_rdbms_migratable}s*%    cCsFg}x9tjjjjD]%}tj|r|j|qqW|S(N(R RRt rdbmsMgmtRRRRJ(tsourcesR((s..\modules\migration.pytsupportedSourcess cCstjjjjdS(Ni(R RRRR(((s..\modules\migration.pytsupportedTargetsscCs1|jr||j_nt|j||_dS(N(RR R4R(RR ((s..\modules\migration.pytsetSourceConnections cCs+t|j||_|jj|j_dS(N(RRRRRR(RR ((s..\modules\migration.pytsetTargetConnectionscCs |jjS(N(RR(R((s..\modules\migration.pyRscCs |jjS(N(RRE(R((s..\modules\migration.pyREscCsA|jjj|jjj|j|jj|j_i}|S(N(Rt migrationLogRIRR9R=RR(Rtreport((s..\modules\migration.pytmigrates'cCs<tjjj|jj|jj|jjidd6}|S(NiRz( R R(R)tgenerateSQLCreateStatementsRRRR#tobjectCreationParams(RR((s..\modules\migration.pyt generateSQLs+ cCs)tjjj||jj|jjdS(N(R R(R)tcreateScriptForCatalogObjectsRRRR(RR((s..\modules\migration.pytcreateTargetScriptscCsD|jjjtjjj|jj|jj |jj |jjS(N( Rt creationLogRIR R(R)tcreateCatalogObjectsRR RR(R((s..\modules\migration.pyt createTargets(R1R2R Rt staticmethodRRRRRR3RRERRRR(((s..\modules\migration.pyRPs #     ( R Rt workbenchRtworkbench.utilsRtobjectRR4R(((s..\modules\migration.pyts  C