def getMessageFromUser(self, prompt=''):
        editor = os.environ.get("EDITOR", "/bin/vi")
        (fd, name) = tempfile.mkstemp()
        if not prompt:
            prompt = 'Enter your change log message.'
        msg = "\n-----\n%s\n" % prompt
        os.write(fd, msg)
        os.close(fd)

        def _getMessageNoEditor():
            sys.stderr.write("Error executing %s. Please set the EDITOR\n"
              "environment variable to a valid editor, or enter log message,\n"
              "terminated with single '.' (or CTRL+D to cancel)\n" % editor)
            rows = []
            while 1:
                try:
                    row = raw_input('>> ')
                except EOFError:
                    return None
                if row == '.':
                    # We need a trailing newline
                    rows.append('')
                    break
                rows.append(row)
            return '\n'.join(rows)

        class EditorError(Exception):
            pass

        cmdargs = [editor, name]
        try:
            try:
                # Capture stderr and discard it
                retcode = subprocess.call(" ".join(cmdargs), shell=True,
                    stderr=subprocess.PIPE)
            except __HOLE__:
                raise EditorError
            if retcode != 0:
                raise EditorError
        except EditorError:
            # Error running the editor
            msg = _getMessageNoEditor()
            if msg is None:
                return False
            self.message.set(msg)
            return True

        newMsg = open(name).read()
        os.unlink(name)

        if newMsg == msg:
            return False

        if newMsg[-len(msg):]:
            newMsg = newMsg[:-len(msg)]

        newMsg = string.strip(newMsg)
        newMsg += '\n'
        self.setMessage(newMsg)
        return True
dataset/ETHPy150Open sassoftware/conary/conary/changelog.py/ChangeLog.getMessageFromUser