MythTV 的 Bash 脚本需要 Python 依赖项

发布于 2024-09-28 19:49:39 字数 2019 浏览 0 评论 0原文

我编写了一个 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 软件包“libmyth-python”和“python-lxml”。

如何从 BASH 测试我的 Python 脚本 MythDataGrabber 是否

 from MythTV import MythDB

满足其要求?

I wrote a bash script which renames MythTV files based upon data it receives. I wrote it in bash because bash has the strong points of textual data manipulation and ease of use.
You can see the script itself here: http://code.google.com/p/mythicallibrarian/source/browse/trunk/mythicalLibrarian

I have several users which are first time Linux users. I've created an installation script here which checks dependencies and sets things up in a graphical manner. You can see the setup script here: http://code.google.com/p/mythicallibrarian/source/browse/trunk/mythicalSetup.sh

Recently, there were some changes to MythTV which require me to migrate the mysql database access in mythicalLibrarian to a Python bindings script. here: http://code.google.com/p/mythicallibrarian/source/browse/trunk/pythonBindings/MythDataGrabber

Previously, I've tested dependencies using a system like this:

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

The python dependencies make it a bit more difficult. I don't know how to test if I have the linux pacakge "libmyth-python" and "python-lxml" on the system.

How, from BASH, can I test that my Python script MythDataGrabber has its

 from MythTV import MythDB

requirement satisfied?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

高跟鞋的旋律 2024-10-05 19:49:39

您可以检查以下状态代码:

python -c "import MythDB.MythTV"

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

You can check the status code of:

python -c "import MythDB.MythTV"

If it returns non-zero, there was an error, likely an ImportError.

智商已欠费 2024-10-05 19:49:39

编写 Python 脚本:

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

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

Write a Python script:

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

then run the Python script from your Bash script, and check its output.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文