进入 Zenity 进度的两个过程 - 如何自动关闭?



>在我的 Youtube API 上传程序脚本运行时,我有一种肮脏的方式来显示上传速度,我在上传过程中测量特定端口的网络输出。我的问题是来自网络端口的数据在上传后继续,因此 Zenity 进度保持打开状态,并且不会自动关闭 - 无法弄清楚如何解决这个问题。我要求$upl将youtube ID传递给脚本的另一部分,所以我不确定我是否完全有这个权利。(为清楚起见,添加了注释(

#This is the uploading script
upl=$(python /home/pi/Documents/ytu/yt_up.py --file="${_file}" --title="$finaltitle $xy"  --description="$show_body" --keywords="$yt_tags" --category="28" --privacyStatus="$priv") | 
#This measures upload data rate $xy is the filename
ifstat -S -i eth0 |stdbuf -i0 -o0 -e0 tr 'r' 'n' |  stdbuf -i0 -o0 -e0 awk -W interactive '{print "#'$xy' " $2 "kb/s"}' | 
zenity --progress --width 500 --height 25 --title="Uploading to Youtube " 
--text="" --pulsate --auto-close --auto-kill

所以我的问题是如何在上传完成后关闭 Zenity 对话框?

目前尚不清楚upl值是什么,以及为什么将赋值通过管道传输到ifstat。我假设这是一个错字,根据描述,ut_up.py和进度监控之间没有关系,并且以后需要upl

考虑在运行上传器之前将 zenity 进度分叉到后台。这样可以更轻松地转移保留upl变量的值。

#
# Pre-fork the progress bar
#
ifstat -S -i eth0 |
stdbuf -i0 -o0 -e0 tr 'r' 'n' |
stdbuf -i0 -o0 -e0 awk -W interactive '{print "#'$xy' " $2 "kb/s"}' |
zenity --progress --width 500 --height 25 --title="Uploading to Youtube " 
--text="" --pulsate --auto-close --auto-kill &
ZENITY_PID=$!
#
# Upload the data, save the result in `upl`
#
upl=$(python /home/pi/Documents/ytu/yt_up.py --file="${_file}" --title="$finaltitle $xy"  --description="$show_body" --keywords="$yt_tags" --category="28" --privacyStatus="$priv")
#
# Kill the progress bar (
#
kill $ZENITY_PID

要使自动关闭工作,您需要某种方式来发送"100%"完成率。在这种情况下,这很复杂,因为上传过程必须保留在前台(以设置upl变量。需要有关 python 脚本和upl值的其他信息来解决此问题。

最新更新