0
Django를 처음 사용했습니다. 어떤 관점에서 몇 가지 명령을 실행하고 싶습니다. 같은 :이 방법을 사용django popen "invalid syntax"
python /path/to/the/script/run.py -id 11 --user root --run_digital_id 29 --workflow map --lib_group library.yaml --log log.conf
통화 :
def run_in_background(cmd):
logging.info('running ' + cmd)
p = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
output, errors = p.communicate()
print output
print errors
logging.debug(output)
logging.debug(errors)
명령은 메소드 run_in_background에 전달됩니다(). 명령을 복사하여 터미널에서 실행하면 잘 작동합니다. 내가 장고의 몇 가지보기에서 실행할 때, 그것을보고 : 나는 약간의 '일반'파이썬 코드에서 호출 할 때
Traceback (most recent call last):
File "/path/to/the/script/run.py", line 11, in ?
import conf, util
File "/path/to/the/script/conf.py", line 11
class Settings():
^
SyntaxError: invalid syntax
어에서, run_in_background 방법도 노력하고 있습니다.
오류 위치는 내 프로그램의 첫 번째 줄입니다. 나는 길에 뭔가 문제가 있다고 생각합니다. 그러나 오랜 시간 동안 찾은 후에, 나는 이유를 얻지 못했습니다. 도와주세요. 감사.
로 변경 할 수 있습니다? 들여 쓰기를 잊으셨습니까? –
@burhan : 아니요 터미널에서 명령을 실행할 수 있습니다 ... – Joy
'class Settings() :'과 같이 빈 괄호로 클래스를 정의하는 일부 Python 버전에서는 유효하지 않으므로 class 설정으로 변경할 수 있습니다 (객체) :'. – Rohan