<commit_before>"""Manage VTTablet during test."""

import json
import logging
import os
import re
import shutil
import sys
import time
import urllib2
import warnings

import MySQLdb

import environment
from mysql_flavor import mysql_flavor
from protocols_flavor import protocols_flavor
from topo_flavor.server import topo_server
import utils

# Dropping a table inexplicably produces a warning despite
# the 'IF EXISTS' clause. Squelch these warnings.
warnings.simplefilter('ignore')

tablet_cell_map = {
    62344: 'nj',
    62044: 'nj',
    41983: 'nj',
    31981: 'ny',
}


def get_backup_storage_flags():
  return ['-backup_storage_implementation', 'file',
          '-file_backup_storage_root',
          os.path.join(environment.tmproot, 'backupstorage')]


def get_all_extra_my_cnf(extra_my_cnf):
  all_extra_my_cnf = [environment.vttop + '/config/mycnf/default-fast.cnf']
  flavor_my_cnf = mysql_flavor().extra_my_cnf()
  if flavor_my_cnf:
    all_extra_my_cnf.append(flavor_my_cnf)
  if extra_my_cnf:
    all_extra_my_cnf.append(extra_my_cnf)
  return all_extra_my_cnf


class Tablet(object):
  """This class helps manage a vttablet instance.

  To use it for vttablet, you need to use init_tablet and/or
  start_vttablet.
  """
  default_uid = 62344
  seq = 0
  tablets_running = 0
  default_db_dba_config = {
      'dba': {
          'uname': 'vt_dba',
          'charset': 'utf8'
      },
  }
  default_db_config = {
      'app': {
          'uname': 'vt_app',
          'charset': 'utf8'
      },
      'allprivs': {
          'uname': 'vt_allprivs',
          'charset': 'utf8'
      },
      'dba': {
          'uname': 'vt_dba',
          'charset': 'utf8'
      },
      'filtered': {
          'uname': 'vt_filtered',
          'charset': 'utf8'
      },
      'repl': {
          'uname': 'vt_repl',
          'charset': 'utf8'
      }
  }

  # this will eventually be coming from the proto3
  tablet_type_value = {
      'UNKNOWN': 0,
      'MASTER': 1,
      'REPLICA': 2,
      'RDONLY': 3,
      'BATCH': 3,
      'SPARE': 4,
      'EXPERIMENTAL': 5,
      'BACKUP': 6,
      'RESTORE': 7,
      'DRAINED': 8,
  }

  def __init__(self, tablet_uid=None, port=None, mysql_port=None, cell=None,
               use_mysqlctld=False):
    self.tablet_uid = tablet_uid or (Tablet.default_uid + Tablet.seq)<commit_msg>test: tablet.py: Remove unused value.<commit_after>"""Manage VTTablet during test."""

import json
import logging
import os
import re
import shutil
import sys
import time
import urllib2
import warnings

import MySQLdb

import environment
from mysql_flavor import mysql_flavor
from protocols_flavor import protocols_flavor
from topo_flavor.server import topo_server
import utils

# Dropping a table inexplicably produces a warning despite
# the 'IF EXISTS' clause. Squelch these warnings.
warnings.simplefilter('ignore')

tablet_cell_map = {
    62344: 'nj',
    62044: 'nj',
    41983: 'nj',
    31981: 'ny',
}


def get_backup_storage_flags():
  return ['-backup_storage_implementation', 'file',
          '-file_backup_storage_root',
          os.path.join(environment.tmproot, 'backupstorage')]


def get_all_extra_my_cnf(extra_my_cnf):
  all_extra_my_cnf = [environment.vttop + '/config/mycnf/default-fast.cnf']
  flavor_my_cnf = mysql_flavor().extra_my_cnf()
  if flavor_my_cnf:
    all_extra_my_cnf.append(flavor_my_cnf)
  if extra_my_cnf:
    all_extra_my_cnf.append(extra_my_cnf)
  return all_extra_my_cnf


class Tablet(object):
  """This class helps manage a vttablet instance.

  To use it for vttablet, you need to use init_tablet and/or
  start_vttablet.
  """
  default_uid = 62344
  seq = 0
  tablets_running = 0
  default_db_dba_config = {
      'dba': {
          'uname': 'vt_dba',
          'charset': 'utf8'
      },
  }
  default_db_config = {
      'app': {
          'uname': 'vt_app',
          'charset': 'utf8'
      },
      'allprivs': {
          'uname': 'vt_allprivs',
          'charset': 'utf8'
      },
      'dba': {
          'uname': 'vt_dba',
          'charset': 'utf8'
      },
      'filtered': {
          'uname': 'vt_filtered',
          'charset': 'utf8'
      },
      'repl': {
          'uname': 'vt_repl',
          'charset': 'utf8'
      }
  }

  def __init__(self, tablet_uid=None, port=None, mysql_port=None, cell=None,
               use_mysqlctld=False):
    self.tablet_uid = tablet_uid or (Tablet.default_uid + Tablet.seq)
{'fraction_non_alphanumeric': 0.11831368993653672, 'fraction_numerical': 0.017905711695376247, 'mean_word_length': 2.8541484716157206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4176090', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1585, 'n_words': 350}