<s> import os <EOL> import sys <EOL> from collections import deque <EOL> import string <EOL> import argparse <EOL> import cStringIO <EOL> import operator <EOL> import cPickle as pickle <EOL> from collections import deque <EOL> import math <EOL> import re <EOL> import cmd <EOL> import readline <EOL> try : <EOL> from gluon import DAL <EOL> except ImportError as err : <EOL> print ( '<STR_LIT>' ) <EOL> class refTable ( object ) : <EOL> def __init__ ( self ) : <EOL> self . columns = None <EOL> self . rows = None <EOL> def getcolHeader ( self , colHeader ) : <EOL> return "<STR_LIT>" . format ( '<STR_LIT>' . join ( [ string . join ( string . strip ( '<STR_LIT>' . format ( item ) ) , <EOL> '<STR_LIT>' ) for item in colHeader ] ) ) <EOL> def wrapTable ( <EOL> self , rows , hasHeader = False , headerChar = '<STR_LIT:->' , delim = '<STR_LIT>' , justify = '<STR_LIT:left>' , <EOL> separateRows = False , prefix = '<STR_LIT>' , postfix = '<STR_LIT>' , wrapfunc = lambda x : x ) : <EOL> def rowWrapper ( row ) : <EOL> '''<STR_LIT>''' <EOL> newRows = [ wrapfunc ( item ) . split ( '<STR_LIT:\n>' ) for item in row ] <EOL> self . rows = newRows <EOL> '''<STR_LIT>''' <EOL> rowList = [ [ substr or '<STR_LIT>' for substr in item ] <EOL> for item in map ( None , * newRows ) ] <EOL> return rowList <EOL> logicalRows = [ rowWrapper ( row ) for row in rows ] <EOL> columns = map ( None , * reduce ( operator . add , logicalRows ) ) <EOL> self . columns = columns <EOL> maxWidths = [ max ( <EOL> [ len ( str <EOL> ( item ) ) for <EOL> item in column ] <EOL> ) for column <EOL> in columns ] <EOL> rowSeparator = headerChar * ( len ( prefix ) + len ( postfix ) + sum ( maxWidths ) + <EOL> len ( delim ) * ( len ( maxWidths ) - <NUM_LIT:1> ) ) <EOL> justify = { '<STR_LIT>' : str <EOL> . center , <EOL> '<STR_LIT:right>' : str <EOL> . rjust , <EOL> '<STR_LIT:left>' : str . <EOL> ljust <EOL> } [ justify <EOL> . lower ( <EOL> ) ] <EOL> output = cStringIO . StringIO ( ) <EOL> if separateRows : <EOL> print >> output , rowSeparator <EOL> for physicalRows in logicalRows : <EOL> for row in physicalRows : <EOL> print >> output , prefix + delim . join ( [ <EOL> justify ( str ( item ) , width ) for ( <EOL> item , width ) in zip ( row , maxWidths ) ] <EOL> ) + postfix <EOL> if separateRows or hasHeader : <EOL> print >> output , rowSeparator <EOL> hasHeader = False <EOL> return output . getvalue ( ) <EOL> def wrap_onspace ( self , text , width ) : <EOL> return reduce ( lambda line , word , width = width : '<STR_LIT>' <EOL> . format ( line , '<STR_LIT>' [ ( len ( <EOL> line [ line . rfind ( '<STR_LIT:\n>' <EOL> ) + <NUM_LIT:1> : ] ) + len ( <EOL> word . split ( '<STR_LIT:\n>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] ) >= <EOL> width ) ] , word ) , text . split ( '<STR_LIT:U+0020>' ) ) <EOL> def wrap_onspace_strict ( self , text , width ) : <EOL> wordRegex = re . compile ( r'<STR_LIT>' + str ( width ) + r'<STR_LIT>' ) <EOL> return self . wrap_onspace ( <EOL> wordRegex . sub ( <EOL> lambda m : self . <EOL> wrap_always ( <EOL> m . group ( ) , width ) , text <EOL> ) , width ) <EOL> def wrap_always ( self , text , width ) : <EOL> return '<STR_LIT:\n>' . join ( <EOL> [ text [ width * i : width * ( i + <NUM_LIT:1> <EOL> ) ] for i in xrange ( <EOL> int ( math . ceil ( <NUM_LIT:1.> * len ( <EOL> text ) / width ) ) ) ] ) <EOL> class tableHelper ( ) : <EOL> def __init__ ( self ) : <EOL> self . oTable = refTable ( ) <EOL> def getAsRows ( self , data ) : <EOL> return [ row . strip ( ) . split ( '<STR_LIT:U+002C>' ) for row in data . splitlines ( ) ] <EOL> def getTable_noWrap ( self , data , header = None ) : <EOL> rows = self . getAsRows ( data ) <EOL> if header is not None : <EOL> hRows = [ header ] + rows <EOL> else : <EOL> hRows = rows <EOL> table = self . oTable . wrapTable ( hRows , hasHeader = True ) <EOL> return table <EOL> def getTable_Wrap ( self , data , wrapStyle , header = None , width = <NUM_LIT> ) : <EOL> wrapper = None <EOL> if len ( wrapStyle ) > <NUM_LIT:1> : <EOL> rows = self . getAsRows ( data ) <EOL> if header is not None : <EOL> hRows = [ header ] + rows <EOL> else : <EOL> hRows = rows <EOL> for wrapper in ( self . oTable . wrap_always , <EOL> self . oTable . wrap_onspace , <EOL> self . oTable . wrap_onspace_strict ) : <EOL> return self . oTable . wrapTable ( hRows , hasHeader = True , separateRows = True , prefix = '<STR_LIT>' , postfix = '<STR_LIT>' , wrapfunc = lambda x : <EOL> wrapper ( x , width ) ) <EOL> else : <EOL> return self . getTable_noWrap ( data , header ) <EOL> def getAsErrorTable ( self , err ) : <EOL> return self . getTable_Wrap ( err , None ) <EOL> class console : <EOL> def __init__ ( self , prompt , banner = None ) : <EOL> self . prompt = prompt <EOL> self . banner = banner <EOL> self . commands = { } <EOL> self . commandSort = [ ] <EOL> self . db = None <EOL> for i in dir ( self ) : <EOL> if "<STR_LIT>" == i [ : <NUM_LIT:4> ] : <EOL> cmd = i . split ( "<STR_LIT>" ) [ <NUM_LIT:1> ] . lower ( ) <EOL> self . commands [ cmd ] = getattr ( self , i ) <EOL> try : <EOL> self . commandSort . append ( ( int ( self <EOL> . commands [ cmd ] . __doc__ . split ( <EOL> "<STR_LIT:|>" ) [ <NUM_LIT:0> ] ) , cmd ) ) <EOL> except : <EOL> pass <EOL> self . commandSort . sort ( ) <EOL> self . commandSort = [ i [ <NUM_LIT:1> ] for i in self . commandSort ] <EOL> self . var_DEBUG = False <EOL> self . var_tableStyle = '<STR_LIT>' <EOL> self . configvars = { } <EOL> for i in dir ( self ) : <EOL> if "<STR_LIT>" == i [ : <NUM_LIT:4> ] : <EOL> var = i . split ( "<STR_LIT>" ) [ <NUM_LIT:1> ] <EOL> self . configvars [ var ] = i <EOL> def setBanner ( self , banner ) : <EOL> self . banner = banner <EOL> def execCmd ( self , db ) : <EOL> self . db = db <EOL> print self . banner <EOL> while True : <EOL> try : <EOL> command = raw_input ( self . prompt ) <EOL> try : <EOL> self . execCommand ( command ) <EOL> except : <EOL> self . execute ( command ) <EOL> except KeyboardInterrupt : <EOL> break <EOL> except EOFError : <EOL> break <EOL> except Exception , a : <EOL> self . printError ( a ) <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def printError ( self , err ) : <EOL> sys . stderr . write ( "<STR_LIT>" . format ( str ( err ) , ) ) <EOL> if self . var_DEBUG : <EOL> pass <EOL> def execute ( self , cmd ) : <EOL> try : <EOL> if not '<STR_LIT>' in cmd : <EOL> exec '<STR_LIT>' . format ( cmd ) <EOL> else : <EOL> file = None <EOL> table = None <EOL> fields = [ ] <EOL> items = string . split ( cmd , '<STR_LIT:U+0020>' ) <EOL> invalidParams = [ ] <EOL> table = self . getTable ( items [ <NUM_LIT:1> ] ) <EOL> allowedParams = [ '<STR_LIT>' , '<STR_LIT:file>' ] <EOL> for i in items : <EOL> if '<STR_LIT:=>' in i and not string . split ( i , '<STR_LIT:=>' ) [ <NUM_LIT:0> ] in allowedParams : <EOL> try : <EOL> invalidParams . append ( i ) <EOL> except Exception , err : <EOL> raise Exception ( '<STR_LIT>' . format ( i ) ) <EOL> else : <EOL> if '<STR_LIT>' in i : <EOL> file = os . path . abspath ( string . strip ( string . split ( <EOL> i , '<STR_LIT:=>' ) [ <NUM_LIT:1> ] ) ) <EOL> if '<STR_LIT>' in i : <EOL> for field in string . split ( string . split ( i , '<STR_LIT:=>' ) [ <NUM_LIT:1> ] , '<STR_LIT:U+002C>' ) : <EOL> if field in self . db [ table ] . fields : <EOL> fields . append ( string . strip ( field ) ) <EOL> if len ( invalidParams ) > <NUM_LIT:0> : <EOL> print ( '<STR_LIT>' . format ( <EOL> string . join ( invalidParams , '<STR_LIT:U+002C>' ) ) ) <EOL> else : <EOL> try : <EOL> self . cmd_table ( table , file , fields ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' <EOL> . format ( table , err ) ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> def getTable ( self , tbl ) : <EOL> for mTbl in db . tables : <EOL> if tbl in mTbl : <EOL> if mTbl . startswith ( tbl ) : <EOL> return mTbl <EOL> def execCommand ( self , cmd ) : <EOL> words = cmd . split ( "<STR_LIT:U+0020>" ) <EOL> words = [ i for i in words if i ] <EOL> if not words : <EOL> return <EOL> cmd , parameters = words [ <NUM_LIT:0> ] . lower ( ) , words [ <NUM_LIT:1> : ] <EOL> if not cmd in self . commands : <EOL> raise Exception ( <EOL> "<STR_LIT>" . format ( cmd ) ) <EOL> self . commands [ cmd ] ( * parameters ) <EOL> '''<STR_LIT>''' <EOL> def cmd_clear ( self , numlines = <NUM_LIT:100> ) : <EOL> """<STR_LIT>""" <EOL> if os . name == "<STR_LIT>" : <EOL> '''<STR_LIT>''' <EOL> os . system ( '<STR_LIT>' ) <EOL> elif os . name in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> os . system ( '<STR_LIT>' ) <EOL> else : <EOL> '''<STR_LIT>''' <EOL> print '<STR_LIT:\n>' * numlines <EOL> def cmd_table ( self , tbl , file = None , fields = [ ] ) : <EOL> """<STR_LIT>""" <EOL> table = None <EOL> for mTbl in db . tables : <EOL> if tbl in mTbl : <EOL> if mTbl . startswith ( tbl ) : <EOL> table = mTbl <EOL> break <EOL> oTable = tableHelper ( ) <EOL> '''<STR_LIT>''' <EOL> tableStyle = self . var_tableStyle <EOL> filedNotFound = [ ] <EOL> table_fields = None <EOL> if len ( fields ) == <NUM_LIT:0> : <EOL> table_fields = self . db [ table ] . fields <EOL> else : <EOL> table_fields = fields <EOL> for field in fields : <EOL> if not field in self . db [ table ] . fields : <EOL> filedNotFound . append ( field ) <EOL> if len ( filedNotFound ) == <NUM_LIT:0> : <EOL> rows = self . db ( self . db [ table ] . id > <NUM_LIT:0> ) . select ( ) <EOL> rows_data = [ ] <EOL> for row in rows : <EOL> rowdata = [ ] <EOL> for f in table_fields : <EOL> rowdata . append ( '<STR_LIT>' . format ( row [ f ] ) ) <EOL> rows_data . append ( string . join ( rowdata , '<STR_LIT:U+002C>' ) ) <EOL> data = string . join ( rows_data , '<STR_LIT:\n>' ) <EOL> dataTable = oTable . getTable_Wrap ( data , tableStyle , table_fields ) <EOL> print ( '<STR_LIT>' . format ( table , dataTable ) ) <EOL> if file is not None : <EOL> try : <EOL> tail , head = os . path . split ( file ) <EOL> try : <EOL> os . makedirs ( tail ) <EOL> except : <EOL> '<STR_LIT>' <EOL> oFile = open ( file , '<STR_LIT:w>' ) <EOL> oFile . write ( '<STR_LIT>' . format ( table , dataTable ) ) <EOL> oFile . close ( ) <EOL> print ( '<STR_LIT>' . format ( file , table ) ) <EOL> except Exception , err : <EOL> print ( "<STR_LIT>" . format ( <EOL> table , err ) ) <EOL> else : <EOL> print ( '<STR_LIT>' . format ( <EOL> string . join ( filedNotFound , '<STR_LIT:U+002C>' ) ) ) <EOL> def cmd_help ( self , * args ) : <EOL> '''<STR_LIT>''' <EOL> alldata = [ ] <EOL> lengths = [ ] <EOL> for i in self . commandSort : <EOL> alldata . append ( <EOL> self . commands [ i ] . __doc__ . split ( "<STR_LIT:|>" ) [ <NUM_LIT:1> : ] ) <EOL> for i in alldata : <EOL> if len ( i ) > len ( lengths ) : <EOL> for j in range ( len ( i ) <EOL> - len ( lengths ) ) : <EOL> lengths . append ( <NUM_LIT:0> ) <EOL> j = <NUM_LIT:0> <EOL> while j < len ( i ) : <EOL> if len ( i [ j ] ) > lengths [ j ] : <EOL> lengths [ j ] = len ( i [ j ] ) <EOL> j += <NUM_LIT:1> <EOL> print ( "<STR_LIT:->" * ( lengths [ <NUM_LIT:0> ] + lengths [ <NUM_LIT:1> ] + <NUM_LIT:4> ) ) <EOL> for i in alldata : <EOL> print ( ( "<STR_LIT>" + str ( lengths [ <NUM_LIT:0> ] ) + "<STR_LIT>" + str ( <EOL> lengths [ <NUM_LIT:1> ] ) + "<STR_LIT:s>" ) % ( i [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] ) ) <EOL> if len ( i ) > <NUM_LIT:2> : <EOL> for j in i [ <NUM_LIT:2> : ] : print ( ( "<STR_LIT:%>" + str ( lengths [ <EOL> <NUM_LIT:0> ] + <NUM_LIT:9> ) + "<STR_LIT>" ) % ( "<STR_LIT:U+0020>" , j ) ) <EOL> print <EOL> def cmd_vars ( self , * args ) : <EOL> '''<STR_LIT>''' <EOL> print ( "<STR_LIT>" + "<STR_LIT:->" * <NUM_LIT> ) <EOL> for i , j in self . configvars . items ( ) : <EOL> value = self . parfmt ( repr ( getattr ( self , j ) ) , <NUM_LIT> ) <EOL> print ( "<STR_LIT>" % ( i , value [ <NUM_LIT:0> ] ) ) <EOL> for k in value [ <NUM_LIT:1> : ] : print ( "<STR_LIT>" % ( "<STR_LIT>" , k ) ) <EOL> if len ( value ) > <NUM_LIT:1> : <EOL> print ( "<STR_LIT>" % ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> print ( "<STR_LIT:->" * <NUM_LIT> ) <EOL> def parfmt ( self , txt , width ) : <EOL> res = [ ] <EOL> pos = <NUM_LIT:0> <EOL> while True : <EOL> a = txt [ pos : pos + width ] <EOL> if not a : <EOL> break <EOL> res . append ( a ) <EOL> pos += width <EOL> return res <EOL> def cmd_set ( self , * args ) : <EOL> '''<STR_LIT>''' <EOL> value = "<STR_LIT:U+0020>" . join ( args [ <NUM_LIT:1> : ] ) <EOL> if args [ <NUM_LIT:0> ] not in self . configvars : <EOL> setattr ( self , "<STR_LIT>" . format ( args [ <NUM_LIT:0> ] ) , eval ( value ) ) <EOL> setattr ( self , "<STR_LIT>" . format ( args [ <NUM_LIT:0> ] ) , eval ( value ) ) <EOL> def cmd_clearscreen ( self , numlines = <NUM_LIT:50> ) : <EOL> '''<STR_LIT>''' <EOL> if os . name == "<STR_LIT>" : <EOL> '''<STR_LIT>''' <EOL> os . system ( '<STR_LIT>' ) <EOL> elif os . name in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> os . system ( '<STR_LIT>' ) <EOL> else : <EOL> '''<STR_LIT>''' <EOL> print '<STR_LIT:\n>' * numlines <EOL> class dalShell ( console ) : <EOL> def __init__ ( self ) : <EOL> pass <EOL> def shell ( self , db ) : <EOL> console . __init__ ( self , prompt = "<STR_LIT>" , banner = '<STR_LIT>' ) <EOL> self . execCmd ( db ) <EOL> class setCopyDB ( ) : <EOL> def __init__ ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . strModel = None <EOL> self . dalPath = None <EOL> self . db = None <EOL> '''<STR_LIT>''' <EOL> self . sourceModel = None <EOL> self . sourceFolder = None <EOL> self . sourceConnectionString = None <EOL> self . sourcedbType = None <EOL> self . sourcedbName = None <EOL> '''<STR_LIT>''' <EOL> self . targetdbType = None <EOL> self . targetdbName = None <EOL> self . targetModel = None <EOL> self . targetFolder = None <EOL> self . targetConnectionString = None <EOL> self . truncate = False <EOL> def _getDal ( self ) : <EOL> mDal = None <EOL> if self . dalPath is not None : <EOL> global DAL <EOL> sys . path . append ( self . dalPath ) <EOL> mDal = __import__ ( <EOL> '<STR_LIT>' , globals = { } , locals = { } , fromlist = [ '<STR_LIT>' ] , level = <NUM_LIT:0> ) <EOL> DAL = mDal . DAL <EOL> return mDal <EOL> def instDB ( self , storageFolder , storageConnectionString , autoImport ) : <EOL> self . db = DAL ( storageConnectionString , folder = os . path . abspath ( <EOL> storageFolder ) , auto_import = autoImport ) <EOL> return self . db <EOL> def delete_DB_tables ( self , storageFolder , storageType ) : <EOL> print '<STR_LIT>' . format ( <EOL> storageFolder , storageType ) <EOL> dataFiles = [ storageType , "<STR_LIT>" ] <EOL> try : <EOL> for f in os . listdir ( storageFolder ) : <EOL> if "<STR_LIT>" in f : <EOL> fTable = "<STR_LIT>" . format ( storageFolder , f ) <EOL> os . remove ( fTable ) <EOL> print ( '<STR_LIT>' . format ( fTable ) ) <EOL> for dFile in dataFiles : <EOL> os . remove ( "<STR_LIT>" . format ( storageFolder , dFile ) ) <EOL> print ( '<STR_LIT>' . format ( <EOL> "<STR_LIT>" . format ( storageFolder , dFile ) ) ) <EOL> except Exception , errObj : <EOL> print ( str ( errObj ) ) <EOL> def truncatetables ( self , tables = [ ] ) : <EOL> if len ( tables ) != <NUM_LIT:0> : <EOL> try : <EOL> print '<STR_LIT>' . format ( tables ) <EOL> for tbl in self . db . tables : <EOL> for mTbl in tables : <EOL> if mTbl . startswith ( tbl ) : <EOL> self . db [ mTbl ] . truncate ( ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> else : <EOL> try : <EOL> for tbl in self . db . tables : <EOL> self . db [ tbl ] . truncate ( ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> def copyDB ( self ) : <EOL> other_db = DAL ( "<STR_LIT>" . format ( <EOL> self . targetdbType , self . targetdbName ) , folder = self . targetFolder ) <EOL> print '<STR_LIT>' <EOL> for table in self . db : <EOL> other_db . define_table ( <EOL> table . _tablename , * [ field for field in table ] ) <EOL> '''<STR_LIT>''' <EOL> print '<STR_LIT>' <EOL> self . db . export_to_csv_file ( open ( '<STR_LIT>' , '<STR_LIT:wb>' ) ) <EOL> print '<STR_LIT>' <EOL> other_db . import_from_csv_file ( open ( '<STR_LIT>' , '<STR_LIT:rb>' ) ) <EOL> other_db . commit ( ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> def createfolderPath ( self , folder ) : <EOL> try : <EOL> if folder is not None : <EOL> os . makedirs ( folder ) <EOL> except Exception , err : <EOL> pass <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> oCopy = setCopyDB ( ) <EOL> db = None <EOL> targetDB = None <EOL> dbfolder = None <EOL> clean = False <EOL> model = None <EOL> truncate = False <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' , <EOL> epilog = '<STR_LIT>' ) <EOL> reqGroup = parser . add_argument_group ( '<STR_LIT>' ) <EOL> reqGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = True , help = "<STR_LIT>" ) <EOL> reqGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = False , help = "<STR_LIT>" ) <EOL> reqGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = True , help = "<STR_LIT>" ) <EOL> reqGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = True , <EOL> help = "<STR_LIT>" ) <EOL> autoImpGroup = parser . add_argument_group ( '<STR_LIT>' ) <EOL> autoImpGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = False , help = '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> miscGroup = parser . add_argument_group ( '<STR_LIT>' ) <EOL> miscGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = False , action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> miscGroup . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , required = False , help = '<STR_LIT>' ) <EOL> miscGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , choices = [ '<STR_LIT:True>' , '<STR_LIT:False>' ] , help = '<STR_LIT>' ) <EOL> miscGroup . add_argument ( '<STR_LIT>' , '<STR_LIT>' , required = False , type = list , help = '<STR_LIT>' ) <EOL> miscGroup . add_argument ( '<STR_LIT:-c>' , '<STR_LIT>' , required = False , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> db = None <EOL> mDal = None <EOL> try : <EOL> oCopy . sourceFolder = args . sourceFolder <EOL> oCopy . targetFolder = args . sourceFolder <EOL> sourceItems = string . split ( args . sourceConnectionString , '<STR_LIT>' ) <EOL> oCopy . sourcedbType = sourceItems [ <NUM_LIT:0> ] <EOL> oCopy . sourcedbName = sourceItems [ <NUM_LIT:1> ] <EOL> targetItems = string . split ( args . targetConnectionString , '<STR_LIT>' ) <EOL> oCopy . targetdbType = targetItems [ <NUM_LIT:0> ] <EOL> oCopy . targetdbName = targetItems [ <NUM_LIT:1> ] <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> if args . dal : <EOL> try : <EOL> autoImport = True <EOL> if args . autoimport : <EOL> autoImport = args . autoimport <EOL> oCopy . dalPath = args . dal <EOL> mDal = oCopy . _getDal ( ) <EOL> db = oCopy . instDB ( args . sourceFolder , args . sourceConnectionString , <EOL> autoImport ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> if args . truncate : <EOL> try : <EOL> if args . truncate : <EOL> if args . tables : <EOL> tables = string . split ( string . strip ( args . tables ) , '<STR_LIT:U+002C>' ) <EOL> else : <EOL> oCopy . truncatetables ( [ ] ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> try : <EOL> if args . clean : <EOL> oCopy . delete_DB_tables ( oCopy . targetFolder , oCopy . targetType ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> """<STR_LIT>""" <EOL> if args . sourceFolder : <EOL> try : <EOL> oCopy . sourceFolder = os . path . abspath ( args . sourceFolder ) <EOL> oCopy . createfolderPath ( oCopy . sourceFolder ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> else : <EOL> oCopy . dbStorageFolder = os . path . abspath ( os . getcwd ( ) ) <EOL> if args . targetFolder : <EOL> try : <EOL> oCopy . targetFolder = os . path . abspath ( args . targetFolder ) <EOL> oCopy . createfolderPath ( oCopy . targetFolder ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> if not args . interactive : <EOL> try : <EOL> oCopy . copyDB ( ) <EOL> except Exception , err : <EOL> print ( '<STR_LIT>' . format ( err ) ) <EOL> else : <EOL> s = dalShell ( ) <EOL> s . shell ( db ) </s>
