Message12071
Hi,
I am using openhab with the jsr223 scripting engine & jython to do some home automation.
With jython 2.7.1 (latest version from maven) it seems that modules do not get imported properly.
I have two files (A&B) which import a self written library:
import testModule
In the library I set a property:
import testModule
print( 'TESTPROP: {}'.format(hasattr(testModule, 'TESTPROP')))
testModule.TESTPROP = 'TEST'
print( 'TESTPROP: {}'.format(hasattr(testModule, 'TESTPROP')))
This results in the following output:
TESTPROP: 0
TESTPROP: 1
TESTPROP: 0
TESTPROP: 1
It seems that the library does get loaded multiple times.
With jython 2.7.0 the output is correct as the library only gets loaded once:
TESTPROP: 0
TESTPROP: 1
Steps to reproduce:
- Download Openhab2.3 from https://www.openhab.org/
- Copy Jython Standalone to Openhab2\runtime\lib\boot\
Use 2.7.1 to reproduce problem, use 2.7.0 to see it work
- unzip attached file into Folder Openhab2\conf\
- Edit Openhab2\runtime\bin\setenv.bat Line 118:
Insert:
-Dpython.path=%OPENHAB_CONF%/automation/lib ^
to add library path to JAVA_OPTS
- Start openhab (start.bat)
- See https://www.openhab.org/docs/tutorial/1sttimesetup.html and select Expert
- Activate JSR223 scripting (Next-Gen Rule Engine)
https://www.openhab.org/docs/configuration/rules-ng.html#installation
- Stop Openhab and restart and watch output in console window
Scripts are located in automation/jsr223
Library is located in automation/lib |
|
Date |
User |
Action |
Args |
2018-08-06 13:18:10 | spaceman_spiff | set | recipients:
+ spaceman_spiff |
2018-08-06 13:18:10 | spaceman_spiff | set | messageid: <1533561490.66.0.56676864532.issue2700@psf.upfronthosting.co.za> |
2018-08-06 13:18:10 | spaceman_spiff | link | issue2700 messages |
2018-08-06 13:18:09 | spaceman_spiff | create | |
|