Jan-13-2025, 10:33 PM
Hi!
In my python I need to parse the argument list like these:
Any idea?
Thanks
In my python I need to parse the argument list like these:
"call_type: "I" alert_id: "101 " data_center: "TOTAL " memname: " " order_id: "0000c" severity: "V" status: "Not_Noticed " send_time: "20250113232733" last_user: " " last_time: " " message: "Ended not OK" run_as: "admin " sub_application: "subapp " application: "app " job_name: "JOB_FALLIDO " host_id: "em2 " alert_type: "R" closed_from_em: " " ticket_number: " " run_counter: "00014 ""I'm trying with argparse but some filed is not well recognized:
def parse_args(): # Crear el parser parser = argparse.ArgumentParser(description="Parsear los argumentos en formato clave-valor") # Definir los argumentos esperados (aunque no se sabe el número exacto, usaremos un enfoque flexible) parser.add_argument('args', nargs='+', help="Lista de argumentos clave:valor") # Parsear los argumentos return parser.parse_args()It shows me:
2025-01-13 23:30:00 - INFO - call_type: I alert_id: 97 2025-01-13 23:30:00 - INFO - data_center: TOTAL 2025-01-13 23:30:00 - INFO - memname: 2025-01-13 23:30:00 - INFO - order_id: 0000c severity: V status: Not_Noticed 2025-01-13 23:30:00 - INFO - send_time: 20250113225049 last_user: 2025-01-13 23:30:00 - INFO - last_time: 2025-01-13 23:30:00 - INFO - message: Ended 2025-01-13 23:30:00 - INFO - OK run_as: admin 2025-01-13 23:30:00 - INFO - sub_application: subapp 2025-01-13 23:30:00 - INFO - application: app 2025-01-13 23:30:00 - INFO - job_name: JOB_FALLIDO 2025-01-13 23:30:00 - INFO - host_id: em2 2025-01-13 23:30:00 - INFO - alert_type: R closed_from_em: 2025-01-13 23:30:00 - INFO - ticket_number: 2025-01-13 23:30:00 - INFO - run_counter: 00010I need call_type, alert_id, order_id, serverity, status, last_user and so on separated.
Any idea?
Thanks