Comments (9)
Hang on, still working on understanding the problem....
from openhab-helper-libraries.
I have an update for the logging, which may fix this, and also adds a log attribute to the function as is done to a rule class. It's currently in the lucid migration branch, and I hope to have this merged by the end of the year, assuming there's someone to test it!
If you wanted to look at it, grab the core.rules.py from that branch. But now that I think of it, you may need the core.log.py and configuration.py too...
from openhab-helper-libraries.
The files from the lucid branch look the same as in the main branch - last commit was 15 days ago.
from openhab-helper-libraries.
I think this is a limitation of ESH, exception which is not handled by jython is logged with simple one liner. Are you sure, that line number is from offending module? For me, line is always set to line number of script (rule .py file) which is being run.
To debug, you can try to add try/except block which logs exception with full stack:
try:
import foo
except Exception as ex:
log.error(traceback.format_exc()) # assuming log is logger
raise ex # optional, makes ESH think that exception was thrown here
So this error:
18:54:39.189 [ERROR] [ript.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/200_rules/foo.py': NameError: name 'foo' is not defined in <script> at line number 17
is now:
18:55:27.092 [ERROR] [ipse.smarthome.automation.rules] - Traceback (most recent call last):
File "<script>", line 17, in <module>
File "/openhab/conf/automation/lib/python/foo.py", line 1, in <module>
bar
NameError: name 'bar' is not defined
18:55:27.094 [ERROR] [ript.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/200_rules/foo.py': NameError: name 'foo' is not defined in <script> at line number 20
Same thing happens when code is executed.
from openhab-helper-libraries.
Yes, the line number for the error comes from the script loading the module. Thank you for the work around, hope there is long term more elegant solution
from openhab-helper-libraries.
I think you can safely put most stuff inside try block, imports, rules, initialization etc. Only thing you need to have outside is logger. @rule decorator adds these try/except to your rules by default.
I think that proper solution can be implemented only on ESH side. If I remember correctly, .py rule file is read and run via jython interpreter as script (not read by jython from file, hence <script> instead file path in jython stack trace. Since nothing is handling an error, ESH is just logging where it went bad.
from openhab-helper-libraries.
The files from the lucid branch look the same as in the main branch - last commit was 15 days ago.
I forgot... I haven't synced yet. Hoping to get this done in the next few hours. IMO, @diijkstra 's issue is the proper solution though. Until then, core.log.log_traceback
can be used to decorate classes, methods and functions in modules. I think this is what you are looking for. The change I mentioned decorates the rule callback (Action).
from openhab-helper-libraries.
There are a couple challenges to work out with migrating lucid, so I've added the changes I was referring to into master.
from openhab-helper-libraries.
@diijkstra, do you planning to submit a PR to openhab-core?
from openhab-helper-libraries.
Related Issues (20)
- Remove "Member of" and "System started" triggers
- core.metadata get_metadata duplicate lines of code HOT 2
- Add a module for storing data to persistent storage
- event.ItemState returning incorrect state for Rollershutter HOT 1
- [Area Triggers and Actions] Make "99/100" state override configurable HOT 2
- [Area Triggers and Actions] Refactor light_action HOT 2
- [Area Triggers and Actions] light_action throws exceptions HOT 2
- [Area Triggers and Actions] Configurable brightness method for light_action HOT 1
- Return missing in utils.js Line 206 HOT 1
- Add syntactic sugar in rules to check if item maintains state for specified duration HOT 7
- timer_example.py link in documentation is a 404. HOT 1
- [utils] kw function is broken
- The WeatherStationUploader community script is obsolete and should be removed HOT 2
- _DirectoryEventTriggerHandlerFactory doesn't work HOT 3
- Javascript doesn't works with current OH 3.0 daily build
- openhab-helper-libraries/Getting Started/Installation suggestions HOT 2
- [actions] LogAction was renamed to Log in OH 3.0
- joda.time is no longer part of the OpenHab 3 Core HOT 2
- Openhab 3 . Channel Trigger WHEN error / MQTT action HOT 5
- WHEN Trigger for Things HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openhab-helper-libraries.