Gradle copy task expand yaml file escape whole string - templates

I have the following gradle task:
processResources {
inputs.properties(project.properties.findAll { it.value instanceof String })
filesMatching("**/*.yaml") {
filteringCharset = 'UTF-8'
expand project.properties
}
}
that I use to process a spring boot application.yaml file that contains variable placeholders.
How can I escape a whole log pattern without escaping every single special character, thus keeping the pattern clean?
application.yaml:
logging:
pattern:
console: %clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}
Tried using slashy strings with no success:
1.Tried:
/%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}/
Error:
Caused by: groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript8.groovy: 138: expecting '}', found 'HH' # line 138, column 60.
ATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.S
^
2.Tried:
$/%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}/$
Error:
Caused by: groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript10.groovy: 138: illegal string body character after dollar sign;
solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" # line 138, column 15.
console: $/%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}/$
^

Given that your YAML files contains character which are interpreted as tokens by the expand method, relying on Groovy's SimpleTemplateEngine, you should use an alternative method like the filter methods.
The documentation shows a number of examples of filter. By using the underlying Ant ReplaceTokens you might have better luck, as it uses #token# as the notation.

Related

Compilation error in nested casting inside a rule in drools

I am using the # operator, and while with one casting it works fine, having two in the same rule it does not compile. The sentence is the following
configuration#RuleSetConfiguration.configurationRule[0].configurationRuleAction#FilteringAction.filteringActionType==$mspl1.configuration#RuleSetConfiguration.configurationRule[0].configurationRuleAction#FilteringAction
And it returns the following compilation error:
[ERR 102] Line 62:87 mismatched input '#' in rule "verify_same_filtering_l4_behaviour" [Message [id=1, kieBase=rules, level=ERROR, path=/home/santiago/eclipse-workspace/DroolKieServer/target/classes/com/sample/rules/Rule.drl, line=62, column=0 text=[ERR 102] Line 62:87 mismatched input '#' in rule "verify_same_filtering_l4_behaviour"], Message [id=2, kieBase=rules, level=ERROR, path=/home/santiago/eclipse-workspace/DroolKieServer/target/classes/com/sample/rules/Rule.drl, line=0, column=0 text=Parser returned a null Package]]
I have tried to use brackets but the result is the same. Is there a limitation on the castings that can be done over a rule?
Greetings
I tried to do two castings in the rule. The expected result is to compile fine due to the use of the # operator is correct, but it returns the compilation error
`
[Message [id=1, kieBase=rules, level=ERROR, path=/home/santiago/eclipse-workspace/DroolKieServer/target/classes/com/sample/rules/Rule.drl, line=62, column=0
text=[ERR 102] Line 62:87 mismatched input '#' in rule "verify_same_filtering_l4_behaviour"], Message [id=2, kieBase=rules, level=ERROR, path=/home/santiago/eclipse-workspace/DroolKieServer/target/classes/com/sample/rules/Rule.drl, line=0, column=0
text=Parser returned a null Package]]
`
The problem was about using the # operator after a list. Instead of that, the standard Java casting have being used and it works fine:
((FilteringAction)((RuleSetConfiguration)configuration).configurationRule[0].configurationRuleAction)

pandoc error: [WARNING] Could not parse YAML metadata: Unexpected 'd'

I am not sure why I get the following error message while converting markdown to PDF with a template:
[WARNING] Could not parse YAML metadata at line 10 column 1: Unexpected 'd'
Here is the command I use to build the document:
pandoc --template eisvogel -o output.pdf input.md
Here is the markdown file:
---
titlepage: true
title: Some title
author: [Author]
date: "2022-11-25"
colorlinks: true
disable-header-and-footer: true
---
# Quick Introduction
A famous guy once said:
The error occurs when I add the disable-header-and-footer: true. If this line is not here, then the Pandoc processes the document.
The space after the colon in the offending line is not a normal (ASCII) space but the Unicode character U+202F, "Narrow Non-Break Space". The YAML parser doesn't see a key-value pair but a single word because of that. Replace it with an ASCII space and everything should work.

Resource Regex Cause Panic

This code is an attempt to replace a service that already works in production, written in java, with one written in rust.
This service will serve as a sidecar proxy for a redis cluster, exposing an api rest. It needs to maintain compatibility with the current api.
The Route is:
"/api/keys/{path:*}"
In path we can put de name of the key for redis, and can contain any format below:
/api/keys/users/41728391
/api/keys/users/1000/followers
/api/keys/users/{1234}/data
this is my attempt
HttpServer::new(move || App::new()
.data(redis_config)
.service(
web::resource("/set/{path:*}").route(web::put().to(set_key))
) ).bind(("127.0.0.1", 8080))?
.run()
.await
I tried like this too:
#[get("/set/{path:*}")]...
But in two cases i get this error:
.service(web::resource("/set/{path:*}").route(web::put().to(path_regex)))
| ^^^^^^^^^^ the trait `Factory<_, _, _>` is not implemented for `path_regex`
thread 'thread 'actix-rt:worker:1actix-rt:worker:0' panicked at '' panicked at 'Wrong path pattern: "/set/{path:*}" regex parse error:
^/set/(?P<path>*)$
^
error: repetition operator missing expressionWrong path pattern: "/set/{path:*}" regex parse error:
^/set/(?P<path>*)$
^
I have read the https://actix.rs/actix-web/actix_web/web/fn.resource.html
My code is : https://github.com/rogeriob2br/enge-sidecar-redis

"YYYYMMDD": Invalid identifier error while trying through SQOOP

Please help me out from the below error.It works fine when checked in oracle but fails when trying through SQOOP import.
version : Hadoop 0.20.2-cdh3u4 and Sqoop 1.3.0-cdh3u5
sqoop import $SQOOP_CONNECTION_STRING
--query 'SELECT st.reference,u.unit,st.reading,st.code,st.read_id,st.avg FROM reading st,tunit `tu,unit u
WHERE st.reference=tu.reference and st.number IN ('218730','123456') and tu.unit_id = u.unit_id
and u.enrolled='Y' AND st.reading <= latest_off and st.reading >= To_Date('20120701','yyyymmdd')
and st.type_id is null and $CONDITIONS'
--split-by u.unit
--target-dir /sample/input
Error:
12/10/10 09:33:21 ERROR manager.SqlManager: Error executing statement:
java.sql.SQLSyntaxErrorException: ORA-00904: "YYYYMMDD": invalid identifier
followed by....
12/10/10 09:33:21 ERROR sqoop.Sqoop: Got exception running Sqoop:
java.lang.NullPointerException
Thanks & Regards,
Tamil
I believe that the problem is actually on Bash side (or your command line interpret). Your query contains for example following fragment u.enrolled='Y'. Please notice that you're escaping character constants with single quotes. You seem to be putting entire query into additional single quotes: --query 'YOUR QUERY'. Which results in something like --query '...u.enrolled='Y'...'. However such string is stripped by bash to '...u.enrolled=Y...'. You can verify that by using "echo" to see what exactly will bash do with your string before it will be passed to Sqoop.
jarcec#jarcec-thinkpad ~ % echo '...u.enrolled='Y'...'
...u.enrolled=Y..
.
I would recommend to either escape all single quotes (\') inside your query or choose double quotes for entire query. Please note that the later option will require escaping $ characters with backslash (\$).

problem in decoupling urls.py , while following a tutorial of django

http://docs.djangoproject.com/en/dev/intro/tutorial03/
I was at the step Decoupling the URLconfs where the tutorial illustrates how to decouple urls.py. On doing exactly what it says, i get the following error-
error at /polls/1/
nothing to repeat
Request Method: GET
Request URL: http://localhost:8000/polls/1/
Exception Type: error
Exception Value:
nothing to repeat
Exception Location: C:\jython2.5.1\Lib\re.py in _compile, line 241
Python Executable: C:\jython2.5.1\jython.bat
Python Version: 2.5.1
Python Path: ['E:\\Programming\\Project\\django_app\\mysite', 'C:\\jython2.5.1\\Lib\\site-packages\\setuptools-0.6c11-py2.5.egg', 'C:\\jython2.5.1\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\jython2.5.1\\Lib\\site-packages']
Server time: Mon, 12 Apr 2010 12:02:56 +0530
Check your regex syntax. In particular, see if you are missing an opening parenthesis before a ? towards the beginning of the pattern, as in
r'^?P<poll_id>\d+)/$'
# ^ note the missing parenthesis
The above should read
r'^(?P<poll_id>\d+)/$'
instead.
(An explanation: "nothing to repeat" is a regex error which arises due to an ? regex operator occurring where it is not preceded by something which it can sensibly attach to. The ? in (?P<...>...) is treated specially, but if you forget the opening parenthesis, the regex engine will treat ? in the regular way, which makes no sense right after ^.)