Commit ce342369 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Logging subprocess stdout

parent 69d14a50
......@@ -43,7 +43,7 @@ QUEUE_WFCATALOG_UPDATE = (
connection = None
session = None
logger = logging.getLogger(__name__)
logger = logging.getLogger('amqpWorker')
logger.setLevel(level=logging.INFO if RUNMODE == "production" else logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
......@@ -53,6 +53,9 @@ handler.setFormatter(formatter)
logger.addHandler(handler)
def grouper(seq, size):
"""
Split a sequence in a fixed-size list of sequences
"""
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
......@@ -144,19 +147,18 @@ def wfcatalog(content):
for chunk in grouper(content.splitlines(), 50):
logger.info("launching WFCatalog update on : %s" % str(chunk))
files = json.dumps(chunk)
p = subprocess.Popen(
out = subprocess.Popen(
[
"python3",
"/home/sysop/wfcatalog/collector/WFCatalogCollector.py",
"./wfcatalog/collector/WFCatalogCollector.py",
"--update",
"--force",
"--logfile",
"/home/sysop/wfcatalog_amqp.log",
"--stdout",
"--list",
files,
]
)
p.wait()
], stdout=subprocess.PIPE
).communicate()[0]
print(out.decode('utf-8'))
if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment