Python dictionary key is not identified -
i have method following,
@staticmethod def get_repo(tenant_id): """ :param int tenant_id: :return: gitrepository object :rtype: gitrepository """ agentgithandler.log.info(agentgithandler.__git_repositories) agentgithandler.log.info("tenant id %s" %tenant_id) key,value in agentgithandler.__git_repositories.iteritems(): if tenant_id == key: agentgithandler.log.info("key matching") agentgithandler.log.info(agentgithandler.__git_repositories[key]) agentgithandler.log.info("key %s : value %s ", key,value) if tenant_id in agentgithandler.__git_repositories: return agentgithandler.__git_repositories[tenant_id] agentgithandler.log.info("false condition") return none
i trying call above function following,
git_repo = agentgithandler.get_repo(tenant_id) git_repo.scheduled_update_task.terminate()
tenant_id parameter value -1234 in dictionary key. getting response below.
2015-06-01 13:44:54,979:info:processing tenant unsubscribed event: [tenant] -1234 [application id] single-cartridge-app 2015-06-01 13:44:54,980:info:{u'-1234': <modules.artifactmgt.git.agentgithandler.gitrepository instance @ 0x1cbeb00>} 2015-06-01 13:44:54,980:info:tenant id -1234 2015-06-01 13:44:54,980:info:key -1234 : value <modules.artifactmgt.git.agentgithandler.gitrepository instance @ 0x1cbeb00> 2015-06-01 13:44:54,980:info:false condition 2015-06-01 13:44:54,980:info:git_repo none 2015-06-01 13:44:54,980:error:error processing 'applicationsignupremovedevent' event traceback (most recent call last): file "/mnt/apache-stratos-python-cartridge-agent-4.1.0-snapshot/modules/subscriber/eventsubscriber.py", line 103, in run handler(event_msg) file "agent.py", line 294, in on_application_signup_removed self.__event_handler.on_application_signup_removed_event(event_obj) file "/mnt/apache-stratos-python-cartridge-agent-4.1.0-snapshot/modules/event/eventhandler.py", line 355, in on_application_signup_removed_event agentgithandler.remove_repo(application_signup_removal_event.tenantid) file "/mnt/apache-stratos-python-cartridge-agent-4.1.0-snapshot/modules/artifactmgt/git/agentgithandler.py", line 414, in remove_repo git_repo.scheduled_update_task.terminate() attributeerror: 'nonetype' object has no attribute 'scheduled_update_task'
why if condition getting false ?
you in doc string tenant_id
int, , appears 1 in log, dictionary key unicode string, -1234 != u'-1234'
.
Comments
Post a Comment