old_contents: #! /usr/bin/env python
  # -*- coding: utf-8 -*-
  from __future__ import print_function, unicode_literals, division
  import argparse
  import os
  import sys
  import contextlib
  
  
  @contextlib.contextmanager
  def redirect_output():
      stdout = sys.stdout
      sys.stdout = open(os.devnull, 'wb')
      yield None  # Executing the inner block.
      sys.stdout.close()
      sys.stdout = stdout
  
  
  def run(connector):
      if connector.endswith('django'):
          # Ensure the settings are pointed to correctly.
          module = 'tests.{}.settings'.format(connector)
          os.environ.setdefault("DJANGO_SETTINGS_MODULE", module)
  
          # Initialize the database tables and install the test fixtures.
          from django.core.management import call_command
          with redirect_output():
              call_command('syncdb', skip_validation=True, interactive=False)
              call_command('loaddata', 'test', skip_validation=True)
  
      # Let the world know.
      print('Armet version 0.3.0-pre')
      print('Development server is running at http://127.0.0.1:5000/')
      print('Quit the server with CONTROL-C.')
  
      if connector.startswith('django'):
          # Run the development server.
          from django.core.servers import basehttp
          application = basehttp.get_internal_wsgi_application()
          basehttp.run('localhost', 5000, application)
  
  
  if __name__ == '__main__':
      # Extend our python path with armet.
      sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
  
      # Initialize and add arguments to the argument parser.
      parser = argparse.ArgumentParser()
      parser.add_argument('connector', choices=(
          'django',
          'django_django',
          'flask'
      ))
      parser.add_argument('command', choices=('run', 'shell'))
  
      # Parse the arguments using our parser.
      arguments = parser.parse_args()
  
      # Expand shorthands.
      connector = arguments.connector
      if connector == 'django':
          connector = 'django_django'
  
      try:
          # Run the appropriate command.
          globals()[arguments.command](connector)
  
      except KeyboardInterrupt:
          # Closing the connection.
          pass
  
new_contents: #! /usr/bin/env python
  # -*- coding: utf-8 -*-
  from __future__ import print_function, unicode_literals, division
  import argparse
  import os
  import sys
  
  
  #! Hostname at which to run the servers at.
  HOST = 'localhost'
  
  
  #! Port at which to run the servers at.
  PORT = 5000
  
  
  def initialize(name):
      if name.endswith('django'):
          # Ensure the settings are pointed to correctly.
          if not name.startswith('django'):
              # Unless django is being used for the http connector as well
              # there is only one settings file.
              name = 'django'
          os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.{}.settings'.format(name)
  
          # Initialize the database tables and install the test fixtures.
          from django.core.management import call_command
          call_command('syncdb', verbosity=False, interactive=False)
  
  
  def run(name):
      # Initialize the data access layer.
      initialize(name)
  
      # Let the world know.
      print('Armet version 0.3.0-pre\n'
            'Development server is running at http://localhost:5000/\n'
            'Quit the server with CONTROL-C.')
  
      # Initialize the request / response layer.
      if name.startswith('django'):
          # Ensure the settings are pointed to correctly.
          os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.{}.settings'.format(name)
  
          # Run the development server.
          from django.core.servers import basehttp
          basehttp.run(HOST, PORT, basehttp.get_internal_wsgi_application())
  
      elif name.startswith('flask'):
          # Run the development server.
          from tests.flask_django import app
          app.application.run(HOST, PORT)
  
  
  def shell(name):
      # Initialize the data access layer.
      initialize(name)
  
      # Open the database access shell.
      if name.endswith('django'):
          from django.core.management import call_command
          call_command('shell_plus')
  
  
  if __name__ == '__main__':
      # Extend our python path with armet.
      sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
  
      # Initialize and add arguments to the argument parser.
      parser = argparse.ArgumentParser()
      parser.add_argument('connector')
      parser.add_argument('command', choices=('run', 'shell'))
  
      # Parse the arguments using our parser.
      arguments = parser.parse_args()
  
      # Expand shorthands.
      connector = arguments.connector.replace('-', '_')
      if connector == 'django':
          connector = 'django_django'
  
      try:
          # Run the appropriate command.
          globals()[arguments.command](connector)
  
      except KeyboardInterrupt:
          # Closing the connection.
          pass
  
subject: Improve management; add shell command.