[Pythonmac-SIG] Appscript

2008-12-11 Thread Conan C. Albrecht
I'm using appscript to script Word and BibDesk.  I need to run the  
script from the "Scripts" menu in one of these programs.  However,  
my .py script won't show up on their menus, even if the script is in  
the right directory.  The python script will show up on the system- 
wide scripts menu, but not on an application's menu.  I changed the  
file extension to .scpt, and it still won't show up.


To fix this, I added a simple AppleScript to the same (scripts)  
directory. I've included this at the bottom, if it helps.  So the  
AppleScript runs first, then it calls "do shell script" to run the  
Python program.  My problem is that the script can't call any GUI  
functions, such as the following:


import osax
sa = osax.OSAX()  # allows use of standard additions (like display  
dialog)

sa.display_dialog("Hi world")

If I run from the command line, the dialog shows up fine.  If I run  
from within Word or BibDesk, the dialog doesn't show up at all.  I  
think it is because "do shell script" runs it in an invisible shell  
that can't access the main GUI.  So the dialog comes up, but is not  
visible to the user.  The calling application (Word or BibDesk)  
freezes since the dialog is "up" but can't be responded to by the user.


Is there a better way to do this?  How can I run Python scripts from  
the Scripts menu in a program?


Thanks in advance.

=
-- Get this script's directory and name
tell application "Finder" to (path to me) as Unicode text
set scriptname to POSIX path of result

-- Remove the .scpt extension, and append .py instead
set AppleScript's text item delimiters to {".scpt"}
set textItems to text items of scriptname
set AppleScript's text item delimiters to {""}
set scriptname to textItems as string
set scriptname to scriptname & ".py"

-- Run the script
do shell script "python '" & scriptname & "'"
===


Conan C. Albrecht, Ph.D.
Information Systems Department
Brigham Young University
Email: co...@warp.byu.edu
Phone: +1-801-805-1615
Web/Blog: http://warp.byu.edu/



smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] LOLpatents

2008-12-12 Thread Conan C. Albrecht
IANAL, but in my watching of open source projects for many years, if  
you have prior work to the patent, you're fine.  If they decide to sue  
you, you can just show that your project predates the patent.  This  
one was filed in 2007, so I think things like appscript are fine.   
(does appscript predate June 8, 2007?)  Again, I'm not a lawyer.


When it comes to software patents, 99 percent of them are bunk.  I  
agree that patents are necessary to let new ideas flourish, but the  
concept has gone way too far.  And especially so in computers.  People  
should get 2-3 years on any patent to give them time to move ahead of  
the competition.  After that, it should be fair game.


Check out this web site on the topic: http://www.linuxfoundation.org/en/Osapa

________
Conan C. Albrecht, Ph.D.
Information Systems Department
Brigham Young University
Email: co...@warp.byu.edu
Phone: +1-801-805-1615
Web/Blog: http://warp.byu.edu/

On Dec 12, 2008, at 16:27, has wrote:


Hey folks,

Look what I ran across today:

http://appft1.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&u=%2Fnetahtml%2FPTO%2Fsearch-adv.html&r=1&p=1&f=G&l=50&d=PG01&S1=%28scripting+AND+bridge%29.TTL.&OS=ttl/(scripting+and+bridge)&RS=TTL/(scripting+AND+bridge)

Still making my own mind up if I should be worried or amused by it.  
Not being familiar with the US patent system though, I'm curious if  
anyone else has any thoughts.


Do companies like Apple automatically file patents on everything  
they write, regardless of whether or not it's actually novel [1] or  
even correct [2]?


How concerned should third-party developers of very similar products  
(e.g. me) be?


Does the US patent office check for prior art themselves before  
deciding if an application is patent-worthy, or is it contingent on  
the patent submitter and/or general public to provide examples or  
prior art? (And if the latter, how is it done?)



Cheers,

has


[1] e.g. The number of original concepts in Scripting Bridge - or  
appscript, for that matter - wouldn't fill the back of a postage  
stamp. Between Frontier, Mac::Glue, gensuitemodule, JavaScriptOSA,  
aeve, appscript and any other AE bridges I've forgotten, not to  
mention the myriad ORM bridges out there that do similar things, I  
think the territory is pretty well covered. The only noticeably new  
wrinkle that I can think of in SB is its selective automatic  
dispatching of 'get' events as determined by what the reference is  
pointing at (an object attribute vs. a one-to-one/one-to-many  
relationship), although that might've appeared first in RubyOSA.


[2] The bit about SB performing significantly better than prior art  
is BS. ObjC appscript has pretty much the same performance  
characteristics when building and sending events and unpacking  
replies. And all appscript implementations are faster at creating  
application objects - significantly so in the case of large, complex  
applications such as InDesign (15 sec for SB [3] vs 0.2 sec for py- 
appscript the last time I checked).


[3] Via Python+PyObjC as sdp just puked when I tried to create an  
InDesign.h header so I could try it in ObjC.


--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Status of Python 3.0 for Mac?

2008-12-14 Thread Conan C. Albrecht
I was surprised at the lack of a Mac build as well.  I think the  
reason is that there are few libraries available for 3.0 right now.   
For example, it will be some time before wxPython, the various  
database drivers, and other popular add-ons will be updated to the 3.0  
syntax.  I installed Py3 for Mac, but there isn't a lot I can do with  
it yet.  I think many are in this camp.


If you want to install it now (like many of us have), here's a good  
page about how to compile it.  It's pretty easy.


http://farmdev.com/thoughts/66/python-3-0-on-mac-os-x-alongside-2-6-2-5-etc-/

I have no idea when the .dmg download will be available.

________
Conan C. Albrecht, Ph.D.
Information Systems Department
Brigham Young University
Email: co...@warp.byu.edu
Phone: +1-801-805-1615
Web/Blog: http://warp.byu.edu/

On Dec 14, 2008, at 08:16, Rodney Somerstein wrote:

Given the recent release of Python 3.0, I've been surprised to see  
no mention of a Mac release of this. Is anyone working on an  
official release? If so, is there an expected release date?


Thanks,

-Rodney
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Status of Python 3.0 for Mac?

2008-12-15 Thread Conan C. Albrecht
It's easy to have two or three Python installations.  They all sit in  
different directories and don't mess with each other.


The trick is to symlink the one you want to use in /usr/local/bin.   
You can actually look at where they are linked by typing "ls -l /usr/ 
local/bin/python*" at the terminal.


To change the link, type:

sudo ln -sf /Library/Frameworks/Python.framework/Versions/3.0/bin/ 
python3.0 /usr/local/bin/python


The above line will make 3.0 your standard python installation.  It's  
just a link, so you can do this as many times as you want to change to  
a different version.


________
Conan C. Albrecht, Ph.D.
Information Systems Department
Brigham Young University
Email: co...@warp.byu.edu
Phone: +1-801-805-1615
Web/Blog: http://warp.byu.edu/

On Dec 15, 2008, at 07:53, Ken Mankoff wrote:


On Mon, 15 Dec 2008, Nicholas Cole wrote:

On Sun, Dec 14, 2008 at 4:36 PM, Kevin Walzer   
wrote:


I'm curious who maintains the Mac builds of Python these days.  
It's not hard to build from source, of course, and that's what I  
do...but the binary installer is convenient for many people.


I want to install 3.0 to experiment with all the new features, but  
I don't want to do anything horrible to my default Leopard install,  
and I'd like to be able to remove 3.0 easily.  What's the most  
sensible way of doing this?  Setting a --prefix of /opt/python3.0 ,  
for example, or just using the default prefix and using make  
altinstall?


What are others doing?


I've had success with multiple python installs setting a custom -- 
prefix. I wrote what I did here:

http://spacebit.org/2008/10/26/python-and-wxpython

 -k.
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Status of Python 3.0 for Mac?

2008-12-16 Thread Conan C. Albrecht
You are all right in correcting me.  Here's a revised version of what  
to have to make multiple versions work:


If I type ls -l /usr/local/bin, I get the following in the list:

lrwxr-xr-x  1 root  wheel  72 Dec 16 10:05 python -> ../../../ 
Library/Frameworks/Python.framework/Versions/Current/bin/python
lrwxr-xr-x  1 root  wheel  71 Dec 16 10:05 pydoc -> ../../../ 
Library/Frameworks/Python.framework/Versions/Current/bin/pydoc
lrwxr-xr-x  1 root  wheel  79 Dec 16 10:05 python-config - 
> ../../../Library/Frameworks/Python.framework/Versions/Current/bin/ 
python-config
lrwxr-xr-x  1 root  wheel  73 Dec 16 10:05 pythonw -> ../../../ 
Library/Frameworks/Python.framework/Versions/Current/bin/pythonw


Note that they all go to the "Current" version.  Then, in the /Library/ 
Frameworks/Python.framework/Versions directory, I have:


drwxrwxr-x  10 root  admin  340 Oct  1 17:52 2.6
drwxr-xr-x   9 root  admin  306 Dec  9 14:01 3.0
lrwxr-xr-x   1 root  admin3 Dec 16 10:06 Current -> 2.6

Note that Current goes to 2.6.  To switch the "active" version of  
Python, just switch the symlink from 2.6 to 3.0.  That should switch  
the system.


________
Conan C. Albrecht, Ph.D.
Information Systems Department
Brigham Young University
Email: co...@warp.byu.edu
Phone: +1-801-805-1615
Web/Blog: http://warp.byu.edu/

On Dec 15, 2008, at 17:33, Christopher Barker wrote:


Dav Clark wrote:
It's easy to have two or three Python installations.  They all sit  
in different directories and don't mess with each other.
Not entirely true.  For example, anything that compiles against  
python with a bare "-framework Python" flag will grab the (I think)  
Current dir from /Library/Frameworks/Python.framework/Versions


True, but "Current" is just a symlink to a particular version - it's  
easy to put it back -- that's what I've done with 2.6 -- it's  
installed, but not set as current.


-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] py2app and Terminal

2008-12-24 Thread Conan C. Albrecht
Be sure the shebang is at the TOP of your script -- first line with  
nothing in front of it.


Py2app is really for GUI applications.  The solution Sean suggests is  
the best way for a terminal app.



Conan C. Albrecht, Ph.D.
Information Systems Department
Brigham Young University
Email: co...@warp.byu.edu
Phone: +1-801-805-1615
Web/Blog: http://warp.byu.edu/

On Dec 24, 2008, at 15:02, Sean DiZazzo wrote:

Give your app a shebang line """#!/usr/bin/env python"" and then  
rename the script ".command"


Then you can double click it and it will open a shell and run.

~Sean

On Wed, Dec 24, 2008 at 10:53 AM, Bryan Smith  
 wrote:

Hi everyone,

I am just finishing up an application and I would like to create an  
app file for my program. That said, it's CLI based with no GUI. If I  
try to make an app, it only seems to work if I have a GUI. Is it  
possible to tell py2app to open Terminal.app first and run my  
program through that?


Thanks,
Bryan

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig