I would like to set up an automated software build system on a scripting base.
Therefore I start a batch file containing the "codesys --runscript" commands for a python script to compile a codesys project with the option --enablescripttracing.
This works fine, but the trace output is not redirected into a file completely.
On cmd prompt the batch file output ist redirected via "build.bat >> log1.dat" - ok
Within build.bat the python "print()" script commands are redirected via "> log2.dat Codesys --runscript ..." - ok
But the codesys compiler messages are displayed within cmd prompt
How can I redirect the messages that come out of codesys during e.g. the python command "app.create_boot_application(bootapppath)" ?
Best regards
Dirk
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
DBe hat geschrieben:
How can I redirect the messages that come out of codesys during e.g. the python command "app.create_boot_application(bootapppath)" ?
Here some example code:
CompileCategory=Guid("{97F48D64-A2A3-4856-B640-75C046E37EA9}")found=projects.primary.find("Application", True)app=found[0]
\# ClearmessagesfromBuildcategorysystem.clear_messages(CompileCategory)app.create_boot_application(r"C:\Temp\App.app")
\# Getmessageobjectswhichcontainallthedataseverities= {
  Severity.FatalError : "Fatal error", Severity.Error : "Error",
  Severity.Warning : "Warning", Severity.Information : "Information",
  Severity.Text : "Text"
  }
msgs=system.get_message_objects(CompileCategory)formsginmsgs:
  sev=severities[msg.severity]
  print("{} {}{}: {}".format(sev, msg.prefix, msg.number, msg.text))
\# Or: Getonlythemessagetextmsgs=system.get_messages(CompileCategory)formsginmsgs:
  print(msg)
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you very much! The compile information is printed within cmd prompt AND log file now .
During project creation I do a SVN checkout (via codesys addon). These reports are printed within cmd prompt only.
Is there another GUID available for this too?
BR
Dirk
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
DBe hat geschrieben:
Is there another GUID available for this too?
Use the following code to get a list of all available message categories:
guids=system.get_message_categories(False)forguidinguids:
  print("GUID: {} Description: {}".format(guid, system.get_message_category_description(guid)))
If you replace "False" with "True" in "get_message_categories()" you only get the active message categories.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
SkriptMeldungen:Information:Build.py(23):Ausnahmefehler(<type'exceptions.AttributeError'>,AttributeError(u'F\xfcr dieses Objekt wurde kein parameterloser Konstruktor definiert.',),<tracebackobjectat0x000000000000002B>)SkriptMeldungen:Information:Build.py(23):    print("GUID: {} Description:{}".format(guid,system.get_message_category_description(guid)))SkriptMeldungen:Information:Build.py(23):Ausnahmefehler(<type'exceptions.AttributeError'>,AttributeError(u'F\xfcr dieses Objekt wurde kein parameterloser Konstruktor definiert.',),<tracebackobjectat0x000000000000002C>)
Kind regards
Dirk
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I would like to set up an automated software build system on a scripting base.
Therefore I start a batch file containing the "codesys --runscript" commands for a python script to compile a codesys project with the option --enablescripttracing.
This works fine, but the trace output is not redirected into a file completely.
On cmd prompt the batch file output ist redirected via "build.bat >> log1.dat" - ok
Within build.bat the python "print()" script commands are redirected via "> log2.dat Codesys --runscript ..." - ok
But the codesys compiler messages are displayed within cmd prompt
How can I redirect the messages that come out of codesys during e.g. the python command "app.create_boot_application(bootapppath)" ?
Best regards
Dirk
Hi DBe.
Here some example code:
BR
Martin
Hi Martin,
thank you very much! The compile information is printed within cmd prompt AND log file now .
During project creation I do a SVN checkout (via codesys addon). These reports are printed within cmd prompt only.
Is there another GUID available for this too?
BR
Dirk
Hi DBe.
Use the following code to get a list of all available message categories:
If you replace "False" with "True" in "get_message_categories()" you only get the active message categories.
BR
Martin
Hi Martin,
works fine - thank you!
Only one small remark:
"HMI Meldungen" has no constructor? Therefore you algo fails.
But a try-catch filters this.
BR
Dirk
Hi DBe.
Which version of CODESYS do you use when this error happened?
BR
Martin
Hi Martin,
I use Codesys 3.5 SP5 Patch 7 with a build profile 3.5 SP3.
Using these commands:
I get these errors:
Kind regards
Dirk
Hi Dirk.
The problem is not the HMI category. It's only the last working category before the error.
I tried it with two newer versions. With CODESYS V3.5 SP6 the problem still exists. With CODESYS V3.5 SP7 there is no error.
BR
Martin