[Zope-CVS] CVS: Products/ExternalEditor/Plugins - homesite.py:1.1 photoshop.py:1.1 photoshp.py:1.1 __init__.py:1.2 homesite5.py:1.2

Casey Duncan casey@zope.com
Sun, 1 Sep 2002 01:03:47 -0400


Update of /cvs-repository/Products/ExternalEditor/Plugins
In directory cvs.zope.org:/tmp/cvs-serv8571/Plugins

Modified Files:
	__init__.py homesite5.py 
Added Files:
	homesite.py photoshop.py photoshp.py 
Log Message:
Added Photoshop plugin
Added plugin alias for HomeSite
Made plugin dependencies explicit for py2exe
Fixed a couple of minor issues in zopeedit
Added plugins to docs


=== Added File Products/ExternalEditor/Plugins/homesite.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""External Editor HomeSite Plugin Alias

$Id: homesite.py,v 1.1 2002/09/01 05:03:43 caseman Exp $
"""

# Alias for homesite5
from homesite5 import EditorProcess



=== Added File Products/ExternalEditor/Plugins/photoshop.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""External Editor Photoshop Plugin Alias

$Id: photoshop.py,v 1.1 2002/09/01 05:03:43 caseman Exp $
"""

# Alias for photoshp
from photoshp import EditorProcess



=== Added File Products/ExternalEditor/Plugins/photoshp.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""External Editor Photoshop Plugin

$Id: photoshp.py,v 1.1 2002/09/01 05:03:43 caseman Exp $
"""

# Note that Photoshop's com API is not terribly rich and external editor
# cannot discern from it when a Photoshop file has been closed.
# Therefore Photoshop should probably be used without DAV locks or
# with always_borrow_locks enabled

from time import sleep
import win32com
from win32com import client # Initialize Client module

class EditorProcess:
    def __init__(self, file):
        """Launch editor process"""
        ps = win32com.client.Dispatch('Photoshop.Application')
        # Try to open the file, keep retrying until we succeed or timeout
        i = 0
        timeout = 45
        while i < timeout:
            try:
                fileconn = ps.Open(file)
            except:
                print 'open failure: ', i
                i += 1
                if i >= timeout:
                    raise RuntimeError('Could not launch Photoshop.')
                sleep(1)
            else:
                break
        self.fileconn = fileconn
        self.file = file
        
    def wait(self, timeout):
        """Wait for editor to exit or until timeout"""
        sleep(timeout)
            
    def isAlive(self):
        """Returns true if the editor process is still alive"""
        # Photoshop has no API for checking if a file is still open
        # This workaround just checks if the file connection is
        # still accessible. It will be until Photoshop itself is closed 8^/
        try:
            self.fileconn.Title # See if the file is still accessible
        except:
            return 0
        return 1

def test():
    print 'Connecting to Photoshop...'
    f = EditorProcess('C:\\Windows\\Cloud.gif')
    print ('%s is open...' % f.fileconn.Title),
    if f.isAlive():
        print 'yes'
        print 'Test Passed.'
    else:
        print 'no'
        print 'Test Failed.'
    
if __name__ == '__main__':
    test()


=== Products/ExternalEditor/Plugins/__init__.py 1.1 => 1.2 ===
--- Products/ExternalEditor/Plugins/__init__.py:1.1	Sat Aug 31 00:17:35 2002
+++ Products/ExternalEditor/Plugins/__init__.py	Sun Sep  1 01:03:43 2002
@@ -0,0 +1,10 @@
+""" External Editor Plugins """
+
+def importAll():
+    # Assert plugin dependancies for py2exe
+    # All plugins must be imported here to be distributed
+    # in the Windows binary package!
+    import homesite
+    import homesite5
+    import photoshop
+    import photoshp


=== Products/ExternalEditor/Plugins/homesite5.py 1.1 => 1.2 ===
--- Products/ExternalEditor/Plugins/homesite5.py:1.1	Sat Aug 31 00:17:35 2002
+++ Products/ExternalEditor/Plugins/homesite5.py	Sun Sep  1 01:03:43 2002
@@ -19,7 +19,6 @@
 from time import sleep
 import win32com
 from win32com import client # Initialize Client module
-from zopeedit import fatalError
 
 class EditorProcess:
     def __init__(self, file):
@@ -61,7 +60,7 @@
     f = EditorProcess(fn)
     print 'Attached to %s %s' % (`f.hs`, f.hs.VersionText)
     print ('%s is open...' % fn),
-    if f.isAlive:
+    if f.isAlive():
         print 'yes'
         print 'Test Passed.'
     else: