Python Zenity进程的两个进程-如何自动关闭?
我有一个肮脏的方式来显示上传速度,当我的Youtube API上传程序脚本运行时,我测量一个特定端口的网络输出,而上传正在进行。我的问题是上传后网络端口的数据会继续,因此Zenity进程保持打开状态,并且不会自动关闭-无法找到解决方法。我需要$upl才能将youtube ID传递到脚本的另一部分,所以我不确定我是否完全正确。(为清晰起见,添加了注释)Python Zenity进程的两个进程-如何自动关闭?,python,bash,zenity,Python,Bash,Zenity,我有一个肮脏的方式来显示上传速度,当我的Youtube API上传程序脚本运行时,我测量一个特定端口的网络输出,而上传正在进行。我的问题是上传后网络端口的数据会继续,因此Zenity进程保持打开状态,并且不会自动关闭-无法找到解决方法。我需要$upl才能将youtube ID传递到脚本的另一部分,所以我不确定我是否完全正确。(为清晰起见,添加了注释) 因此,我的问题是如何在上传完成后关闭Zenity对话框?不清楚什么是upl值,以及为什么分配会通过管道传输到ifstat。我假设这是一个输入错误,
因此,我的问题是如何在上传完成后关闭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
值的其他信息来解决此问题。好的,谢谢,我会试试。$upl最终成为上传视频的YoutubeID,它是成功上传后返回的内容,然后用于整个工作流的其他部分。That python脚本yt_up.py返回id我可以添加一个while upl=nothing循环吗?当它等于某个值时,杀死pid?在这种情况下,该循环的结构是什么?'upl=$(…)'在python作业退出之前不会完成。while
循环将如何帮助?上传完成后,进度窗口将关闭。好的,我想我认为在$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