gpt4 book ai didi

python - bash/ python : Organization of several scripts

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:36 25 4
gpt4 key购买 nike

我在树莓派上搭建了一个照相亭。它太棒了!但是经过一些编码之后,我现在在组织脚本时遇到了问题。目前所有脚本都是通过“lxterminal -e”启动的。所以每个脚本都有自己的终端窗口,所有的东西都同时运行。我问自己是否可以通过更有效的方式完成此操作。

照相亭的基本功能:人们按下遥控按钮,拍照,照片显示在内置的 tft 上。

start.sh --> is being executed automatically after booting. It prepares the system, , sets up the camera and brings it in tethered mode. After all that it launches the other, following scripts:

system-watchdog.sh --> checks continuously if one of the physical buttons on the photo booth is being pressed, to reboot or go into setup mode. It's an ever-lasting-while-loop.

sync.sh --> syncs the captured photo to some folders, where they are modified for beeing printed. Also an ever-lasting-while-loop.

backup.sh --> copies all taken pictures to a usb device as a backup. This is a cronjob, every 5 minutes.

temp-logger.sh --> Logs the temperature of the CPU continuously, because I had heat-problems.

CPU 持续运行在 20-40% 左右。也许通过一些优化,我可以在查看器脚本上运行并减少 CPU 使用率。

有什么建议可以用来更好地组织脚本?

感谢您的建议!

最佳答案

sync.sh --> syncs the captured photo to some folders, where they are modified for 1. being shown on the second screen, 2. upload to dropbox and 3. being printed. Also an ever-lasting-while-loop.

terminal-sync.sh --> copies the taken photos to the second-screen-terminal, where they are shown in a gallery. It's also an ever-lasting-while-loop.

对于这些,您可以使用 inotifywait 在处理文件之前等待文件可用。

您应该检查使用 top,哪个脚本实际消耗 CPU 以及原因。一旦您确定了脚本及其消耗 CPU 的原因,您就可以开始寻找优化的方法来完成相同的工作

关于python - bash/ python : Organization of several scripts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45883224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com