code: def _epub_to_mobi(
              self,
              epubPath,
              deleteEpub=False):
          
          self.log.debug('starting the ``_epub_to_mobi`` method')
  
          mobi = epubPath.replace(".epub", ".mobi")
          kindlegen = self.settings["executables"]["kindlegen"]
          cmd = """%(kindlegen)s "%(epubPath)s" """ % locals(
          )
          p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
          stdout, stderr = p.communicate()
          self.log.debug('output: %(stdout)s' % locals())
  
          try:
              with open(mobi):
                  pass
              fileExists = True
          except IOError:
              fileExists = False
              self.log.error(
                  "the mobi %s does not exist on this machine. The kindlegen error was: %s" % (mobi, stdout))
              return False
  
          if deleteEpub:
              os.remove(epubPath)
  
          self.log.debug('completed the ``_epub_to_mobi`` method')
          return mobi
docs: *convert the give epub to mobi format using kindlegen*
  
          **Key Arguments:**
              - ``epubPath`` -- path to the epub book
              - ``deleteEpub`` -- delete the epub when mobi is generated. Default *False*
  
          **Return:**
              - ``mobi`` -- the path to the generated mobi book