Jump to content

Check if another Workflow is installed


Recommended Posts

I need this functionality recently, and put this little function together. Thought I'd share it in case any one else ever needs it. Basically, I have a couple of workflows (ZotQuery, Skimmer, and SEND) which have overlapping functionality. Instead of copying code so that each can do everything the other does, I wanted to open up certain functionality within one (ZotQuery in this case) if another workflow is installed. So I wrote this little Python function that will check to see if a certain Alfred workflow is installed. It takes a workflow name as input and will output a Boolean true or false. 

def check_for_workflow(name):
	import os
	import plistlib

	workflows_dir = os.path.dirname(os.getcwd())
	all_wfs = os.walk(workflows_dir).next()[1]

	for wf in all_wfs:
		plist = workflows_dir + u"/" + wf + u"/info.plist"
		if os.path.isfile(plist):
			plist_info = plistlib.readPlist(plist)
			wf_name = plist_info['name'].lower()
			if wf_name == name.lower():
				found = True
				break
	try:
		found
		return True
	except:
		return False
Shout out to Shawn Rice for the conceptual backbone to this code. 
 
Hope someone else finds it useful.
stephen
Link to comment

FWIW, you should probably be looking for bundle IDs, not workflow names. There's a much greater chance of names being the same than IDs (though conversely, there's a greater chance of a workflow not having an ID than not having a name…).

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...