lundi 8 avril 2019

I need help adding a raw input into the extracted string after the NOTIFY= portion within that string

I this have tool that works throughout, except for the "if" portion. So, what I'm trying to do, is extract the content within the "METADATA" parameter for this program. If theres already a NOTIFY=@user, I need to extend that to NOTIFY=@user,@user1 where @user1 was input into the 'prod_input' variable.

import aftractor.utils

import re



job_IDs = raw_input('INPUT JIDS: ')
prod_Input = raw_input('INPUT PROD usertag: ')

job_IDs_num = []
for each in job_IDs:
    if each.isdigit():
        job_IDs_num.append(each)

jid_merged = ''.join(job_IDs_num)



sep_nums = re.findall('.{1,7}', jid_merged)
list1 = sep_nums

#, columns=['title', 'jid', 'metadata']
with aftractor.utils.tractor_connection() as tq:
    for jid in list1:
        job = tq.jobs('jid=%s'%jid, columns=['jid', 'metadata'])
        print job
        job = job[0]
        metadata = job['metadata']
        if 'NOTIFY=' in metadata:
            metadata['NOTIFY='].append(prod_Input + ',')
        else:
            new_metadata = metadata + ' NOTIFY=%s'%prod_Input
            print new_metadata
            tq.jattr('jid in %s'%[jid], key = 'metadata', value = new_metadata)

Aucun commentaire:

Enregistrer un commentaire