By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,332 Members | 1,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,332 IT Pros & Developers. It's quick & easy.

UnboundLocalError: local variable 'additional_info' referenced before assignment

P: 1
How can I fix it ???

Expand|Select|Wrap|Line Numbers
  1. snmp_actions_table = 'snmp_actions'
  2.         action='precondition' + oid_name
  3.         additional_info = self.config.get_campaign()      
  4.         if self.val != expected:
  5.             result='N'
  6.         #print 'oid_name = ', oid_name
  7.             if oid_name == "MT120_SW_mt120SwTableStatus" :
  8.                 states_download_mt120=["Idle","Downloading","Downloaded","Abort_downloaded"]
  9.                 val8888_mt120_swr='Empty field'
  10.                 if expected == 8888 :
  11.                     additional_info='precondition  check failed , expected ' + val8888_mt120_swr + ' found ' +  states_download_mt120[self.val]
  12.                 else:
  13.                      additional_info='precondition  check failed , expected ' + states_download_mt120[expected] + ' found ' +  states_download_mt120[self.val]
  14.             elif oid_name == "associatedBsc.Table.1.mt120ReplacementStatus" :
  15.                states_mt120_swr=["Idle","Preloading","Preloaded","Abort_Preloaded","Activating","Activated","Accepting","Rejecting"]
  16.                 val8888_mt120sw='Empty field' 
  17.                 if expected == 8888 :
  18.                     additional_info='precondition  check failed , expected ' + val8888_mt120sw +  ' found ' +  states_mt120_swr[self.val]
  19.                 else:  
  20.                     additional_info='precondition  check failed , expected ' + states_mt120_swr[expected] + ' found ' +  states_mt120_swr[self.val]
  21.             elif oid_name == "softwareManagement.swReplacementStatus":
  22.     #    print 'In if de la tcif '
  23.                 states_tcif_swr=["Idle","Downloading","Downloaded","Activating","Activated","Accepting","Aborting","Rejecting"]
  24.                 additional_info='precondition  check failed , expected ' + states_tcif_swr[expected] + ' found ' +  states_tcif_swr[self.val]
  25.             print 'Dupa if '
  26.             self.result='NOK'
  27.         else:
  28.             result = 'P'
  29.             additional_info='precondition ok'
  30.             if self.result == 'NONE':
  31.                 self.result = 'OK'
  32.         #self.test_logger.LogAction(snmp_actions_table,action,result,additional_info)
  33.         end_time = strftime("%H:%M:%S")
  34.         self.test_logger.LogAction(snmp_actions_table,action,result,additional_info,start_time,end_time)
  35.         test_id = self.test_logger.getTestId()
  36.         self.test_logger.UpdateResult('snmp_test',test_id,self.result)
  37.         self.assertEqual(self.val, expected,'precondition check failed')
Jul 23 '12 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 626
"referenced before assignment" means that the variable has not yet been declared. I will leave it to you to learn how to Google for the error message as these very simple error messages are already explained on many sites. If you don't already know, there are many beginner tutorials available http://wiki.python.org/moin/Beginner...NonProgrammers
Jul 27 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.