Beispiel #1
0
	# add an optional query and save it to 'query'
	parser.add_argument('text', nargs='?', default=None)
	# parse the script's arguments
	args = parser.parse_args(wf.args)

	try:
		ws = pl.readPlist('info.plist')['variables']['ws']
	except:
		ws = ''
		wf.add_item('Error with env vars','Please report to developer (tab) or try reconfiguring',autocomplete=':help',valid=False)
	if os.path.isfile('static/overlay.gif') and os.path.isfile('static/grayscale.gif') and ws!= '':
		if  wf.args[0]=='':
			wf.add_item('Radar','Download latest NOAA radar images',arg=ws,valid=True)
		if len(wf.args[0])<2:
			wf.add_item('Radar [Location]','Find local station, cache local static data',autocomplete=' ',valid=False)
	else:
		wf.add_item('Radar','Must (re)congfigure location first: autocomplete this item and type your location',autocomplete=' ',valid=False)
	
	wf.send_feedback()

def help():
	wf.open_help()

if __name__ == '__main__':
	wf = Workflow(libraries=['./lib'], 
				update_settings=UPDATE_SETTINGS,
				help_url=HELP_URL,
				capture_args=True)
	log=wf.logger
	wf.magic_prefix=':'
	sys.exit(wf.run(main))
    for (name, h, entity, icon) in results:
        icon = os.path.join(config.ICON_DIR, icon)
        if not os.path.exists(icon):
            icons_to_generate.add(h)
            # icon = os.path.join('icons', 'unknown.png')
        subtitle = 'U+{}'.format(h)
        wf.add_item(name,
                    subtitle,
                    autocomplete='{} {} '.format(name, config.DELIMITER),
                    copytext=subtitle,
                    arg=icon,
                    type='file',
                    icon=icon)

    # Generate icons if need be
    generate_icons(icons_to_generate,
                   config.ICON_DIR,
                   logfile=wf.logfile,
                   font=wf.settings.get('font'),
                   size=wf.settings.get('size'))
    wf.send_feedback()


if __name__ == '__main__':
    wf = Workflow(default_settings=config.DEFAULT_SETTINGS,
                  update_settings=config.UPDATE_SETTINGS,
                  help_url=config.HELP_URL)
    wf.magic_prefix = 'wf:'
    log = wf.logger
    sys.exit(wf.run(main))
import sys, os, plistlib as pl
import workflow
from workflow import Workflow, ICON_INFO
from workflow.background import run_in_background, is_running
from plistlib import readPlist

def main(wf):
	wf.send_feedback()

if __name__ == '__main__':
	wf = Workflow(capture_args=True)
	log=wf.logger
	wf.magic_prefix='wf:'
	sys.exit(wf.run(main))
        else:
            icon = ICON_KEYCHAIN_APPLICATION

        subtitle = ''
        if item.account:
            subtitle += item.account
        if item.comments:
            if subtitle:
                subtitle += ', '
            subtitle += item.comments

        wf.add_item(title=item.name or item.service,
                    subtitle=subtitle,
                    arg=item.service + '|||' + ('internet' if item.type == 'inet' else 'generic'),
                    valid=True,
                    icon=icon)

    # Send the results to Alfred as XML
    wf.send_feedback()
    return 0

if __name__ == u"__main__":
    wf = Workflow()
    wf.magic_prefix = 'wf:'  # Change prefix to `wf:`

    def opensettings():
        subprocess.call(['open', wf.settings_path])
        return 'Opening workflow settings...'

    wf.magic_arguments['settings'] = opensettings
    sys.exit(wf.run(main))