1,105,578 Community Members

Getting output from AS function from within Python

Member Avatar
FALL3N
Junior Poster in Training
88 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 
import os;

def callAS(cmd):
	os.system(cmd);

def selectFile():
	 callAS("""osascript -e 'tell application "Finder" to return choose file "Select the file:"'""")

def fixPath(raw):
	arr = raw.split(' ');
	return(str(arr[1]));

thePath = selectFile()
thePath = fixPath(thePath);
print(thePath);

When the above code is run in IDLE, it just gives an error. But, when the above code is run in BBedit, it returns an error (saying that I can't split an object of null type), but also outputs alias First:Applications:Adapter.app: ... How do I get the output from an AS function run from within Python?

Member Avatar
Gribouillis
Posting Maven
3,456 posts since Jul 2008
Reputation Points: 1,140 [?]
Q&As Helped to Solve: 884 [?]
Skill Endorsements: 18 [?]
Moderator
 
1
 

Perhaps use this snippet http://www.daniweb.com/software-development/python/code/257449 instead of os.system()

Member Avatar
FALL3N
Junior Poster in Training
88 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

yup, thanks a lot!

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: