(self)
Unlock the database
Unlock the database
Unlock the database
def unlock_db(self):
        '''Unlock the database'''

        if self.lock_highlight == 1 or self.lock_highlight == 3:
            password = self.control.get_password('Password: ')
            if password is False:
                return False
            elif password == -1:
                self.close()
            if self.lock_highlight != 3:  # Only password needed
                keyfile = None
        if self.lock_highlight == 2 or self.lock_highlight == 3:
            while True:
                if self.control.config['rem_key'] is True:
                    self.control.get_last_key()
                if (self.control.last_key is None or
                        self.control.config['rem_key'] is False):
                    ask_for_lf = False
                else:
                    ask_for_lf = True

                keyfile = FileBrowser(self.control, ask_for_lf, True, 
                                      self.control.last_key)()
                if keyfile is False:
                    return False
                elif keyfile == -1:
                    self.close()
                elif not isfile(keyfile):
                    self.control.draw_text(self.changed,
                                           (1, 0, 'That\'s not a file'),
                                           (3, 0, 'Press any key.'))
                    if self.control.any_key() == -1:
                        self.close()
                    continue
                break
            if self.lock_highlight != 3:  # Only keyfile needed
                password = None

        if self.remote is True:
            db_buf = self.client().get_db()
            if self.check_answer(db_buf) is False:
                return False
        else:
            db_buf = None

        try:
            self.db.unlock(password, keyfile, db_buf)
        except KPError as err:
            self.control.draw_text(self.changed,
                                   (1, 0, err.__str__()),
                                   (4, 0, 'Press any key.'))
            if self.control.any_key() == -1:
                self.close()
        else:
            self.cur_root = self.db.root_group
            # If last shown group was Results
            if self.g_highlight >= len(self.groups):
                self.g_highlight = len(self.groups) - 1 
            self.sort_tables(True, False)
            self.state = 0
            self.control.show_groups(self.g_highlight, self.groups,
                                     self.cur_win, self.g_offset,
                                     self.changed, self.cur_root)
            self.control.show_entries(self.e_highlight, self.entries,
                                      self.cur_win, self.e_offset)
def unlock_db ( self ) : if self . lock_highlight == 1 or self . lock_highlight == 3 : password = self . control . get_password ( 'Password: ' ) if password is False : return False elif password == - 1 : self . close ( ) if self . lock_highlight != 3 : # Only password needed keyfile = None if self . lock_highlight == 2 or self . lock_highlight == 3 : while True : if self . control . config [ 'rem_key' ] is True : self . control . get_last_key ( ) if ( self . control . last_key is None or self . control . config [ 'rem_key' ] is False ) : ask_for_lf = False else : ask_for_lf = True keyfile = FileBrowser ( self . control , ask_for_lf , True , self . control . last_key ) ( ) if keyfile is False : return False elif keyfile == - 1 : self . close ( ) elif not isfile ( keyfile ) : self . control . draw_text ( self . changed , ( 1 , 0 , 'That\'s not a file' ) , ( 3 , 0 , 'Press any key.' ) ) if self . control . any_key ( ) == - 1 : self . close ( ) continue break if self . lock_highlight != 3 : # Only keyfile needed password = None if self . remote is True : db_buf = self . client ( ) . get_db ( ) if self . check_answer ( db_buf ) is False : return False else : db_buf = None try : self . db . unlock ( password , keyfile , db_buf ) except KPError as err : self . control . draw_text ( self . changed , ( 1 , 0 , err . __str__ ( ) ) , ( 4 , 0 , 'Press any key.' ) ) if self . control . any_key ( ) == - 1 : self . close ( ) else : self . cur_root = self . db . root_group # If last shown group was Results if self . g_highlight >= len ( self . groups ) : self . g_highlight = len ( self . groups ) - 1 self . sort_tables ( True , False ) self . state = 0 self . control . show_groups ( self . g_highlight , self . groups , self . cur_win , self . g_offset , self . changed , self . cur_root ) self . control . show_entries ( self . e_highlight , self . entries , self . cur_win , self . e_offset )