How to refresh the interpreter

View: New views
3 Messages — Rating Filter:   Alert me  

How to refresh the interpreter

by vincent lapointe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,
 
I'm changing the INTERPRETER_PATH_NEW preference with the preference store of the pydev plugin. How can I send a refresh command to the pydev plugin to make sure it is updated?
 
See the sample below...
 
 
Note: sometimes, pydev automatically detected my preference change and automatically refresh the plugin, but sometimes it doesn't. Is there a particular reason?
 
Thanks
 
Vincent
 
 
 /**
  * String template used to define the interpreter value
  */
 private static final String INTERPRETER_PATH_NEW_TEMPLATE =
  "Version$versionExecutable:" + pathTag + "\\python.exe|" +
  "$path\\DLLs|" +
  "$path\\lib|" +
  "$path\\lib\\lib-tk|" +
  "$path|" +
  "$path\\lib\\site-packages|" +
  "$path\\lib\\site-packages\\win32|" +
  "$path\\lib\\site-packages\\win32\\lib|" +
  "$path\\lib\\site-packages\\Pythonwin@$|" +
  "OpenGL|__builtin__|__main__|_codecs|_hotshot|_locale|_weakref|array|audioop|binascii|cPickle|cStringIO|cmath|email|errno|exceptions|gc|imageop|imp|marshal|math|md5|msvcrt|new|nt|operator|os|pcre|regex|rgbimg|rotor|sha|signal|strop|struct|sys|thread|time|wx|wxPython|xreadlines|xxsubtype&&&&&";

 
private void setPydevInterpreter(File pythonRootDirExecFile, String version) {
 
  String pythonPath = pythonRootDirExecFile.getAbsolutePath();
 
  // Calculate interpreter value
  String interpreterValue = INTERPRETER_PATH_NEW_TEMPLATE;

  // replace version
  interpreterValue = interpreterValue.replace("$version", version);

  // replace python path
  interpreterValue = interpreterValue.replace("$path", pythonPath);

  // Set INTERPRETER_PATH_NEW preference
  pydevPlugin.getPreferenceStore().setValue(INTERPRETER_PATH_NEW, interpreterValue);
 
  // Refresh pydev plugin
  // How can I force the refresh of the plugin

 }
     
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://go.microsoft.com/?linkid=9691815
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pydev-code mailing list
pydev-code@...
https://lists.sourceforge.net/lists/listinfo/pydev-code

Re: How to refresh the interpreter

by Fabio Zadrozny :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I'm changing the INTERPRETER_PATH_NEW preference with the preference store of the pydev plugin. How can I send a refresh command to the pydev plugin to make sure it is updated?
>
> See the sample below...
>
>
> Note: sometimes, pydev automatically detected my preference change and automatically refresh the plugin, but sometimes it doesn't. Is there a particular reason?
>
> Thanks
>
> Vincent
>
>
>  /**
>  * String template used to define the interpreter value
>  */
>  private static final String INTERPRETER_PATH_NEW_TEMPLATE =
>  "Version$versionExecutable:" + pathTag + "\\python.exe|" +
>  "$path\\DLLs|" +
>  "$path\\lib|" +
>  "$path\\lib\\lib-tk|" +
>  "$path|" +
>  "$path\\lib\\site-packages|" +
>  "$path\\lib\\site-packages\\win32|" +
>  "$path\\lib\\site-packages\\win32\\lib|" +
>  "$path\\lib\\site-packages\\Pythonwin@$|" +
>  "OpenGL|__builtin__|__main__|_codecs|_hotshot|_locale|_weakref|array|audioop|binascii|cPickle|cStringIO|cmath|email|errno|exceptions|gc|imageop|imp|marshal|math|md5|msvcrt|new|nt|operator|os|pcre|regex|rgbimg|rotor|sha|signal|strop|struct|sys|thread|time|wx|wxPython|xreadlines|xxsubtype&&&&&";
>
>
> private void setPydevInterpreter(File pythonRootDirExecFile, String version) {
>
>  String pythonPath = pythonRootDirExecFile.getAbsolutePath();
>
>  // Calculate interpreter value
>  String interpreterValue = INTERPRETER_PATH_NEW_TEMPLATE;
>
>  // replace version
>  interpreterValue = interpreterValue.replace("$version", version);
>
>  // replace python path
>  interpreterValue = interpreterValue.replace("$path", pythonPath);
>
>  // Set INTERPRETER_PATH_NEW preference
>  pydevPlugin.getPreferenceStore().setValue(INTERPRETER_PATH_NEW, interpreterValue);
>
>  // Refresh pydev plugin
>  // How can I force the refresh of the plugin
>
>  }
>



Hi Vincent.

The actual way to create an interpreter would be something as:

IInterpreterManager iMan = PydevPlugin.getPythonInterpreterManager(true);
IInterpreterInfo interpreterInfo = ... (create your interpreter info here)
iMan.addInterpreterInfo(interpreterInfo);
iMan.restorePythopathForAllInterpreters(monitor);
iMan.setPersistedString(iMan.getStringToPersist(new
IInterpreterInfo[]{interpreterInfo}));
iMan.saveInterpretersInfoModulesManager();

Cheers,

Fabio

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pydev-code mailing list
pydev-code@...
https://lists.sourceforge.net/lists/listinfo/pydev-code

Re: How to refresh the interpreter

by vincent lapointe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


 <cfb578b20911051457s6c11b8b8q45ef3aa16ed6c29d@...>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0


Hi Fabio=2C
=20
I made the modifications based on what you suggested.
=20
However=2C when I apply the changes=2C all opened projects with python natu=
re throw the following exception. (Note that pydev console also generated a=
 similar exception)
=20
Invalid interpreter: Default configured for project: Project1.
org.python.pydev.core.ProjectMisconfiguredException: Invalid interpreter: D=
efault configured for project: Project1.
 at org.python.pydev.plugin.nature.PythonNature.getProjectInterpreter(Pytho=
nNature.java:1051)
 at org.python.pydev.plugin.nature.PythonNature.getConfigErrorsAndInfo(Pyth=
onNature.java:1100)
 at org.python.pydev.navigator.ProjectInfoForPackageExplorer.getConfigError=
sAndInfo(ProjectInfoForPackageExplorer.java:79)
 at org.python.pydev.navigator.ProjectInfoForPackageExplorer.recreateInfo(P=
rojectInfoForPackageExplorer.java:53)
 at org.python.pydev.navigator.PythonBaseModelProvider.internalDoNotifyPyth=
onPathRebuilt(PythonBaseModelProvider.java:289)
 at org.python.pydev.navigator.PythonBaseModelProvider$Updater.run(PythonBa=
seModelProvider.java:193)
 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Then=2C if I close my rcp application and reopen it=2C the projects with py=
thon nature and the pydev console work correctly=20
=20
Moreover=2C I checked the configuration of the interpreter in the preferenc=
e page and all settings are exactly the same as when configured automatical=
ly. Note that I set an empty dll list in the InterpreterInfo.
=20
So=2C is it normal that I should close my rcp application before the new in=
terpreter works correctly?
=20
=20
Thank again
=20
Vincent
    =20
_________________________________________________________________
Ready. Set. Get a great deal on Windows 7. See fantastic deals on Windows 7=
 now
http://go.microsoft.com/?linkid=3D9691818=

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pydev-code mailing list
pydev-code@...
https://lists.sourceforge.net/lists/listinfo/pydev-code