[Jo...] Posted June 21, 2022 Share Posted June 21, 2022 Hello, How can I debug a customized import script? I'm creating a customized import script and using a Pydev as my IDE. I save the import script in the personal import script folder and it is activated when I import a file with the correct structure. So the initial set up is working. Next step is to be able to debug this script. Can I attache the debugger of Pydev (eclipse based) to the running script? Can I write messages or print statements to a console? How can I activate this console or is there a log file? Thanks in advance. Johnny Link to comment Share on other sites More sharing options...
[Da...] Posted June 29, 2022 Share Posted June 29, 2022 Hello Johnny, there is no official way of debugging an import script. Do you use GOM XML as the interface? Then you could create the output xml file externally which is than easily debuggable. You could also save the xml file to another location so that you can examine the produced file. An other options would be to create a log file with debug messages. If you want to get fancy you could add a wait to the start of your import script and than attach to the python process. Hope this helps. Greetings Daniel Link to comment Share on other sites More sharing options...
[Jo...] Posted June 29, 2022 Author Share Posted June 29, 2022 Hello Daniel, I'm using the XML interface. Does there exist a save method in this interface? Does there exist a method for the log file writing with debug messages? I would like to explore these 2 methods first. Thanks in advance, Johnny Link to comment Share on other sites More sharing options...
[Da...] Posted June 29, 2022 Share Posted June 29, 2022 1. For saving you can use the GOMXmlWriter () from the gom_xml module. It has a member function xmlWrite (out_file_name). So you can specify a path to save a second version of your xml file. 2. You could use the python module "logging" import logging import os # 50 means critical if logging.getLogger ().isEnabledFor (50): log_file = 'C:/temp/debug_log.log' log_dir = os.path.dirname (log_file) if not os.path.exists (log_dir): os.makedirs (log_dir) logging.basicConfig (filename=log_file, level=logging.DEBUG) # and then call the logger like this logging.debug (f"Debug! Message") You can find an example in the following import format: https://connect.gom.com/display/GPF/Import+FUM Hope this helps. Greetings Daniel Link to comment Share on other sites More sharing options...
[Jo...] Posted June 29, 2022 Author Share Posted June 29, 2022 Thanks Daniel, That helps definitely Regards Johnny Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in