如何在setup.py文件中运行多个bash / sh脚本?

时间:2017-02-22 06:34:29

标签: python linux bash shell setup.py

我在文件夹startup.sh中有2个脚本:desktopsetup.shbin。以下是我setup.py的代码。

from setuptools import setup
from setuptools.command.install import install
import os

class MyInstall(install):
    def run(self):
        install.run(self)
        path = os.getcwd().replace(" ", "\ ").replace("(","\(").replace(")","\)") + "/bin/"
        os.system("echo 'Setting up Tzara.desktop'")
        os.system("chmod +x "+path+"desktopsetup.sh")
        os.system("sh "+path+"desktopsetup.sh")
        os.system("chmod +x "+path+"startup.sh")
        os.system("sh "+path+"startup.sh")


setup(name='Tzara---A-Personal-Assistant',
      version='1.0.6',
      description='A Virtual Personal Assistant',
      url='https://github.com/Suman7495/Tzara---A-Personal-Assistant',
      author='MyName',
      author_email='myemail@gmail.com',
      license='MIT',
      packages=['tzara'],
      classifiers=['Development Status :: 4 - Beta',
      'Programming Language :: Python :: 2.7',            
      ],
      scripts=['bin/desktopsetup.sh', 'bin/startup.sh'],
      cmdclass={'install': MyInstall},
)

当我使用python install setup.py运行时,只运行startup.shdesktopsetup.sh无法运行。

这是我的desktopsetup.sh代码:

#!/bin/bash
STR=$'[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Tzara
Comment=A Virtual Personal Assistant
Exec=guake -n guake -t -e "python /usr/local/lib/python2.7/dist-packages/tzara/main.pyc" guake -r "Tzara"
Terminal=True
Type=Application
Categories=Application'
if [ ! -e /usr/share/applications/Tzara.desktop  ]; then
  echo "Setting up .desktop file"
  echo "$STR" | sudo tee sudo /usr/share/applications/Tzara.desktop > /dev/null
  read -n1 -r -p "Press any key to continue..." key
fi

找到the details of my code here.

如果有人能提供一点帮助,我会非常感激。

0 个答案:

没有答案