简单的命令行工具,在目标程序完成工作后发出通知

nf的Python项目详细描述


https://img.shields.io/travis/NIC-MichalLabedzki/nf/v1.4.0?label=latest%20stable%20buildhttps://img.shields.io/coveralls/github/NIC-MichalLabedzki/nf/v1.4.0https://img.shields.io/pypi/v/nfhttps://img.shields.io/pypi/implementation/nfhttps://img.shields.io/pypi/pyversions/nf.svghttps://img.shields.io/pypi/l/nfhttps://img.shields.io/pypi/dm/nfhttps://img.shields.io/travis/NIC-MichalLabedzki/nf/master?label=latest%20development%20buildhttps://img.shields.io/coveralls/github/NIC-MichalLabedzki/nf/master?label=latest%20development%20coveragehttps://img.shields.io/github/repo-size/NIC-MichalLabedzki/nfhttps://img.shields.io/github/languages/code-size/NIC-MichalLabedzki/nfhttps://img.shields.io/github/commits-since/NIC-MichalLabedzki/nf/v1.4.0

简言之

nf是一个工具,用于通知用户其命令完成工作。例如,“make”程序需要很长时间才能完成。在

SPDX许可证标识符:0BSD

项目名称:nf 许可证:0BSD/免费公共许可证1.0.0 有关许可证的详细信息:https://opensource.org/licenses/0BSD

变更日志

来自1.3.2:
  1. –将run命令的detach作为分离的进程(stdout仍然相同,但进程的父进程依赖于系统)
  2. –等待pids等待一个或多个进程,然后运行cmd
  3. 添加新后端:win10toast persist
  4. 修复后端优先权赢
  5. 修复某些Linux配置上的“null”dbus接口
  6. 检测WSL(Win),但还不支持它

截图

  1. KDE截图:
Screenshot from KDE
  1. KDE截图:
Screenshot from KDE
  1. KDE截图:
Screenshot from KDE
  1. Android截图:
Screenshot from Android

不安装

它是一个文件脚本,因此您可以下载和使用它。 您也可以从没有任何依赖关系的源代码中运行它*(只需要python,也许还需要一些附带的模块)

*-Windows需要一些模块才能工作,请参阅设置.py了解详情。在2020-03-08,它们是:python-m install psutil win10toast persist

最新开发版本:

wget -c https://github.com/NIC-MichalLabedzki/nf/raw/master/nf.py

或者

^{pr2}$

或者把链接放到你的浏览器里

https://github.com/NIC-MichalLabedzki/nf/raw/master/nf.py

或者

git clone git@github.com:NIC-MichalLabedzki/nf.git
python ./nf.py

参见:

python ./nf.py --help

有关更多详细信息,请参阅CLI部分。在

以前的稳定版本:

wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.4.0/nf.py
wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.3.2/nf.py
wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.2.0/nf.py
wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.1.1/nf.py
wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.0.1/nf.py

安装

python -m pip install nf

或者

python -m pip install nf --user

或者

python -m pip install nf --user --proxy=YOUR.PROXY.IP.v4:YOUR_PORT

或者

python -m pip install -e git+https://github.com/NIC-MichalLabedzki/nf.git#egg=master

或者

git clone https://github.com/NIC-MichalLabedzki/nf.git
cd nf
python setup.py # or python -m pip install -e .

或者

git clone git@github.com:NIC-MichalLabedzki/nf.git
cd nf
python setup.py # or python -m pip install -e .

要更新:

python -m pip install nf -U

接口

有一种接口:CLI。在

如果您认为需要lib/module,请告诉我原因。 也许这是有原因的。在

CLI

CLI是命令行界面。所以你有一个叫做:nf的工具

$ python nf.py --help
usage: nf.py [-h][-l LABEL][-p][-n][-s][-w WAIT_FOR_PID][--detach][-b {paramiko,ssh,dbus,gdbus,notify-send,termux-notification,win10toast-persist,win10toast,plyer,plyer_toast,stdout}][-v][-d][--debugfile DEBUGFILE][--custom_notification_text CUSTOM_NOTIFICATION_TEXT][--custom_notification_title CUSTOM_NOTIFICATION_TITLE][--custom_notification_exit_code CUSTOM_NOTIFICATION_EXIT_CODE]
            cmd ...

Simple command line tool to make notification after target program finished work

positional arguments:
cmd
args

optional arguments:
-h, --help            show this help message and exit
-l LABEL, --label LABEL
                        Add humn readable text to custom job identification
-p, --print           Print notification text in stdout too
-n, --no-notify       Do not do annoying notifications
-s, --save            Save/append command and stat to .nf file
-w WAIT_FOR_PID, --wait-for-pid WAIT_FOR_PID
                        Wait for PID aka waitfor already run process finish
                        work. This option can be used multiple times.
--detach              Run command or waitfor pid in detached process
-b {paramiko,ssh,dbus,gdbus,notify-send,termux-notification,win10toast-persist,win10toast,plyer,plyer_toast,stdout}, --backend {paramiko,ssh,dbus,gdbus,notify-send,termux-notification,win10toast-persist,win10toast,plyer,plyer_toast,stdout}
                        Notification backend
-v, --version         Print version
-d, --debug           More print debugging on stdout
--debugfile DEBUGFILE
                        More print debugging save into file
--custom_notification_text CUSTOM_NOTIFICATION_TEXT
                        Custom notification text
--custom_notification_title CUSTOM_NOTIFICATION_TITLE
                        Custom notification title
--custom_notification_exit_code CUSTOM_NOTIFICATION_EXIT_CODE
                        Custom notification exit code

Examples:
nf make
nf ls
nf ls not_exist_file
nf sleep 2
nf -l sleeping sleep 2
nf -l `tty` ls
nf "ls | grep .py"
nf --detach sleep 15
nf -w 55555 ls
nf -w 55555 --detach echo Finished
nf -w 55555 -w 55556echo Done

"/home/nic/src/nf$ nf.py -p ls
LICENSE  nf.py  pytest.ini  README  README.dev  requirements-dev.txt  setup.cfg  setup.py  tox.ini
-----------------------------------------------------------
"/home/nic/src/nf$ ls" finished work.

Start time:   17:32.50
End time:     17:32.50
Elapsed time: 00:00.00
-----------------------------------------------------------

局限性

  1. 使用Jython:它没有dbus模块,回退到命令行。在
  2. 在KDE中观察到:可以删除具有相同正文(文本)的通知。为了避免这种情况,我添加了时间戳文本以使nofittations唯一。在

特点

  1. 通过termux通知支持Android通知(当然是通过termux
  2. 通过python模块或回退到notify send(libnotify0.7.7或0.7.8的一部分)
  3. 在stdout上打印通知的选项。在
  4. 选项将完整的命令行和stat保存到工作目录中。在
  5. 支持整个python实现/版本(至少不会崩溃并在stdout上打印)
  6. Case SSH:如果您使用SSH,则通过向后SSH连接将通知发送到您的本机系统(强制密码)
  7. 支持的通知后端:paramiko(ssh)、ssh、dbus、notify send、termux notification(Android)、win10toast(Windows)、plyer、plyer_toast、stdout
  8. 标签中的yakuake/konsole终端标签名称
  9. 屏幕/tmux会话/window/pane title/name in label
  10. Python模块aka库接口“导入nf;纳滤(['ls')”

nf使用的TMUX/SCREEN或如何测试它

1。tmux会话名称: .. bash::块代码

tmux rename-session sesja tmux list-sessions -F “#{session_name}”

2。tmux窗口名称: .. 代码块::bash

tmux rename-window okno tmux list-window -F “#{window_name} #{window_active}”

3。tmux窗格名称: .. 代码块::bash

printf ‘033]2;%s033' ‘this is a title’ tmux list-pane -F “#{pane_title} #{pane_active}”

4。获取父级的客户端pid(例如:yakuake) .. 代码块::bash

tmux display-message -p “#{client_pid}”

5。屏幕会话: .. 代码块::bash在

screen -list There are screens on: 7842.pts-30.nic (Attached) 6981.pts-25.nic (Attached) 2 Sockets in /tmp/screens/S-nic.

6。屏幕窗口标题 .. bash::块代码

screen -S 6981.pts-25.nic -Q title terefere

7。屏幕窗口: .. bash::块代码

screen -S 6981.pts-25.nic -Q windows 0* terefere 1 bash 2 bash 3- bash

托多

  1. –try version=1.3.2-下载(需要互联网连接),放在主目录中并使用它而不是安装的版本
  2. –try version=dev-要测试的最新git版本
  3. $HOME/.nf目录和“versions”子目录到下载的版本
  4. WSL支持

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android Action_Edit Intent无法像以前一样调用App Gallery来编辑图片   确保JRE兼容性的java适当程序(32或64位)   java JSONArray。for循环中的add(JSONObject)正在替换for循环中的旧值,数组由循环中的最后一个值组成   java需要帮助创建一个返回数组的方法,该数组的元素是另一个数组的平方   使用SmbFile w/groovy XmlSluper()创建xml。解析()Java   检查大小后的java ArrayIndexOutOfBoundsException   乘法表中的第k个最小元素   java 401 on请求,其中指定了'permitAll()'   java如何附加ORC文件   java hibernate类模型   java IDEA没有看到由自定义注释处理器生成的方法   Servlet中未声明java SerialVersionId   java linkedlist到达列表末尾时   java如何正确对齐EditText光标?   java 6编译器1.6上的eclipse重写方法错误   java如何在基于Jersey的RESTful Web服务中读取post数据   java如何在活动中正确使用接口?   Java的JIT编译器的工作速度有多快?