I would appreciate it if you could tell me about the 'ErrorReturnCode' that is currently occurring.
happylie opened this issue · comments
온실 속 선인장 commented
It is normal that there is no current result value.
If the result is present, no Error occurs.
If there is no data value, is it right to occur like 'ErrorReturnCode'?
No message found in STDOUT/STDERR.
I'll leave a simple test code.
I'd appreciate it if you could tell me about the contents.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sh
def test_sh(application_properties):
cat = sh.Command("cat")
grep = sh.Command("grep")
try:
result = grep(grep(cat(application_properties), "-v", "#"), "management.endpoints.web.base-path")
except sh.ErrorReturnCode as e:
print(e)
return None
output = str(result).strip()
return output.split("=")[-1]
if __name__ == "__main__":
path = './application.properties'
print(test_sh(path))
Now let's look at the problematic cases.
$ cat application.properties
spring.application.name=hello
spring.profiles=default,development
management.endpoint.restart.enabled=true
# management.endpoints.web.base-path=/manage
$ python ex_sh.py
RAN: /usr/bin/grep management.endpoints.web.base-path
STDOUT:
STDERR:
None
Now let's look at the normal case.
$ cat application.properties
spring.application.name=hello
spring.profiles=default,development
management.endpoint.restart.enabled=true
management.endpoints.web.base-path=/manage
$ python ex_sh.py
/manage
Thank you.
Erik Cederstrand commented
This is just how grep
works. See my comment in #629 (comment)
Erik Cederstrand commented
Closing as duplicate of #629