'Return a dictionary with some general Tribler statistics.'

def get_tribler_statistics(self):

    torrent_db_handler = self.session.open_dbhandler(NTFY_TORRENTS)
    channel_db_handler = self.session.open_dbhandler(NTFY_CHANNELCAST)
    torrent_stats = torrent_db_handler.getTorrentsStats()
    torrent_total_size = (0 if (torrent_stats[1] is None) else torrent_stats[1])
    stats_dict = {'torrents': {'num_collected': torrent_stats[0], 'total_size': torrent_total_size, 'num_files': torrent_stats[2]}, 'num_channels': channel_db_handler.getNrChannels(), 'database_size': os.path.getsize(os.path.join(self.session.config.get_state_dir(), DB_FILE_RELATIVE_PATH))}
    if self.session.lm.rtorrent_handler:
        torrent_queue_stats = self.session.lm.rtorrent_handler.get_queue_stats()
        torrent_queue_size_stats = self.session.lm.rtorrent_handler.get_queue_size_stats()
        torrent_queue_bandwidth_stats = self.session.lm.rtorrent_handler.get_bandwidth_stats()
        stats_dict['torrent_queue_stats'] = torrent_queue_stats
        stats_dict['torrent_queue_size_stats'] = torrent_queue_size_stats
        stats_dict['torrent_queue_bandwidth_stats'] = torrent_queue_bandwidth_stats
    return stats_dict
