code: def commit_check(self, commands="", req_format="text"):
          if not commands:
              raise InvalidCommandError('No commands specified')
          clean_cmds = []
          for cmd in clean_lines(commands):
              clean_cmds.append(cmd)
          self.lock()
          self._session.load_configuration(action='set', config=clean_cmds)
          results = ET.fromstring(self._session.validate(
              source='candidate').tostring)
          self.unlock()
          if req_format == "xml":
              return ET.tostring(results)
          out = ""
          for i in results.iter():
              if i.tag == 'commit-check-success':
                  out += 'configuration check succeeds\n'
              elif i.text is not None:
                  if i.text.strip() + '\n' != '\n':
                      out += i.text.strip() + '\n'
              elif i.text is None:
                  if i.tag + '\n' != '\n':
                      out += i.tag + '\n'
          return out