Skip to content

Commit

Permalink
Merge pull request whyliam#31 from liszd/develop
Browse files Browse the repository at this point in the history
更新 有道翻译 workflow v1.2.5
  • Loading branch information
whyliam authored Feb 7, 2017
2 parents 02f0ac8 + a36dd39 commit 7c68a7a
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 112 deletions.
2 changes: 1 addition & 1 deletion License
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 [email protected]
Copyright (c) 2015

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# whyliam.workflows.youdao

## 有道翻译 workflow v1.2.4
## 有道翻译 workflow v1.2.5

默认快捷键 "yd",查看翻译结果。

Expand All @@ -25,11 +25,11 @@
![No JSON object could be decoded](https://cloud.githubusercontent.com/assets/12092275/16805774/590a4064-4944-11e6-9b12-d8218024c032.png)

请删除该文件
`/Users/用户名/Library/Application\ Support/Alfred\ 2/Workflow\ Data/whyliam.workflows.youdao`
`/Users/用户名/Library/Application\ Support/Alfred\ 3/Workflow\ Data/whyliam.workflows.youdao`

### 下载

[点击下载](https://github.com/liszd/whyliam.workflows.youdao/releases/download/1.2.4/whyliam.workflows.youdao.alfredworkflow)
[点击下载](https://github.com/liszd/whyliam.workflows.youdao/releases/download/1.2.5/whyliam.workflows.youdao.alfredworkflow)

## Demo

Expand Down Expand Up @@ -57,7 +57,7 @@

## The MIT License (MIT)

Copyright (c) 2015 [email protected]
Copyright (c) 2015

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 8 additions & 6 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ open "http://dict.youdao.com/search?q=`echo $query | awk 'BEGIN{FS="$"} {print $
<integer>1</integer>
<key>argumenttext</key>
<string>yd </string>
<key>focusedappvariable</key>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>-1</integer>
<integer>0</integer>
<key>hotmod</key>
<integer>1048576</integer>
<key>hotstring</key>
<string>double tap</string>
<integer>0</integer>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
Expand All @@ -289,7 +291,7 @@ open "http://dict.youdao.com/search?q=`echo $query | awk 'BEGIN{FS="$"} {print $
</dict>
</array>
<key>readme</key>
<string>有道翻译 Workflow v1.2.4
<string>有道翻译 Workflow v1.2.5
默认快捷键 "yd", 查看翻译结果。
Expand Down Expand Up @@ -366,7 +368,7 @@ open "http://dict.youdao.com/search?q=`echo $query | awk 'BEGIN{FS="$"} {print $
</dict>
</dict>
<key>version</key>
<string>1.2.4</string>
<string>1.2.5</string>
<key>webaddress</key>
<string>https://github.com/liszd/whyliam.workflows.youdao</string>
</dict>
Expand Down
Binary file modified whyliam.workflows.youdao.alfredworkflow
Binary file not shown.
Empty file modified workflow/Notify.tgz
100644 → 100755
Empty file.
Empty file modified workflow/__init__.py
100644 → 100755
Empty file.
28 changes: 10 additions & 18 deletions workflow/background.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# Created on 2014-04-06
#

"""
Run background tasks
"""
"""Run background tasks."""

from __future__ import print_function, unicode_literals

Expand All @@ -34,40 +32,38 @@ def wf():


def _arg_cache(name):
"""Return path to pickle cache file for arguments
"""Return path to pickle cache file for arguments.
:param name: name of task
:type name: ``unicode``
:returns: Path to cache file
:rtype: ``unicode`` filepath
"""

return wf().cachefile('{0}.argcache'.format(name))


def _pid_file(name):
"""Return path to PID file for ``name``
"""Return path to PID file for ``name``.
:param name: name of task
:type name: ``unicode``
:returns: Path to PID file for task
:rtype: ``unicode`` filepath
"""

return wf().cachefile('{0}.pid'.format(name))


def _process_exists(pid):
"""Check if a process with PID ``pid`` exists
"""Check if a process with PID ``pid`` exists.
:param pid: PID to check
:type pid: ``int``
:returns: ``True`` if process exists, else ``False``
:rtype: ``Boolean``
"""
"""
try:
os.kill(pid, 0)
except OSError: # not running
Expand All @@ -76,8 +72,7 @@ def _process_exists(pid):


def is_running(name):
"""
Test whether task is running under ``name``
"""Test whether task is running under ``name``.
:param name: name of task
:type name: ``unicode``
Expand Down Expand Up @@ -113,7 +108,6 @@ def _background(stdin='/dev/null', stdout='/dev/null',
:type stderr: filepath
"""

# Do first fork.
try:
pid = os.fork()
Expand Down Expand Up @@ -150,8 +144,7 @@ def _background(stdin='/dev/null', stdout='/dev/null',


def run_in_background(name, args, **kwargs):
"""Pickle arguments to cache file, then call this script again via
:func:`subprocess.call`.
r"""Cache arguments then call this script again via :func:`subprocess.call`.
:param name: name of task
:type name: ``unicode``
Expand All @@ -175,7 +168,6 @@ def run_in_background(name, args, **kwargs):
return immediately and will not run the specified command.
"""

if is_running(name):
wf().logger.info('Task `{0}` is already running'.format(name))
return
Expand All @@ -199,12 +191,12 @@ def run_in_background(name, args, **kwargs):


def main(wf): # pragma: no cover
"""
"""Run command in a background process.
Load cached arguments, fork into background, then call
:meth:`subprocess.call` with cached arguments
:meth:`subprocess.call` with cached arguments.
"""

name = wf.args[0]
argcache = _arg_cache(name)
if not os.path.exists(argcache):
Expand Down
Empty file modified workflow/notify.py
100644 → 100755
Empty file.
Empty file modified workflow/update.py
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion workflow/version
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.1
1.24
Empty file modified workflow/web.py
100644 → 100755
Empty file.
Loading

0 comments on commit 7c68a7a

Please sign in to comment.