Reputation: 345
I have the following code in which am trying to loop over every entry of GerritInfo and add logic based on that but running into below error can anyone suggest what is wrong here and how to overcome this?
#!/usr/bin/python
GerritInfo = {'Assignee': username, 'RCAInfo': 'Provided', 'PLProductLine': 'LNX.LA.0.0', 'GerritInfo': [{'Url': 'https://review-android.company.com/761190', 'Status': 'MERGED', 'kw_ran': 'kw running', 'Info': 'ALREADY INTEGRATED', 'lookahead_ran': 'lookahead running'}, {'Url': 'https://review-android.company.com/777849', 'Status': 'NEW', 'kw_ran': 'kw did not run', 'Info': 'Available', 'lookahead_ran': 'lookahead running'}], 'CRId': '<a href="http://prism/CR/664310">664310</a>', 'CRStatus': Fix, 'RNotesStatus': 'Yes', 'TargetName': MSM8916, 'IsDevComplete': True}
if (('Not Provided' in GerritInfo['GerritInfo'][0]['Url'] or 'Wrong Gerrit Provided' in GerritInfo['GerritInfo'][0]['Url']) or ('NEW' in GerritInfo['GerritInfo'][0]['Status'] or 'ABANDONED' in GerritInfo['GerritInfo'][0]['Status'] or 'Yes' not in GerritInfo['RNotesStatus'] or 'Provided' not in GerritInfo['RCAInfo'] or 'False' in str(GerritInfo['IsDevComplete']))):
print "Inside if"
else:
print "in else"
Error:-
Traceback (most recent call last):
File "infoloop.py", line 3, in <module>
GerritInfo = {'Assignee': username, 'RCAInfo': 'Provided', 'PLProductLine': 'LNX.LA.0.0', 'GerritInfo': [{'Url': 'https://review-android.company.com/761190', 'Status': 'MERGED', 'kw_ran': 'kw running', 'Info': 'ALREADY INTEGRATED', 'lookahead_ran': 'lookahead running'}, {'Url': 'https://review-android.company.com/777849', 'Status': 'NEW', 'kw_ran': 'kw did not run', 'Info': 'Available', 'lookahead_ran': 'lookahead running'}], 'CRId': '<a href="http://prism/CR/664310">664310</a>', 'CRStatus': Fix, 'RNotesStatus': 'Yes', 'TargetName': MSM8916, 'IsDevComplete': True}
NameError: name 'username' is not defined
Thanks
Upvotes: 0
Views: 8040
Reputation: 75555
Either define the variable username
or add quotes "username"
, if you had intended to use the String value "username"
.
Upvotes: 3