Ejemplo n.º 1
0
 def test_setup_logging(self):
     main.setup_logging()
     self.assertEqual(logging.getLogger().level, logging.DEBUG)
     self.assertEqual(logging.getLogger('requests').propagate, False)
Ejemplo n.º 2
0
def up(args, parser):
    update_config(args, parser)
    main.setup_logging()
    cmd = main.TopLevelCommand()
    cmd.dispatch(['up', '-d'], None)
Ejemplo n.º 3
0
 def test_setup_logging(self):
     main.setup_logging()
     self.assertEqual(logging.getLogger().level, logging.DEBUG)
     self.assertEqual(logging.getLogger('requests').propagate, False)
Ejemplo n.º 4
0
def create_parser():
    parser = argparse.ArgumentParser()

    subparsers = parser.add_subparsers(
        help='See each command for additional help',
        title='Sub-commands', description='Valid commands'
    )

    parser_root = subparsers.add_parser(
        'root', help='Create or update the root paths in the fig.yml.'
    )
    parser_root.add_argument(
        'directory', help='Path to the marketplace repositories.',
        default=None, nargs='?'
    )
    parser_root.add_argument(
        '--buildfrom', help='Build locally or from docker hub',
        dest='build', action='store'
    )
    # Set the default to empty to allow "mkt root" to just print out the
    # root directory.
    parser_root.set_defaults(build=None)
    parser_root.set_defaults(func=root)

    parser_bash = subparsers.add_parser(
        'bash', help='Run a bash shell on a running container.'
    )
    parser_bash.add_argument(
        'project',
        help='Project name, if not given will be calculated.',
        default=None, nargs='?')
    parser_bash.set_defaults(func=bash)

    parser_update = subparsers.add_parser(
        'update', help='Runs git pull on each repo and any migrations.'
    )
    parser_update.add_argument(
        '--git', help='Runs git pull', action='store_true')
    parser_update.add_argument(
        '--migrations', help='Runs migrations', action='store_true')
    parser_update.set_defaults(func=update)

    parser_check = subparsers.add_parser(
        'check', help='Basic health checks of the system.'
    )
    parser_check.add_argument(
        '--services', help='Checks the status page of each service.',
        action='store_true'
    )
    parser_check.add_argument(
        '--requirements', help='Checks the container requirements vs current'
                               ' requirements',
        action='store_true'
    )
    parser_check.add_argument(
        '--versions', help='Checks versions of docker, boot2docker and fig',
        action='store_true'
    )
    parser_check.set_defaults(func=check)

    parser_up = subparsers.add_parser(
        'up', help='Recreates fig.yml and starts the '
                   'containers in the background, a wrapper around `fig up`'
    )
    parser_up.set_defaults(func=up)

    parser_checkgitconfig = subparsers.add_parser(
        'chkgitconfig', help='Print out the git config for mkt branches'
    )
    parser_checkgitconfig.set_defaults(func=check_git_config)

    parser_revs = subparsers.add_parser(
        'revs', help='Print out the git revs for the trees'
    )
    parser_revs.set_defaults(func=revs)

    parser_whoami = subparsers.add_parser(
        'whoami', help='Check or store your github credentials'
    )
    parser_whoami.add_argument(
        'github_username', help='Your github username e.g. "jrrtolkien"',
        metavar="USER_NAME", default=None, nargs='?'
    )
    parser_whoami.set_defaults(func=whoami)

    parser_checkout = subparsers.add_parser(
        'checkout', help='Checkout your forks of sourcecode'
    )
    parser_checkout.add_argument(
        '--moz_remote_name',
        help='What to call the mozilla repo remote for this project. '
             'Following github terminology this defaults to "upstream"',
        metavar="MOZ_REMOTE_NAME",
        default='upstream', nargs='?'
    )
    parser_checkout.add_argument(
        '--fork_remote_name',
        help='What to call your fork remote for this project. Following '
             'github terminology this defaults to "origin"',
        metavar="FORK_REMOTE_NAME", default='origin', nargs='?'
    )
    parser_checkout.set_defaults(func=checkout)

    parser_bind = subparsers.add_parser(
        'bind', help='Bind the mp.dev domain to your public IP on '
                     'a Firefox OS device. Your public ID must be a proxy to '
                     'your internal Docker IP.'
    )
    parser_bind.add_argument(
        '--bind_ip',
        help='Public IP to bind to. If empty, the IP will be discovered.')
    parser_bind.add_argument(
        '--bind_host', default='mp.dev',
        help='Hostname to bind your IP too. Default: %(default)s')
    parser_bind.add_argument(
        '--bind_int',
        help='Network interface to guess a public IP from. Example: en0',
        default=None)
    parser_bind.add_argument(
        '--interfaces',
        help='Show network interfaces but do not bind anything.',
        action='store_true')
    parser_bind.set_defaults(func=bind)

    parser.add_argument('--version', action='version', version=__version__)
    # Setup the logging for fig.
    main.setup_logging()
    return parser