# Path: servi/command.py
# class Command(object):
#     def __init__(self):
#         self.special = {
#             "skip_init": False,
#             "parse_known_args": False
#         }
# 
#     def register_command_line(self, sub_parser):
#         pass
# 
#     def run(self, args, extra_args):
#         pass
# 
# Path: servi/utils.py
# @contextmanager
# def timeit():
#     t0 = datetime.now()
#     yield
#     t1 = datetime.now()
#     info('Total running time: {0:.1f} min'.format((t1 - t0).seconds / 60))
# 
# Path: servi/exceptions.py
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


import subprocess
import os
import sys
import servi.config as c
from logging import info
from servi.command import Command
from servi.utils import timeit
from servi.exceptions import ServiError
                        "This is a convenience function that sets "
                        "up the ansible command with the proper "
                        "vagrant_inventory "
                        "file, and ssh user and password, saving you a lot "
                        "of typing. Any arguments not listed below will be "
                        "passed directly 'ansible-playbook'."
        )

        parser.add_argument(
            '-p', '--project_only', action='store_true', help=
            'Only run the "projectSpecific" role.')

        parser.set_defaults(command_func=self.run)

    def run(self, args, extra_args):
        proj_only = ['-t', 'projectSpecific'] if args.project_only else []

        cmd_line = ['ansible-playbook', 'playbook.yml',
                    '--inventory-file', get_servi_inventory_path(),
                    '--limit', 'vagrant',
                    '--user', c.MAIN_USERNAME,
                    '--private-key', c.MAIN_RSA_KEY_FILE,
                    '-e', 'IS_VAGRANT=True',
                    ] + proj_only \
                      + extra_args

        info('Running local ansible with:\n\tcommand line: {0}\n\tcwd:{1}'
             .format(' '.join(cmd_line),
                     os.path.join(c.MASTER_DIR, 'ansible_config')))


# Path: servi/command.py
# class Command(object):
#     def __init__(self):
#         self.special = {
#             "skip_init": False,
#             "parse_known_args": False
#         }
# 
#     def register_command_line(self, sub_parser):
#         pass
# 
#     def run(self, args, extra_args):
#         pass
# 
# Path: servi/utils.py
# @contextmanager
# def timeit():
#     t0 = datetime.now()
#     yield
#     t1 = datetime.now()
#     info('Total running time: {0:.1f} min'.format((t1 - t0).seconds / 60))
# 
# Path: servi/exceptions.py
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


# Path: servi/commands/lans.py
import subprocess
import os
import sys
import servi.config as c
from logging import info
from servi.command import Command
from servi.utils import timeit
from servi.exceptions import ServiError

                        "This is a convenience function that sets "
                        "up the ansible command with the proper "
                        "vagrant_inventory "
                        "file, and ssh user and password, saving you a lot "
                        "of typing. Any arguments not listed below will be "
                        "passed directly 'ansible-playbook'."
        )

        parser.add_argument(
            '-p', '--project_only', action='store_true', help=
            'Only run the "projectSpecific" role.')

        parser.set_defaults(command_func=self.run)

    def run(self, args, extra_args):
        proj_only = ['-t', 'projectSpecific'] if args.project_only else []

        cmd_line = ['ansible-playbook', 'playbook.yml',
                    '--inventory-file', get_servi_inventory_path(),
                    '--limit', 'vagrant',
                    '--user', c.MAIN_USERNAME,
                    '--private-key', c.MAIN_RSA_KEY_FILE,
                    '-e', 'IS_VAGRANT=True',
                    ] + proj_only \
                      + extra_args

        info('Running local ansible with:\n\tcommand line: {0}\n\tcwd:{1}'
             .format(' '.join(cmd_line),
                     os.path.join(c.MASTER_DIR, 'ansible_config')))


        with timeit():