# stevedore/example/base.py
import abc
import fabric
from fabric.colors import red, green, cyan, yellow, white
from fabric.decorators import task
from fabric.operations import run, get, settings
from fabric.state import env
from fabric.tasks import execute
import six


@six.add_metaclass(abc.ABCMeta)
class DebuggerPlugin(object):
    """Base class for example plugin used in the tutorial.
    """

    def __init__(self, component_deployer):
        self.passed = 0
        self.failed = 0
        self.warnings = 0
        self.message_style = "[{0: <20}] {1}"
        self.name = self.__class__.__name__
        self.component_deployer = component_deployer
        self.environment = self.component_deployer.read_environment()
        self.roles = self.component_deployer.get_roles()
        print cyan(self.message_style.format('DEBUG STARTING', self.name))

    def __del__(self):
        self.report()

    def success(self, message):
        """
        Function to display and tally success of a debug step
        """
        self.passed +=1
        print green(self.message_style.format('DEBUG PASSED', message))

    def failure(self, message):
        """
        Function to display and tally a failure of a debug step
        """
        self.failed +=1
        print red(self.message_style.format('DEBUG FAILED', message))

    def info(self, message):
        """
        Function to display information of a debug step
        """
        print white(self.message_style.format('INFO', message))

    def warning(self, message):
        """
        Function to display and tally a warning of a debug step
        """
        self.warnings +=1
        print yellow(self.message_style.format('DEBUG WARNING', message))

    def report(self):
        """
        Function to display report of debug results
        """
        text_color = red
        if self.failed == 0:
            text_color = cyan
        print text_color(self.message_style.format('DEBUG RESULTS',
                                             "Name: {0} Passed: "
                                             "{1} Failed: {2}".format(
                                              self.name,
                                              str(self.passed),
                                              str(self.failed))))

    @task
    def run_command_task(command, user='root', password='foobar'):
        """
        Task to run command on host and return result
        """
        env.user = user
        env.password = password
        env.parallel = True
        return run(command)

    @task
    def get_file_task(remote_path, local_path, user='root', password='foobar'):
        """
        Task to grab file from host and return result
        """
        env.user = user
        env.password = password
        env.parallel = True
        with settings(warn_only=True):
            return get(remote_path, local_path)

    def get_file_on_host(self, remote_path, local_path, host):
        """
        Function to execute get_file_task on host
        """
        return execute(self.get_file_task, remote_path=remote_path,
                       local_path=local_path, host=host)[host]

    def run_command_on_hosts(self, command, hosts, host=None):
        """
        Function to execute run_command_task on list of hosts
        """
        return execute(self.run_command_task, command=command, hosts=hosts)

    def run_command_on_host(self, command, host):
        """
        Function to execute run_command_task on host
        """
        return execute(self.run_command_task, command=command, host=host)[host]

    def debug(self):
        """Format the data and return unicode text.

        :param data: A dictionary with string keys and simple types as
                     values.
        :type data: dict(str:?)
        :returns: Iterable producing the formatted text.
        """

@@ -329,19 +329,17 @@
 t):%0A    
-%22%22%22
+#
 Base cla
@@ -385,16 +385,8 @@
 ial.
-%0A    %22%22%22
 %0A%0A  
@@ -929,35 +929,25 @@
 e):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -985,36 +985,24 @@
  debug step%0A
-        %22%22%22%0A
         self
@@ -1122,35 +1122,25 @@
 e):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -1180,36 +1180,24 @@
  debug step%0A
-        %22%22%22%0A
         self
@@ -1312,35 +1312,25 @@
 e):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -1362,36 +1362,24 @@
  debug step%0A
-        %22%22%22%0A
         prin
@@ -1467,35 +1467,25 @@
 e):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -1529,28 +1529,16 @@
 ug step%0A
-        %22%22%22%0A
         
@@ -1656,35 +1656,25 @@
 f):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -1706,28 +1706,16 @@
 results%0A
-        %22%22%22%0A
         
@@ -2264,35 +2264,25 @@
 '):%0A        
-%22%22%22%0A       
+#
  Task to run
@@ -2312,36 +2312,24 @@
 turn result%0A
-        %22%22%22%0A
         env.
@@ -2527,27 +2527,17 @@
         
-%22%22%22%0A       
+#
  Task to
@@ -2575,28 +2575,16 @@
  result%0A
-        %22%22%22%0A
         
@@ -2814,35 +2814,25 @@
 t):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -2858,36 +2858,24 @@
 ask on host%0A
-        %22%22%22%0A
         retu
@@ -3061,35 +3061,25 @@
 e):%0A        
-%22%22%22%0A       
+#
  Function to
@@ -3121,28 +3121,16 @@
 f hosts%0A
-        %22%22%22%0A
         
@@ -3256,27 +3256,17 @@
         
-%22%22%22%0A       
+#
  Functio
@@ -3303,28 +3303,16 @@
 on host%0A
-        %22%22%22%0A
         

Fix single line comments in debuggerplugin.py