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
		return True
		return False
Shout out to Shawn Rice for the conceptual backbone to this code. 
Hope someone else finds it useful.
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...