
from __future__ import unicode_literals

import collections
import pipes


CommandResult = collections.namedtuple('CommandResult', [
    'rc', 'stdout', 'stderr', 'command',
])


class BaseBackend(object):

    def quote(self, command, *args):
        return command % tuple(pipes.quote(a) for a in args)

    @staticmethod
    def parse_hostspec(hostspec):
        host = hostspec
        user = None
        port = None
        if "@" in host:
            user, host = host.split("@", 1)
        if ":" in host:
            host, port = host.split(":", 1)
        return host, user, port

    def run(self, command, *args):
        raise NotImplementedError


from __future__ import unicode_literals

import collections
import pipes


CommandResult = collections.namedtuple('CommandResult', [
    'rc', 'stdout', 'stderr', 'command',
])


class BaseBackend(object):

    def quote(self, command, *args):
        if args:
            return command % tuple(pipes.quote(a) for a in args)
        else:
            return command

    @staticmethod
    def parse_hostspec(hostspec):
        host = hostspec
        user = None
        port = None
        if "@" in host:
            user, host = host.split("@", 1)
        if ":" in host:
            host, port = host.split(":", 1)
        return host, user, port

    def run(self, command, *args):
        raise NotImplementedError

Fix safe_ssh command without arguments
backend: Fix safe_ssh command without arguments

  
  from __future__ import unicode_literals
  
  import collections
  import pipes
  
  
  CommandResult = collections.namedtuple('CommandResult', [
      'rc', 'stdout', 'stderr', 'command',
  ])
  
  
  class BaseBackend(object):
  
      def quote(self, command, *args):
+         if args:
-         return command % tuple(pipes.quote(a) for a in args)
+             return command % tuple(pipes.quote(a) for a in args)
+         else:
+             return command
  
      @staticmethod
      def parse_hostspec(hostspec):
          host = hostspec
          user = None
          port = None
          if "@" in host:
              user, host = host.split("@", 1)
          if ":" in host:
              host, port = host.split(":", 1)
          return host, user, port
  
      def run(self, command, *args):
          raise NotImplementedError
  
Fix safe_ssh command without arguments
## Code Before:

from __future__ import unicode_literals

import collections
import pipes


CommandResult = collections.namedtuple('CommandResult', [
    'rc', 'stdout', 'stderr', 'command',
])


class BaseBackend(object):

    def quote(self, command, *args):
        return command % tuple(pipes.quote(a) for a in args)

    @staticmethod
    def parse_hostspec(hostspec):
        host = hostspec
        user = None
        port = None
        if "@" in host:
            user, host = host.split("@", 1)
        if ":" in host:
            host, port = host.split(":", 1)
        return host, user, port

    def run(self, command, *args):
        raise NotImplementedError

## Instruction:
Fix safe_ssh command without arguments
## Code After:

from __future__ import unicode_literals

import collections
import pipes


CommandResult = collections.namedtuple('CommandResult', [
    'rc', 'stdout', 'stderr', 'command',
])


class BaseBackend(object):

    def quote(self, command, *args):
        if args:
            return command % tuple(pipes.quote(a) for a in args)
        else:
            return command

    @staticmethod
    def parse_hostspec(hostspec):
        host = hostspec
        user = None
        port = None
        if "@" in host:
            user, host = host.split("@", 1)
        if ":" in host:
            host, port = host.split(":", 1)
        return host, user, port

    def run(self, command, *args):
        raise NotImplementedError
