Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from zabbix.api import ZabbixAPI
- from zabbix.api import ZabbixAPIException
- class ZabbixClient(ZabbixAPI):
- def __init__(self, url='http://localhost', use_authenticate=False, user='Admin', password='zabbix'):
- self.url=url
- self.use_authenticate=use_authenticate
- super(ZabbixClient,self).__init__(url=self.url,use_authenticate=self.use_authenticate, user=user, password=password)
- def delete_host(self, hostid):
- try:
- deleted=self.host.delete(hostid)
- except ZabbixAPIException as ex: <---------- here i want to use the exception imported from the zabbix.api file
- pass
- return False
- return deleted
- $ python zbx-reg.py
- Traceback (most recent call last):
- File "zbx-reg.py", line 12, in <module>
- from zabbix.api import ZabbixAPIException
- ImportError: cannot import name ZabbixAPIException
- (venv) rojo@minishift:~/os-zbx$
- $ python
- Python 2.7.12 (default, Nov 19 2016, 06:48:10)
- [GCC 5.4.0 20160609] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import zabbix.api
- >>> dir (zabbix.api)
- ['ZabbixAPI', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__warningregistry__', 'warnings']
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement