Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #4

Merged
merged 11 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make errors more friendly
  • Loading branch information
you-n-g committed Jul 21, 2020
commit 0eb6f36f9b473afec4769226a0c1443c842c1060
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ This package is under development. We will release it soon in the future.

# Installation

[fzf](https://github.com/junegunn/fzf) is required
<!-- [fzf](https://github.com/junegunn/fzf) is required -->
```shell
pip install wan # TODO: upload this to pip source
```

## config

Expand Down
2 changes: 1 addition & 1 deletion wan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def wait(self, pid=None, message=None, idle=False, patience=20, sleep=3):
if pid is None:
pid = get_pid_via_fzf()
if pid is None:
logger.info('No process selected')
logger.info('No process selected, You can used --pid to specify the process')
return

process_info = self._get_process_info(pid)
Expand Down
8 changes: 7 additions & 1 deletion wan/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
from iterfzf import iterfzf
from loguru import logger


def iter_ps():
Expand All @@ -14,7 +15,12 @@ def get_pid_from_line(line):


def get_pid_via_fzf(exact=True):
return get_pid_from_line(iterfzf(iter_ps(), multi=False, exact=exact))
try:
selected_line = iterfzf(iter_ps(), multi=False, exact=exact)
except PermissionError as e:
logger.error(f'Please make {e.filename} executable(e.g `chmod a+x {e.filename}`).')
return None
return get_pid_from_line(selected_line)


if __name__ == "__main__":
Expand Down