gluish
gluish copied to clipboard
shellout broken when using json-strings and .format() style because of internal double-format
e.g.
cmd="esbulk
-server {server} -purge -mapping '{"mappings":{"{type}":{"properties":{"location":{"type":"geo_point"}}}}}' -index {index} -type {type} -w {workers} -id id -verbose {file}.ldj".format(**self.config)
output=shellout(cmd)
leads to:
Traceback (most recent call last): File "/home/metadata/.local/lib/python3.5/site-packages/luigi/worker.py", line 194, in run new_deps = self._run_get_new_deps() File "/home/metadata/.local/lib/python3.5/site-packages/luigi/worker.py", line 131, in _run_get_new_deps task_gen = self.task.run() File "/home/metadata/git/efre-lod-elasticsearch-tools/luigi/update_gn.py", line 91, in run cmd="esbulk -server {server} -purge -mapping '{"mappings":{"{type}":{"properties":{"location":{"type":"geo_point"}}}}}' -index {index} -type {type} -w {workers} -id id -verbose {file}.ldj".format(**self.config) KeyError: '"mappings"'
escaping the braces doesn't work either
Thanks @boerni667 for the report. It's ugly, but you can get around that by quoting a curly brace with a curly brace; I created an example. In short:
$ shellout(""" echo "Hello World" | awk '{{ print $0 }}' """)
this still doesn't work with .format()
>>>shellout(""" echo "Hello {w}" | awk '{{ print $0 }}' """.format(w="World")) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/dist-packages/gluish/utils.py", line 127, in shellout command = template.format(**kwargs) KeyError: ' print $0 '