from spec import skip


def simple_command_on_host():
    """
    Run command on host "localhost"
    """
    skip()
    Connection('localhost').run('echo foo')
    # => Result

def simple_command_on_multiple_hosts():
    """
    Run command on localhost...twice!
    """
    skip()
    Batch(['localhost', 'localhost']).run('echo foo')
    # => [Result, Result

def sudo_command():
    """
    Run command via sudo on host "localhost"
    """
    skip()
    Connection('localhost').sudo('echo foo')

def mixed_sudo_and_normal_commands():
    """
    Run command via sudo, and not via sudo, on "localhost"
    """
    skip()
    cxn = Connection('localhost')
    cxn.run('whoami')
    cxn.sudo('whoami')
    # Alternately...
    cxn.run('whoami', runner=Basic)
    cxn.run('whoami', runner=Sudo)

def switch_command_between_local_and_remote():
    """
    Run command truly locally, and over SSH via "localhost"

    Only really makes sense at the task level though...
    """
    skip()
    # Basic/raw
    run('hostname') # Or Context().run('hostname')
    Connection('localhost').run('hostname')

from spec import skip, Spec


class Main(Spec):
    def simple_command_on_host(self):
        """
        Run command on host "localhost"
        """
        skip()
        Connection('localhost').run('echo foo')
        # => Result

    def simple_command_on_multiple_hosts(self):
        """
        Run command on localhost...twice!
        """
        skip()
        Batch(['localhost', 'localhost']).run('echo foo')
        # => [Result, Result

    def sudo_command(self):
        """
        Run command via sudo on host "localhost"
        """
        skip()
        Connection('localhost').sudo('echo foo')

    def mixed_sudo_and_normal_commands(self):
        """
        Run command via sudo, and not via sudo, on "localhost"
        """
        skip()
        cxn = Connection('localhost')
        cxn.run('whoami')
        cxn.sudo('whoami')
        # Alternately...
        cxn.run('whoami', runner=Basic)
        cxn.run('whoami', runner=Sudo)

    def switch_command_between_local_and_remote(self):
        """
        Run command truly locally, and over SSH via "localhost"

        Only really makes sense at the task level though...
        """
        skip()
        # Basic/raw
        run('hostname') # Or Context().run('hostname')
        Connection('localhost').run('hostname')

Move towards real spec usage
Move towards real spec usage

- from spec import skip
+ from spec import skip, Spec
  
  
+ class Main(Spec):
- def simple_command_on_host():
+     def simple_command_on_host(self):
-     """
+         """
-     Run command on host "localhost"
+         Run command on host "localhost"
-     """
+         """
-     skip()
+         skip()
-     Connection('localhost').run('echo foo')
+         Connection('localhost').run('echo foo')
-     # => Result
+         # => Result
  
- def simple_command_on_multiple_hosts():
+     def simple_command_on_multiple_hosts(self):
-     """
+         """
-     Run command on localhost...twice!
+         Run command on localhost...twice!
-     """
+         """
-     skip()
+         skip()
-     Batch(['localhost', 'localhost']).run('echo foo')
+         Batch(['localhost', 'localhost']).run('echo foo')
-     # => [Result, Result
+         # => [Result, Result
  
- def sudo_command():
+     def sudo_command(self):
-     """
+         """
-     Run command via sudo on host "localhost"
+         Run command via sudo on host "localhost"
-     """
+         """
-     skip()
+         skip()
-     Connection('localhost').sudo('echo foo')
+         Connection('localhost').sudo('echo foo')
  
- def mixed_sudo_and_normal_commands():
+     def mixed_sudo_and_normal_commands(self):
-     """
+         """
-     Run command via sudo, and not via sudo, on "localhost"
+         Run command via sudo, and not via sudo, on "localhost"
-     """
+         """
-     skip()
+         skip()
-     cxn = Connection('localhost')
+         cxn = Connection('localhost')
-     cxn.run('whoami')
+         cxn.run('whoami')
-     cxn.sudo('whoami')
+         cxn.sudo('whoami')
-     # Alternately...
+         # Alternately...
-     cxn.run('whoami', runner=Basic)
+         cxn.run('whoami', runner=Basic)
-     cxn.run('whoami', runner=Sudo)
+         cxn.run('whoami', runner=Sudo)
  
- def switch_command_between_local_and_remote():
+     def switch_command_between_local_and_remote(self):
-     """
+         """
-     Run command truly locally, and over SSH via "localhost"
+         Run command truly locally, and over SSH via "localhost"
  
-     Only really makes sense at the task level though...
+         Only really makes sense at the task level though...
-     """
+         """
-     skip()
+         skip()
-     # Basic/raw
+         # Basic/raw
-     run('hostname') # Or Context().run('hostname')
+         run('hostname') # Or Context().run('hostname')
-     Connection('localhost').run('hostname')
+         Connection('localhost').run('hostname')
  
Move towards real spec usage
## Code Before:
from spec import skip


def simple_command_on_host():
    """
    Run command on host "localhost"
    """
    skip()
    Connection('localhost').run('echo foo')
    # => Result

def simple_command_on_multiple_hosts():
    """
    Run command on localhost...twice!
    """
    skip()
    Batch(['localhost', 'localhost']).run('echo foo')
    # => [Result, Result

def sudo_command():
    """
    Run command via sudo on host "localhost"
    """
    skip()
    Connection('localhost').sudo('echo foo')

def mixed_sudo_and_normal_commands():
    """
    Run command via sudo, and not via sudo, on "localhost"
    """
    skip()
    cxn = Connection('localhost')
    cxn.run('whoami')
    cxn.sudo('whoami')
    # Alternately...
    cxn.run('whoami', runner=Basic)
    cxn.run('whoami', runner=Sudo)

def switch_command_between_local_and_remote():
    """
    Run command truly locally, and over SSH via "localhost"

    Only really makes sense at the task level though...
    """
    skip()
    # Basic/raw
    run('hostname') # Or Context().run('hostname')
    Connection('localhost').run('hostname')

## Instruction:
Move towards real spec usage
## Code After:
from spec import skip, Spec


class Main(Spec):
    def simple_command_on_host(self):
        """
        Run command on host "localhost"
        """
        skip()
        Connection('localhost').run('echo foo')
        # => Result

    def simple_command_on_multiple_hosts(self):
        """
        Run command on localhost...twice!
        """
        skip()
        Batch(['localhost', 'localhost']).run('echo foo')
        # => [Result, Result

    def sudo_command(self):
        """
        Run command via sudo on host "localhost"
        """
        skip()
        Connection('localhost').sudo('echo foo')

    def mixed_sudo_and_normal_commands(self):
        """
        Run command via sudo, and not via sudo, on "localhost"
        """
        skip()
        cxn = Connection('localhost')
        cxn.run('whoami')
        cxn.sudo('whoami')
        # Alternately...
        cxn.run('whoami', runner=Basic)
        cxn.run('whoami', runner=Sudo)

    def switch_command_between_local_and_remote(self):
        """
        Run command truly locally, and over SSH via "localhost"

        Only really makes sense at the task level though...
        """
        skip()
        # Basic/raw
        run('hostname') # Or Context().run('hostname')
        Connection('localhost').run('hostname')
