EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: CSS - Problem importing Jar on Jython
From: "Kasemir, Kay" <[email protected]>
To: Gabriel de Souza Fedel <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Mon, 28 Nov 2016 14:01:50 +0000
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
> 
> 



Replies:
Re: CSS - Problem importing Jar on Jython Gabriel de Souza Fedel
References:
CSS - Problem importing Jar on Jython Patard Charles-Henri
Re: CSS - Problem importing Jar on Jython Gabriel de Souza Fedel

Navigate by Date:
Prev: Re: CSS - Problem importing Jar on Jython Gabriel de Souza Fedel
Next: EPICS/RTEMS Compilation errors Jianxun Yan
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: CSS - Problem importing Jar on Jython Gabriel de Souza Fedel
Next: Re: CSS - Problem importing Jar on Jython Gabriel de Souza Fedel
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 29 Nov 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·