进入Zenity的两个过程-如何自动关闭? [英] Two processes into Zenity progress- how to auto close?

查看:118
本文介绍了进入Zenity的两个过程-如何自动关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a dirty way to show upload speed while my Youtube API uploader script runs, I measure the network output of a specific port, while the upload is in progress. My problem is that the data from the network port continues after the upload so the Zenity progress remains open, and doesnt auto-close - can't figure out how to get around this. I require $upl to pass the youtube ID to another portion of the script, so I'm not sure I quite have that right. (Comments added for clarity)

#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对话框?

So my question is how to close the Zenity dialog on completion of the upload?

推荐答案

目前尚不清楚upl的值是什么,为什么将分配赋值到ifstat中.我假设这是一个错字,按照说明,ut_up.py与进度监视之间没有关系,并且在以后需要upl.

It's not clear what is the upl value, and why is the assignment piped into ifstat. I'm assuming this is a typo, and there is no relationship between the ut_up.py and the progress monitoring, as per description, and that the upl is needed down the road.

在运行上载程序之前,请考虑将zenity进度分叉到背景中.这样可以更轻松地转移保留upl变量的值.

Consider forking the zenity progress into the backgroud, BEFORE running the uploader. This will make it easier to transfer retain the value of the upl variable.

#
# 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值的附加信息.

To get the auto-close to work, you will need some way to send '100%' completion rate. This is complex in this case, as the upload process has to stay in the foreground (to set the upl variable. Additional information about the python script and the value of upl is needed to address this issue.

这篇关于进入Zenity的两个过程-如何自动关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆