#NEWLINE# def migrate_repeater_db( old_db_dir , new_db_dir ) : #NEWLINE# #INDENT# old_repeater_db_path = os . path . join ( old_db_dir , 'valuable_blobs.db' ) #NEWLINE# if ( not os . path . exists ( old_repeater_db_path ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# old_db = leveldb . LevelDB ( old_repeater_db_path ) #NEWLINE# info_db = sqlite3 . connect ( os . path . join ( new_db_dir , 'blind_info.db' ) ) #NEWLINE# peer_db = sqlite3 . connect ( os . path . join ( new_db_dir , 'blind_peers.db' ) ) #NEWLINE# unql_db = unqlite . UnQLite ( os . path . join ( new_db_dir , 'blind_settings.db' ) ) #NEWLINE# BLOB_INFO_TYPE = 'b' #NEWLINE# SETTING_TYPE = 's' #NEWLINE# PEER_TYPE = 'p' #NEWLINE# info_c = info_db . cursor ( ) #NEWLINE# info_c . execute ( ( ( ( ( ( ( ( 'create table if not exists valuable_blobs (' + '    blob_hash text primary key, ' ) + '    blob_length integer, ' ) + '    reference text, ' ) + '    peer_host text, ' ) + '    peer_port integer, ' ) + '    peer_score text' ) + ')' ) ) #NEWLINE# info_db . commit ( ) #NEWLINE# peer_c = peer_db . cursor ( ) #NEWLINE# peer_c . execute ( ( ( ( 'create table if not exists approved_peers (' + '    ip_address text, ' ) + '    port integer' ) + ')' ) ) #NEWLINE# peer_db . commit ( ) #NEWLINE# info_c = info_db . cursor ( ) #NEWLINE# peer_c = peer_db . cursor ( ) #NEWLINE# for ( k , v ) in old_db . RangeIter ( ) : #NEWLINE# #INDENT# ( key_type , key_rest ) = json . loads ( k ) #NEWLINE# if ( key_type == PEER_TYPE ) : #NEWLINE# #INDENT# ( host , port ) = key_rest #NEWLINE# peer_c . execute ( 'insert into approved_peers values (?, ?)' , ( host , port ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key_type == SETTING_TYPE ) : #NEWLINE# #INDENT# unql_db [ key_rest ] = v #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key_type == BLOB_INFO_TYPE ) : #NEWLINE# #INDENT# blob_hash = key_rest #NEWLINE# ( length , reference , peer_host , peer_port , peer_score ) = json . loads ( v ) #NEWLINE# info_c . execute ( 'insert into valuable_blobs values (?, ?, ?, ?, ?, ?)' , ( blob_hash , old_db , reference , peer_host , peer_port , peer_score ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# info_db . commit ( ) #NEWLINE# peer_db . commit ( ) #NEWLINE# info_db . close ( ) #NEWLINE# peer_db . close ( )