I write my Python code as independent layers. Python DebuggersĪt this time, there are no Python debuggers for PyScript. Shortcut to open the debugger: CTRL + Shift + J. YouTube: Debugging JavaScript – Chrome DevTools 101.I will not cover how to use the web browser debugger as there are many excellent resources on the Internet. Most web browsers include a very good HTML, CSS, and JavaScript debugger. That function will catch network problems loading the PyScript JavaScript file, which I see once in a while developing. The function scriptLoadFailure() is located in error-handler.js. Notice the onerror=scriptLoadFailure('pyscript.js') added to the script tag for loading pyscript.js. This example includes the file error-handler.js that I will explain later in this article. Your development team will appreciate bug reports that include source code file and line details. If you use separate development and QA teams, your QA team will appreciate the time you spent structuring the source code and providing informative messages for all error conditions. I prefer that a customer has a useful error box with detailed information that he can report over “ hey – your program does not work and there are no error messages“. Only the parts that interface with the browser need to be tested with the browser.īy structuring your application in a consistent manner and with functionality split into different modules, you will improve your ability to detect and solve problems that occur. By splitting the Python code into multiple files, you can test the Python code independently of the browser. Separate the HTML from the Python code to make testing easier. That line number is relative to the start of the Python code and not the actual line number when mixed with HTML. Python error messages often contain a line number where the error occurred. I do not recommend mixing HTML with Python. PyScript Error Handling Feature Improvements.I try to cover several important items when writing PyScript applications: Network failures, resources not being available and programming mistakes are just a few problems to manage. There are many types of errors that PyScript applications will experience. If you experience continued problems with your script and you have checked it and debugged it thoroughly, you can report the problem to Schneider Electric ( see Report a Script Failure - Disable CompressWebRequests).Knowing that an error occurred is the first step to preventing and solving errors. By setting Geo SCADA Expert to run segments of the code and then breaking, you may be able to determine where the unexpected results are occurring and then you can make appropriate adjustments.įor more information on the commands included on the Script tab of the ViewX ribbon, see Debug Mode. Use the Step Over/Step Into/Run To Cursor commands to insert breakpoints to step through the code.For the Alarm Banner, the script will run when you right-click in the Alarm Banner (if a breakpoint is inserted on the line containing BuildAlarmMenu) or when you select one of the menu options added to the Alarm Banner’s context sensitive menu by the script.For Mimics, the script will either run when you first display the Mimic or will run when you select an appropriate Mimic script pick action.The debugger will break at the breakpoints in turn. ![]() Use the Insert/Remove command on the Script tab to insert breakpoints where you suspect there may be problems in the script.If you run your script and it runs successfully but produces unexpected results: When your script contains no errors, it will run successfully and you will no longer be prompted to run the script in Debug mode. Remove the error by changing the code appropriately.An error dialog box informs you which line contains the error. ![]() The script runs in Debug mode and breaks on the line that contains the first error.
0 Comments
Leave a Reply. |