“source” to set PATH to bitbake with shell=True having no effect in Python

后端 未结 4 772
花落未央
花落未央 2021-01-16 18:51

Below is the code in shell script

source /proj/common/tools/repo/etc/profile.d/repo.sh
repo project init $branch
repo project sync
source poky/fnc-init-build         


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-01-16 19:50

    The problem is, that you run subprocess.call(something, shell=True) several times and assume that the variables set in the first call are present in the later calls, which use shells independend from the earlier calls.

    I would put the commands in a shell script and then run it with a single subprocess.call command. There seems to be no real point in converting it line by line into python by just running shell commands with the subprocess module.

    When repo and bitbake are python programs there could be a point to import the relevant modules from them and run the corresponding python functions instead of the shell commands provided by their main method.

提交回复
热议问题