Hi:
Fundamentally, what Charles-Henri suggested is correct.
For example, if you want to use the commons-math jar, you can do this:
import sys
sys.path.append(‘/full/path/to/your/copy/of/commons-math3-3.2.jar’)
from org.apache.commons.math3.fitting import CurveFitter
If your import fails, check the log file to see if there are error messages.
For example, maybe some class in the jar cannot be resolved because of further dependencies.
Note, however, that BOY will execute jython scripts on the UI thread, so all of CSS will freeze while you’re executing your script.
If you really need to do something that takes longer, you should create a Runnable inside your script and execute that on a new Thread.
Then use Display.asyncExec() for interacting with the widgets back on the UI thread.
Ideally, move what you think you have to do in a script into an IOC (which may be a pcaspy-based python IOC) and in the UI you then just read/write PVs. All the logic is in the IOC.
-Kay
On Nov 28, 2016, at 5:24 AM, Gabriel de Souza Fedel <[email protected]> wrote:
Hi Pattard,
thank you for the answer.
I tried your solution, but didn't work.
The console error is this:
"ImportError: No module named github"
I'm trying to import a module called com.github.imageio, but the
cs-studio didn't find it....
I'm tried another jars that didn't work too. I'm tried to add path inside my code too, but nothing works.
What version of CSS you are using?
Regards
Em 28-11-2016 06:29, Patard Charles-Henri escreveu:
Hi Gabr iel,
Can you show the console error ? I’ve got this kind of problem with
Jython imports. Even if you modify PYTHONPATH or CS-Studio PYTHONPATH
preferences it doesn’t work. To solve it I needed to create a python
script named ImportDependencies.py :
“
#Python imports
import sys
from os.path import expanduser
# Get Home path
HOME_PATH = expanduser("~")
print 'importDependencies HOME_PATH '+str(HOME_PATH)
# Add librairies
sys.path.append(str(HOME_PATH)+'/path/to/jar/file')”
In a second time, you have to import ImprtDependencies.py in your
Jython/Python script like this : “import ImportDependencies”.
Best regards.
------------------------------------------------------------------------
/Préservons notre environnement, n’imprimez ce mail que si nécessaire./
/Preserve our environment, print this email only if necessary./
--
Gabriel Fedel
Software de Operação das Linhas de Luz
Laboratório Nacional de Luz Síncrotron – (LNLS)
Centro Nacional de Pesquisa em Energia e Materiais (CNPEM)
[email protected] | +55 (19) 3512 1226
www.lnls.cnpem.br