Execute an operational mode command.

        Purpose: Used to send an operational mode command to the connected
               | device. This requires and uses a paramiko.SSHClient() as
               | the handler so that we can easily pass and allow all pipe
               | commands to be used.
               |
               | We indiscriminately attach ' | no-more' on the end of
               | every command so the device doesn't hold output. The
               | req_format parameter can be set to 'xml' to force raw
               | xml output in the reply.

        @param command: The single command that to retrieve output from the
                      | device. Any pipes will be taken into account.
        @type command: str
        @param req_format: The desired format of the response, defaults to
                         | 'text', but also accepts 'xml'. **NOTE**: 'xml'
                         | will still return a string, not a libxml ElementTree
        @type req_format: str

        @returns: The reply from the device.
        @rtype: str

def op_cmd(self, command, req_format='text', xpath_expr=""):
        """ Execute an operational mode command.

        Purpose: Used to send an operational mode command to the connected
               | device. This requires and uses a paramiko.SSHClient() as
               | the handler so that we can easily pass and allow all pipe
               | commands to be used.
               |
               | We indiscriminately attach ' | no-more' on the end of
               | every command so the device doesn't hold output. The
               | req_format parameter can be set to 'xml' to force raw
               | xml output in the reply.

        @param command: The single command that to retrieve output from the
                      | device. Any pipes will be taken into account.
        @type command: str
        @param req_format: The desired format of the response, defaults to
                         | 'text', but also accepts 'xml'. **NOTE**: 'xml'
                         | will still return a string, not a libxml ElementTree
        @type req_format: str

        @returns: The reply from the device.
        @rtype: str
        """
        if not command:
            raise InvalidCommandError("Parameter 'command' cannot be empty")
        if req_format.lower() == 'xml' or xpath_expr:
            command = command.strip() + ' | display xml'
        command = command.strip() + ' | no-more\n'
        out = ''
        # when logging in as root, we use _shell to get the response.
        if self.username == 'root':
            self._shell.send(command)
            time.sleep(3)
            while self._shell.recv_ready():
                out += self._shell.recv(999999)
                time.sleep(.75)
            # take off the command being sent and the prompt at the end.
            out = '\n'.join(out.split('\n')[1:-2])
        # not logging in as root, and can grab the output as normal.
        else:
            stdin, stdout, stderr = self._session.exec_command(command=command,
                                           timeout=float(self.session_timeout))
            stdin.close()
            # read normal output
            while not stdout.channel.exit_status_ready():
                out += stdout.read()
            stdout.close()
            # read errors
            while not stderr.channel.exit_status_ready():
                out += stderr.read()
            stderr.close()
        return out if not xpath_expr else xpath(out, xpath_expr)