Skip to content

Commit

Permalink
update not_update
Browse files Browse the repository at this point in the history
  • Loading branch information
whyliam authored and whyliam committed Feb 3, 2020
1 parent e2c6012 commit 2dfa7f1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
15 changes: 13 additions & 2 deletions splitargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ def get_args(wf):
operation = arg_array[5]

# 是否有更新
if operation == 'update':
if operation == 'update_now':
wf.start_update()
return
elif operation == 'update_with_url':
import webbrowser
url = "https://github.com/whyliam/whyliam.workflows.youdao/releases"
webbrowser.open(url)
return
elif operation == 'update_next_time':
return

# 是否有错误
elif operation == 'error':
Expand Down Expand Up @@ -91,5 +99,8 @@ def get_args(wf):


if __name__ == '__main__':
wf = Workflow3()
wf = Workflow3(update_settings={
'github_slug': 'whyliam/whyliam.workflows.youdao',
'frequency': 0
})
sys.exit(wf.run(get_args))
Binary file modified whyliam.workflows.youdao.alfred3workflow
Binary file not shown.
Binary file modified whyliam.workflows.youdao.alfredworkflow
Binary file not shown.
20 changes: 13 additions & 7 deletions youdao.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import hashlib
import time
import sys
import random
reload(sys)
sys.setdefaultencoding('utf8')

Expand Down Expand Up @@ -93,8 +94,6 @@ def sentry_message(errorCode, msg):

def get_youdao_url(query):
# 构建有道翻译URL
import random

zhiyun_id = os.getenv('zhiyun_id', '').strip()
zhiyun_key = os.getenv('zhiyun_key', '').strip()
if zhiyun_id and zhiyun_key:
Expand Down Expand Up @@ -194,17 +193,24 @@ def get_history_data():


def is_expired():
# 检查更新
if wf.update_available:
arg = get_arg_str('', '', operation='update')
# 检查更新,随机检测
if random.random() < 0.01 and wf.update_available:
arg = get_arg_str('', '', operation='update_now')
wf.add_item(
title='马上更新', subtitle='有新版本更新', arg=arg,
title='马上更新(点击后请打开 Alfred 的 Preference 完成更新)',
subtitle='有新版本更新', arg=arg,
valid=True, icon=ICON_UPDATE)

arg = get_arg_str('', '', operation='not_update')
arg = get_arg_str('', '', operation='update_with_url')
wf.add_item(
title='手动更新', subtitle='有新版本更新', arg=arg,
valid=True, icon=ICON_ERROR)

arg = get_arg_str('', '', operation='update_next_time')
wf.add_item(
title='暂不更新', subtitle='有新版本更新', arg=arg,
valid=True, icon=ICON_ERROR)

wf.send_feedback()
return True
return False
Expand Down

0 comments on commit 2dfa7f1

Please sign in to comment.