UnboundLocalError: local variable 'additional_info' referenced before assignment

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MariusMardar
    New Member
    • Jul 2012
    • 1

    UnboundLocalError: local variable 'additional_info' referenced before assignment

    How can I fix it ???

    Code:
    snmp_actions_table = 'snmp_actions'
            action='precondition' + oid_name
            additional_info = self.config.get_campaign()      
            if self.val != expected:
                result='N'
    	    #print 'oid_name = ', oid_name
                if oid_name == "MT120_SW_mt120SwTableStatus" :
                    states_download_mt120=["Idle","Downloading","Downloaded","Abort_downloaded"]
                    val8888_mt120_swr='Empty field'
                    if expected == 8888 :
                        additional_info='precondition  check failed , expected ' + val8888_mt120_swr + ' found ' +  states_download_mt120[self.val]
                    else:
                 	    additional_info='precondition  check failed , expected ' + states_download_mt120[expected] + ' found ' +  states_download_mt120[self.val]
                elif oid_name == "associatedBsc.Table.1.mt120ReplacementStatus" :
               	states_mt120_swr=["Idle","Preloading","Preloaded","Abort_Preloaded","Activating","Activated","Accepting","Rejecting"]
                	val8888_mt120sw='Empty field' 
                	if expected == 8888 :
                        additional_info='precondition  check failed , expected ' + val8888_mt120sw +  ' found ' +  states_mt120_swr[self.val]
                    else:  
                	    additional_info='precondition  check failed , expected ' + states_mt120_swr[expected] + ' found ' +  states_mt120_swr[self.val]
                elif oid_name == "softwareManagement.swReplacementStatus":
    	#	print 'In if de la tcif '
                    states_tcif_swr=["Idle","Downloading","Downloaded","Activating","Activated","Accepting","Aborting","Rejecting"]
                    additional_info='precondition  check failed , expected ' + states_tcif_swr[expected] + ' found ' +  states_tcif_swr[self.val]
                print 'Dupa if '
                self.result='NOK'
            else:
                result = 'P'
                additional_info='precondition ok'
                if self.result == 'NONE':
                    self.result = 'OK'
            #self.test_logger.LogAction(snmp_actions_table,action,result,additional_info)
            end_time = strftime("%H:%M:%S")
            self.test_logger.LogAction(snmp_actions_table,action,result,additional_info,start_time,end_time)
            test_id = self.test_logger.getTestId()
            self.test_logger.UpdateResult('snmp_test',test_id,self.result)
            self.assertEqual(self.val, expected,'precondition check failed')
    Last edited by Rabbit; Jul 23 '12, 03:38 PM. Reason: Please use code tags when posting code.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    "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

    Comment

    Working...