Python workflow 模块,ICON_WARNING 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用workflow.ICON_WARNING

项目:pomodoro-alfred    作者:ecbrodie    | 项目源码 | 文件源码
def main(wf):
    query = None

    args = wf.args
    if len(wf.args):
        query = wf.args[0]

    items = all_items()
    if query:
        items = wf.filter(query, items, lambda item: item['arg'])

    if not items:
        wf.add_item('Unknown pomo command', icon=ICON_WARNING)

    for item in items:
        wf.add_item(item['title'], item['description'], arg=item['arg'], valid=True)

    # Send output to Alfred. You can only call this once.
    wf.send_feedback()
项目:alfred-unicode    作者:deanishe    | 项目源码 | 文件源码
def search(query, cursor):
    try:
        cursor.execute("""SELECT name, hex, entity, icon FROM
                    (SELECT rank(matchinfo(chars))
                    AS r, name, hex, entity, icon
                    FROM chars WHERE chars MATCH ?)
                    ORDER BY r DESC LIMIT ?""", (query, config.MAX_RESULTS))
        results = cursor.fetchall()
    except sqlite3.OperationalError as err:
        if b'malformed MATCH' in err.message:
            wf.add_item('Invalid query', icon=ICON_WARNING)
            wf.send_feedback()
            return
        else:
            raise err
    log.debug('{:d} results for `{}`'.format(len(results), query))
    return results
项目:alfredToday    作者:jeeftor    | 项目源码 | 文件源码
def get_login(wf, show_alfred_items=True):
    stored_login = get_stored_login(wf)
    auto_login= autodetect_login(wf)
    if stored_login is None:

        if auto_login is None:
            if show_alfred_items:
                login_item = wf.add_item('Please set Login', 'Could not auto detect a login from keychain for ' + CREDENTIAL_ENTRY,
                        valid=True, icon=ICON_WARNING)
            ret = None
        else:
            if show_alfred_items:
                login_item = wf.add_item('Exchange Login', "(autodetcted) " + auto_login, arg=auto_login, valid=True, icon='img/ok.png')
            ret = auto_login

    else:
        if show_alfred_items:
            login_item = wf.add_item('Exchange Login', stored_login, arg=stored_login, valid=True, icon='img/ok.png')
        ret = stored_login

    if show_alfred_items:
        login_item.setvar('text_to_display', 'Exchange Login:')
        login_item.setvar('settings_value' , 'exchange_login')

    return ret
项目:alfredToday    作者:jeeftor    | 项目源码 | 文件源码
def get_password(wf, show_alfred_items=True):
    stored_password = get_stored_password(wf)
    auto_password   = autodetect_password(wf)

    if stored_password is None:

        if auto_password is None:
            if show_alfred_items:
                password_item = wf.add_item('Please set Exchange Password', 'Could not auto detect password from keychain for ' + CREDENTIAL_ENTRY, valid=True, icon=ICON_WARNING)
            ret = None
        else:
            if show_alfred_items:
                password_item = wf.add_item('Exchange Password stored in keychain', '(auto detected from keychain)', valid=True, icon='img/ok.png')
            ret = auto_password

    else:
        if show_alfred_items:
            password_item = wf.add_item('Exchange Password stored in keychain', 'xxxxxxxxxx', valid=True, icon='img/ok.png')
        ret = stored_password

    if show_alfred_items:
        password_item.setvar('text_to_display','Exchange Password')
        password_item.setvar('settings_value' ,'password')
    return ret
项目:alfred-ec2    作者:SoMuchToGrok    | 项目源码 | 文件源码
def list_profiles(wf, query):
    profiles = get_profiles()

    if query:
        profiles = wf.filter(query, profiles, key=search_key_for_profile)

    if not profiles:
        wf.add_item('No profile found', icon=ICON_WARNING)
        wf.send_feedback()
        return 0

    for profile in profiles:
        wf.add_item(arg=profile['name'],
                    icon=ICON_NETWORK,
                    title=profile['name'],
                    valid=True)

    wf.send_feedback()
项目:alfred-ec2    作者:SoMuchToGrok    | 项目源码 | 文件源码
def query_instances(wf, query):
    account = wf.settings.get('active_account', 'default')
    aws_access_key_id = wf.settings[account].get('aws_access_key_id', None)
    profile_name = wf.settings[account].get('profile_name', 'default')
    user_name = wf.settings[account].get('user_name', 'ec2-user')

    region = wf.settings[account].get('region', 'eu-west-1')

    def wrapper():
        return get_recent_instances(region, profile_name)

    instances = wf.cached_data('instances-%s' % account, wrapper, max_age=10)

    if query:
        instances = wf.filter(query, instances, key=search_key_for_instance)

    if not instances:
        wf.add_item('No instances found', icon=ICON_WARNING)
        wf.send_feedback()
        return 0

    for instance in instances:
        wf.add_item(arg="{}|{}|{}".format(profile_name, user_name, instance['ip']),
                    uid=instance['ip'],
                    icon=ICON_NETWORK,
                    subtitle=instance['desc'],
                    title=instance['name'],
                    copytext=instance['ip'],
                    valid=True)

    wf.send_feedback()
项目:alfred-arxiv-workflow    作者:wookayin    | 项目源码 | 文件源码
def main(wf):
    import argparse
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('query', default=None, type=str)
    args = parser.parse_args()
    log.debug('args : {}'.format(args))

    query = args.query
    # FUCK arxiv.py is too stupid why it is not quoting
    ret = arxiv.query(urllib.quote(query),
                      max_results=25)

    if not ret:
        wf.add_item('No matchings', icon=workflow.ICON_WARNING)

    for entry in ret:
        title = entry['title']
        authors = ', '.join(entry['authors'])
        bundle = ', '.join(t['term'] for t in entry['tags'])
        url = entry['id']

        identifier, version = parse_arxiv_url(url)     # 1704.12345
        canonical_url = 'https://arxiv.org/abs/%s' % identifier

        item = wf.add_item(
            title="[%s] %s" % (identifier, title),
            subtitle="%s [%s]" % (authors, bundle),
            valid=True,
            arg=identifier,
            uid=identifier,
            type='file',
            #icon='icon.png',
        )
        item.add_modifier('alt', 'http://arxiv.org/pdf/%s' % identifier,
                          arg=identifier)
        item.add_modifier('shift', 'Copy the identifier %s' % identifier,
                          arg=identifier)
        item.add_modifier('cmd', 'Copy the arXiv abs URL: %s' % canonical_url,
                          arg=canonical_url)
        item.add_modifier('ctrl', 'Copy markdown link: [[%s] %s](%s)' % (identifier, title, canonical_url),
                          arg="[[%s] %s](%s)" % (identifier, title, canonical_url))

    wf.send_feedback()
    return 0
项目:alfred-papers3-workflow    作者:wookayin    | 项目源码 | 文件源码
def main(wf):
    import argparse
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('query', default=None, type=str)
    args = parser.parse_args()
    log.debug('args : {}'.format(args))

    items = wf.cached_data('papers_all', read_papers_entries,
                           max_age=600) # cache 600 seconds
    log.debug('Cached {} items from Papers3'.format(len(items)))

    # fuzzy-search by query
    # http://www.deanishe.net/alfred-workflow/user-manual/filtering.html?highlight=match_all
    ret = wf.filter(args.query, items,
                    key=lambda t: (t['title'] + ' ' +
                                   t['author names'] + ' ' +
                                   t['bundle name'] + ' ' +
                                   t['keyword names']),
                    match_on=(workflow.MATCH_ALL ^ workflow.MATCH_ALLCHARS),
                    min_score=20,
                    include_score=True)

    #ret.sort(key=lambda t: t[1], reverse=True)

    if not ret:
        wf.add_item('No matchings', icon=workflow.ICON_WARNING)

    for entry, score, _ in ret:
        title, authors = entry['title'], entry['author names']
        bundle, year = entry['bundle name'], entry['publication year']
        citekey = entry['citekey']
        wf.add_item(title=title,
                    subtitle=authors + (" (%s %s)" % (bundle, year)), #+ (" (%.3f)" % score),
                    modifier_subtitles={
                        'alt' : citekey,
                        'shift' : 'Copy the BibTeX record of ' + citekey,
                    },
                    valid=True,
                    arg=citekey,
                    uid=citekey,
                    type='file',
                    icon='icon.png'
                    )

    wf.send_feedback()
    return 0