在我的fabfile.py中,我有一个像这样的函数。
def _update_settings(source_folder):
settings_path = source_folder + '/Porfolio/settings.py'
print settings_path
sed(settings_path, "DEBUG = True", "DEBUG = False", use_sudo=True)
# sed(settings_path, 'ALLOWED_HOSTS = "localhost"', 'DOMAIN = "%s"' % (site_name,))
secret_key_file = source_folder + '/Porfolio/secret_key.py'
if not exists(secret_key_file):
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
key = ''.join(random.SystemRandom().choice(chars) for _ in range(50))
append(secret_key_file, "SECRET_KEY = '%s'" % (key,), use_sudo=True)
append(settings_path, '\nfrom .secret_key import SECRET_KEY', use_sudo=True)
当我运行fabfile.py并进入此函数时,它会提示此错误:
[ip] sudo: sed -i.bak -r -e 's/DEBUG = True/DEBUG = False/g'
"$(echo /home/test/Porfolio/settings.py)"
[ip] out: sudo password:
[ip] out: sed: can't read /home/test/Porfolio/settings.py: No such file or directory
[ip] out:
Warning: sudo() received nonzero return code 2 while executing 'sed -i.bak -r -e 's/DEBUG = True/DEBUG = False/g' "$(echo /home/test/Porfolio/settings.py)"'!
[ip] sudo: echo 'SECRET_KEY = '\\''$n07%0acym!nokir64ql8@k5@u8ff^9inp5pk1@$y#(++6^0_+'\\''' >> "$(echo /home/test/Porfolio/secret_key.py)"
[ip] out: sudo password:
[ip] out: /bin/bash: /home/test/Porfolio/secret_key.py: No such file or directory
[ip] out:
为简洁起见,我删除了部分错误。但简而言之,它无法在所谓的导向器中找到该文件,当我进入系统时,该文件完全在同一路径下。
我错过了什么?
编辑:将/ home / test / *的目录更改为' django'并且在' django'内,这是我正在处理的帐户。仍然是同样的错误