2016-11-08 1 views
1

MAC OS의 지역 서버에서 Django 프로젝트에서 java 프로그램 https://github.com/antonydeepak/ResumeParser/을 사용하는 데 문제가 있습니다.파이썬 호출 자바가 발생합니다. 오류 : 메인 클래스를 찾지 못했습니다.

내가 좋아하는 장고 프로젝트에 ResumeParser를 설치 한 :

- 장고 프로젝트 - APP1 - APP2 - ResumerParser 여기

내 코드는하지만 찾을 수 없습니다 "라고하거나 로드 메인 클래스 ".

if form.is_valid(): 
    f = form.save(commit=False) 

    resume = form.cleaned_data['resume'] 

    cmd = ['java', '-cp', 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*', 'code4goal.antony.resumeparser.ResumeParserProgram %s textOutput.json' % resume] 

    subprocess.Popen(cmd) 

어떻게 해결할 수 있는지 실마리가 있습니까? StackOverflow에서이 테마와 관련된 모든 게시물을 성공하지 못했습니다.

미리 감사드립니다.

답변

0

이 후 주 그것은 작동합니다. 모든 파일을 ResumeParser/ResumeTransducer 디렉터리에 복사해야합니다.

또한 파일 구문 분석을 위해 현재 디렉토리에 알릴 필요가 있습니다.

# first save the file 
if form.is_valid(): 
    f = form.save(commit=False) 

    resume = form.cleaned_data['resume'] 
    f.resume = resume 
    f.save() 

    # copy file to the CV parser dir so java can parse the file 
    cf = "." + f.resume.url 
    shutil.copy2(cf, 'ResumeParser/ResumeTransducer') 

    # get file to convert 
    fl_name = str(f.resume).split('/')[-1] 

    # get file name to make json output 
    base_name = os.path.splitext(fl_name)[0] 

    cmd = "java -cp 'bin/*:../GATEFiles/lib/*:../GATEFiles/bin/gate.jar:lib/*' code4goal.antony.resumeparser.ResumeParserProgram %s %s.json" % (fl_name, base_name) 

    # get the current working dir  
    os.chdir("ResumeParser/ResumeTransducer") 

    # call java 
    subprocess.Popen(cmd, shell=True) 

감사합니다 장 - 프랑수아 파브르 : 여기

는 구현입니다!

1

공백으로 그룹화 된 매개 변수로 잘 구분 기호 매개 변수를 혼합합니다.

cmd = ['java', '-cp', 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*', 'code4goal.antony.resumeparser.ResumeParserProgram %s textOutput.json' % resume] 

귀하의 마지막 매개 변수는 단일 매개 변수로 간주되고 subprocess에 의해 공간에 의해 보호됩니다 :

"code4goal.antony.resumeparser.ResumeParserProgram resume_value textOutput.json"

=> 전체 "class<space>param1<space>param2" 당신의 클래스로 볼 수 있습니다 : 발견되지 왜 당연하지 .

분할 모든 당신의 매개 변수와 그것을 작동합니다, subprocess하지 않습니다 그룹화 매개 변수, 아니은 (strresume 개체의 강제 변환 주) 인용 : 내가 가진

cmd = ['java', '-cp', 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*', 'code4goal.antony.resumeparser.ResumeParserProgram', str(resume),'textOutput.json'] 
+0

빠른 답변 감사드립니다. 이제 새로운 오류가 발생했습니다 : execv() arg 2는 문자열 만 포함해야합니다 –

+0

죄송합니다! 'resume' 객체를 문자열로 변환해야했습니다. 편집을 참조하십시오. –

관련 문제