def reset(offline=False, **kwargs):
    """
  Reset the taurus database; upon successful completion, the necessary schema
  are created, but the tables are not populated

  :param offline: False to execute SQL commands; True to just dump SQL commands
    to stdout for offline mode or debugging
  :param bool suppressPromptAndContinueWithDeletion: kwarg only! When passed
    with the value of True, proceeds to drop the Taurus Engine database without
    prompting. Without this arg or if it's False, will prompt the user via
    terminal and expect a specific string to be entered

  :returns: 0 if reset was completed successfully; 1 if user doesn't confirm the
    request
  """
    # Make sure we have the latest version of configuration
    config.loadConfig()
    dbName = config.get("repository", "db")
    dbHost = config.get("repository", "host")

    if not kwargs.get("suppressPromptAndContinueWithDeletion"):
        answer = raw_input(
            "\n"
            "Attention!  You are about to do something irreversible, and potentially"
            " dangerous.\n"
            "\n"
            "To back out immediately without making any changes, feel free to type "
            "anything but \"Yes\" in the prompt below, and press return.\n"
            "\n"
            "Should you choose to continue, the database \"%s\" on \"%s\" will be"
            "permanently deleted.\n"
            "\n"
            "Are you sure you want to continue? " % (dbName, dbHost))

        if answer.strip() != "Yes":
            print "Wise choice, my friend.  Bye."
            return 1

    resetDatabaseSQL = ("DROP DATABASE IF EXISTS %(database)s; "
                        "CREATE DATABASE %(database)s;" % {
                            "database": dbName
                        })
    statements = resetDatabaseSQL.split(";")

    engine = getUnaffiliatedEngine()
    with engine.connect() as connection:
        for s in statements:
            if s.strip():
                connection.execute(s)

    migrate(offline=offline)

    return 0
Exemple #2
0
def reset(offline=False, **kwargs):
  """
  Reset the taurus database; upon successful completion, the necessary schema
  are created, but the tables are not populated

  :param offline: False to execute SQL commands; True to just dump SQL commands
    to stdout for offline mode or debugging
  :param bool suppressPromptAndContinueWithDeletion: kwarg only! When passed
    with the value of True, proceeds to drop the Taurus Engine database without
    prompting. Without this arg or if it's False, will prompt the user via
    terminal and expect a specific string to be entered

  :returns: 0 if reset was completed successfully; 1 if user doesn't confirm the
    request
  """
  # Make sure we have the latest version of configuration
  config.loadConfig()
  dbName = config.get("repository", "db")
  dbHost = config.get("repository", "host")

  if not kwargs.get("suppressPromptAndContinueWithDeletion"):
    answer = raw_input(
      "\n"
      "Attention!  You are about to do something irreversible, and potentially"
      " dangerous.\n"
      "\n"
      "To back out immediately without making any changes, feel free to type "
      "anything but \"Yes\" in the prompt below, and press return.\n"
      "\n"
      "Should you choose to continue, the database \"%s\" on \"%s\" will be"
      "permanently deleted.\n"
      "\n"
      "Are you sure you want to continue? " % (dbName, dbHost))

    if answer.strip() != "Yes":
      print "Wise choice, my friend.  Bye."
      return 1

  resetDatabaseSQL = (
    "DROP DATABASE IF EXISTS %(database)s; "
    "CREATE DATABASE %(database)s;" % {"database": dbName})
  statements = resetDatabaseSQL.split(";")

  engine = getUnaffiliatedEngine()
  with engine.connect() as connection:
    for s in statements:
      if s.strip():
        connection.execute(s)

  migrate(offline=offline)

  return 0
Exemple #3
0
def reset(offline=False):
    """
  Reset the taurus database; upon successful completion, the necessary schema
  are created, but the tables are not populated

  :param offline: False to execute SQL commands; True to just dump SQL commands
    to stdout for offline mode or debugging
  """
    # Make sure we have the latest version of configuration
    config.loadConfig()
    dbName = config.get("repository", "db")
    dbHost = config.get("repository", "host")

    if "--suppress-prompt-and-continue-with-deletion" not in sys.argv:
        answer = raw_input(
            "Attention!  You are about to do something irreversible, and potentially"
            " dangerous.\n"
            "\n"
            "To back out immediately without making any changes, feel free to type "
            "anything but \"Yes\" in the prompt below, and press return.\n"
            "\n"
            "Should you choose to continue the database \"%s\" on \"%s\" will be"
            "permanently deleted.  If you do not wish to see this message again, "
            "you can pass --suppress-prompt-and-continue-with-deletion as an "
            "argument to this command.\n"
            "\n"
            "Are you sure you want to continue? " % (dbName, dbHost))

        if answer.strip() != "Yes":
            print "Wise choice, my friend.  Bye."
            return

    resetDatabaseSQL = ("DROP DATABASE IF EXISTS %(database)s; "
                        "CREATE DATABASE %(database)s;" % {
                            "database": dbName
                        })
    statements = resetDatabaseSQL.split(";")

    engine = getUnaffiliatedEngine()
    with engine.connect() as connection:
        for s in statements:
            if s.strip():
                connection.execute(s)

    migrate(offline=offline)
Exemple #4
0
def reset(offline=False):
  """
  Reset the taurus database; upon successful completion, the necessary schema
  are created, but the tables are not populated

  :param offline: False to execute SQL commands; True to just dump SQL commands
    to stdout for offline mode or debugging
  """
  # Make sure we have the latest version of configuration
  config.loadConfig()
  dbName = config.get("repository", "db")
  dbHost = config.get("repository", "host")

  if "--suppress-prompt-and-continue-with-deletion" not in sys.argv:
    answer = raw_input(
      "Attention!  You are about to do something irreversible, and potentially"
      " dangerous.\n"
      "\n"
      "To back out immediately without making any changes, feel free to type "
      "anything but \"Yes\" in the prompt below, and press return.\n"
      "\n"
      "Should you choose to continue the database \"%s\" on \"%s\" will be"
      "permanently deleted.  If you do not wish to see this message again, "
      "you can pass --suppress-prompt-and-continue-with-deletion as an "
      "argument to this command.\n"
      "\n"
      "Are you sure you want to continue? " % (dbName, dbHost))

    if answer.strip() != "Yes":
      print "Wise choice, my friend.  Bye."
      return

  resetDatabaseSQL = (
      "DROP DATABASE IF EXISTS %(database)s; "
      "CREATE DATABASE %(database)s;" % {"database": dbName})
  statements = resetDatabaseSQL.split(";")

  engine = getUnaffiliatedEngine()
  with engine.connect() as connection:
    for s in statements:
      if s.strip():
        connection.execute(s)

  migrate(offline=offline)