~vil/pydev/upstream

« back to all changes in this revision

Viewing changes to org.python.pydev/src/org/python/pydev/editor/codecompletion/shell/PythonShell.java

  • Committer: Vladimír Lapáček
  • Date: 2006-08-30 18:38:44 UTC
  • Revision ID: vladimir.lapacek@gmail.com-20060830183844-f4d82c1239a7770a
Initial import of upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on Aug 16, 2004
 
3
 *
 
4
 * @author Fabio Zadrozny
 
5
 */
 
6
package org.python.pydev.editor.codecompletion.shell;
 
7
 
 
8
import java.io.File;
 
9
import java.io.IOException;
 
10
 
 
11
import org.eclipse.core.runtime.CoreException;
 
12
import org.python.pydev.core.REF;
 
13
import org.python.pydev.plugin.PydevPlugin;
 
14
import org.python.pydev.runners.SimplePythonRunner;
 
15
import org.python.pydev.runners.SimpleRunner;
 
16
 
 
17
/**
 
18
 * @author Fabio Zadrozny
 
19
 */
 
20
public class PythonShell extends AbstractShell{
 
21
 
 
22
    
 
23
    /**
 
24
     * Initialize with the default python server file.
 
25
     * 
 
26
     * @throws IOException
 
27
     * @throws CoreException
 
28
     */
 
29
    public PythonShell() throws IOException, CoreException {
 
30
        super(PydevPlugin.getScriptWithinPySrc("pycompletionserver.py"));
 
31
    }
 
32
 
 
33
 
 
34
    @Override
 
35
    protected synchronized String createServerProcess(int pWrite, int pRead) throws IOException {
 
36
        String interpreter = PydevPlugin.getPythonInterpreterManager().getDefaultInterpreter();
 
37
        File file = new File(interpreter);
 
38
        if(file.exists() == false ){
 
39
            throw new RuntimeException("The interpreter location found does not exist. "+interpreter);
 
40
        }
 
41
        if(file.isDirectory() == true){
 
42
            throw new RuntimeException("The interpreter location found is a directory. "+interpreter);
 
43
        }
 
44
 
 
45
 
 
46
        String execMsg;
 
47
        if(SimpleRunner.isWindowsPlatform()){ //in windows, we have to put python "path_to_file.py"
 
48
            execMsg = interpreter+" \""+REF.getFileAbsolutePath(serverFile)+"\" "+pWrite+" "+pRead;
 
49
        }else{ //however in mac, or linux, this gives an error...
 
50
            execMsg = interpreter+" "+REF.getFileAbsolutePath(serverFile)+" "+pWrite+" "+pRead;
 
51
        }
 
52
        process = new SimplePythonRunner().createProcess(execMsg, serverFile.getParentFile());
 
53
 
 
54
        return execMsg;
 
55
    }
 
56
 
 
57
 
 
58
 
 
59
}
 
 
b'\\ No newline at end of file'