Commit 4391708d authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Un peu de pylint

parent 91fa124c
......@@ -69,20 +69,20 @@ def validated_data_integrated_files(content):
# forward content to Seedtree queue
sender = connection.create_sender(QUEUE_SEEDTREE_UPDATE)
message = Message(durable=True, body=content)
logger.info("forwarding message to queue %s" % QUEUE_SEEDTREE_UPDATE)
logger.info("forwarding message to queue %s", QUEUE_SEEDTREE_UPDATE)
sender.send(message)
# forward content to WFcatalog queue
sender = connection.create_sender(QUEUE_WFCATALOG_UPDATE)
message = Message(durable=True, body=content)
logger.info("forwarding message to queue %s" % QUEUE_WFCATALOG_UPDATE)
logger.info("forwarding message to queue %s", QUEUE_WFCATALOG_UPDATE)
sender.send(message)
# forward content to seedpsd-data queue. On message per line
sender = connection.create_sender(QUEUE_SEEDPSD_DATA)
logger.info("forwarding message to queue %s" % QUEUE_SEEDPSD_DATA)
for f in content.split('\n'):
message = Message(durable=True, body=f)
logger.info("forwarding message to queue %s", QUEUE_SEEDPSD_DATA)
for line in content.split('\n'):
message = Message(durable=True, body=line)
sender.send(message)
......@@ -90,7 +90,7 @@ def seedtree(content):
"""
Get filenames from incoming message, sort filenames by Seedtree database schema.
Lauch each subsequent Seedtree scans.
Send subsequent messages to applications depending on Seedtree scans.
Send subsequent messages to applications depending on Seedtree scans.
"""
# get a fresh RESIF inventory
logger.info("getting RESIF inventory...")
......@@ -111,10 +111,10 @@ def seedtree(content):
# get full network code for current file
fullnetwork = inv.get_full_network_code(network, station)
if not fullnetwork:
logger.error("full networkcode not found for file %s" % filename)
logger.error("full networkcode not found for file %s", filename)
updateagain += filename + "\n"
continue
logger.debug("new file : %s, full network code : %s " % (filename, fullnetwork))
logger.debug("new file : %s, full network code : %s ", filename, fullnetwork)
fileDict.setdefault(fullnetwork, []).append(filename)
# get seedtree schema name corresponding to this network
schema = inv.get_seedtree_schema(fullnetwork)
......@@ -123,15 +123,13 @@ def seedtree(content):
# send files with problems to an alternate list, for future manual processing
if updateagain:
logger.error(
"sending message to %s : %s" % (QUEUE_SEEDTREE_UPDATE_AGAIN, updateagain)
)
logger.error("sending message to %s : %s", QUEUE_SEEDTREE_UPDATE_AGAIN, updateagain)
sender = connection.create_sender(QUEUE_SEEDTREE_UPDATE_AGAIN)
message = Message(durable=True, body=updateagain)
sender.send(message)
# for each network code in fileDict, launch Seedtree updates
for network in fileDict:
for network in fileDict.items():
# get seedtree schema name
schema = inv.get_seedtree_schema(network)
# build a stringIO containing all filenames
......@@ -143,14 +141,14 @@ def seedtree(content):
mystdin.seek(0)
# lauch seedtree instance
logger.info(
"launching filetree.py --insert %s)" % (schema)
"launching filetree.py --insert %s)", (schema)
)
p = subprocess.Popen([sys.executable, f"{SEEDTREE_PATH}/filetree.py", "--insert", schema], stdin=subprocess.PIPE)
p.communicate(mystdin.read().encode())
logger.info("lauching Seedtree (--sync %s)" % schema)
logger.info("lauching Seedtree (--sync %s)", schema)
p = subprocess.Popen([sys.executable, f"{SEEDTREE_PATH}/seedtree5.py", "--sync", schema])
p.wait()
logger.info("lauching Seedtree (--computeproducts %s)" % schema)
logger.info("lauching Seedtree (--computeproducts %s)", schema)
p = subprocess.Popen([sys.executable, f"{SEEDTREE_PATH}/seedtree5.py", "--computeproducts", schema])
p.wait()
......@@ -203,28 +201,28 @@ if __name__ == "__main__":
logger.info("Connected to %s : %s", AMQP_SERVER, connection)
try:
# wait for message on queue
logger.info(
"waiting for incoming message on queue %s ~~~~~~~~~~~~ " % queue
)
message = receiver.receive(timeout=None)
logger.info("message received : %s" % message)
# launch subsequent action
if isinstance(message.body, bytes):
m = message.body.decode('utf-8')
else:
m = message.body
if args.validated_data_integrated_files:
validated_data_integrated_files(m)
if args.seedtree:
seedtree(m)
if args.wfcatalog:
wfcatalog(m)
receiver.accept()
logger.info("message acknowledged")
# wait for message on queue
logger.info(
"waiting for incoming message on queue %s ~~~~~~~~~~~~ ", queue
)
message = receiver.receive(timeout=None)
logger.info("message received : %s", message)
# launch subsequent action
if isinstance(message.body, bytes):
m = message.body.decode('utf-8')
else:
m = message.body
if args.validated_data_integrated_files:
validated_data_integrated_files(m)
if args.seedtree:
seedtree(m)
if args.wfcatalog:
wfcatalog(m)
receiver.accept()
logger.info("message acknowledged")
except Exception as err:
logger.critical(traceback.format_exc())
logger.critical(str(err))
......
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