Logo Search packages:      
Sourcecode: zope-externaleditor version File versions  Download package

def ExternalEditor::Plugins::excel::EditorProcess::isAlive (   self )
Returns true if the editor process is still alive

Definition at line 50 of file excel.py.

00050                      :
        """Returns true if the editor process is still alive"""
        tries = 0
        head, tail = os.path.split(self.file)
        head, tail = head.lower(), tail.lower()

        try:
            for doc in self.excelapp.Workbooks:
                if head == doc.Path.lower() and tail == doc.Name.lower():
                    return 1
            return 0
        except pythoncom.com_error, why:
            # COM will reject the call to enumerate the docs if the user is
            # doing anything interactive at the time the call is made.  The
            # symptom is a COM error numbered -2147418111 named "Call rejected
            # by callee".  This could happen indefinitely while a user is
            # camped on a cell waiting for input, so the only sane thing to do
            # is to return true and wait til the next call to really do the
            # check.
            if why[0] == -2147418111:
                return 1
            else:
                raise
        except AttributeError, why:
            # No one knows why this happens but sometimes while a user is
            # editing, win32com\client\dynamic.py will raise an error
            # signifying that the attributes we attempt to look up on the Excel
            # document can't be found.  Ignore this and return 1 if so,
            # waiting for the next go-around to check again (eventually we do
            # get access to the attributes).
            if (isinstance(why, types.StringType) or
                isinstance(why, types.UnicodeType)):
                if why.endswith('Path') or why.endswith('Name'):
                    return 1
            raise
        except TypeError, why:
            # Again, who knows why this happens but the enumeration of
            # workbooks can occasionally lead to a type error, e.g.:
            # Traceback (most recent call last):
            # File "zopeedit.py", line 764, in ?
            # File "zopeedit.py", line 372, in launch
            # File "Plugins\excel.pyc", line 57, in isAlive
            # File "win32com\client\dynamic.pyc", line 210, in __getitem__
            # TypeError: This object does not support enumeration
            # We ignore this and return true.
            why = str(why)
            if why.endswith('enumeration'):
                return 1
            raise


Generated by  Doxygen 1.6.0   Back to index