【问题标题】:Bash Script for MythTV which requires Python Dependencies需要 Python 依赖项的 MythTV 的 Bash 脚本
【发布时间】:2023-03-06 15:44:02
【问题描述】:

我编写了一个 bash 脚本,它根据接收到的数据重命名 MythTV 文件。我用 bash 编写它是因为 bash 具有文本数据操作和易用性的优点。
您可以在此处查看脚本本身:http://code.google.com/p/mythicallibrarian/source/browse/trunk/mythicalLibrarian

我有几个第一次使用 Linux 的用户。我在这里创建了一个安装脚本,它检查依赖关系并以图形方式进行设置。您可以在此处查看设置脚本:http://code.google.com/p/mythicallibrarian/source/browse/trunk/mythicalSetup.sh

最近,MythTV 发生了一些变化,需要我将 mythicalLibrarian 中的 mysql 数据库访问迁移到 Python 绑定脚本。这里:http://code.google.com/p/mythicallibrarian/source/browse/trunk/pythonBindings/MythDataGrabber

以前,我使用这样的系统测试过依赖项:

test "`uname`" != "Darwin" && LinuxDep=1 || LinuxDep=0

if which agrep >/dev/null; then
        echo "Verified agrep exists"
else
        test "$LinuxDep" = "1" && echo "Please install 'agrep' on your system" || echo "Please obtain MacPorts and install package agrep"
        d="agrep "
fi
 .........................
if which agrep>/dev/null && which curl>/dev/null && which dialog>/dev/null; then
        echo "All checks complete!!!"
else
        echo "the proper dependencies must be installed..." 
        echo "The missing dependencies are $a$b$c$d$e"
        test "$LinuxDep" = "1" && echo "Debian based users run: apt-get install $a$b$c$d$e" || echo "Please obtain MacPorts and run: port install $a$b$c"
        if [ "$LinuxDep" = "0" ]; then
                read -n1 -p " Would you like some help on installing MacPorts? Select: (y)/n" MacPortsHelp

python 依赖项使它变得更加困难。我不知道如何测试系统上是否有 linux pacakge "libmyth-python" 和 "python-lxml"。

如何通过 BASH 测试我的 Python 脚本 MythDataGrabber 是否有其

 from MythTV import MythDB

要求满足了吗?

【问题讨论】:

    标签: python bash dependencies


    【解决方案1】:

    您可以查看以下状态码:

    python -c "import MythDB.MythTV"
    

    如果返回非零,则有错误,可能是 ImportError。

    【讨论】:

      【解决方案2】:

      编写 Python 脚本:

      try:
          from MythTV import MythDB
          print "Yes"
      except ImportError:
          print "No"
      

      然后从您的 Bash 脚本运行 Python 脚本,并检查其输出。

      【讨论】:

        猜你喜欢
        • 2020-12-05
        • 2018-05-08
        • 2020-03-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-22
        相关资源
        最近更新 更多