Skip to content

Commit

Permalink
Better error handling when the environment variable /uio/kant/usit-db…
Browse files Browse the repository at this point in the history
…d-u1/rafael is not defined. [Issue:#28]
  • Loading branch information
rafaelma committed Mar 21, 2017
1 parent f391d53 commit 42862c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 16 additions & 3 deletions bin/zabbix-cli
Expand Up @@ -98,9 +98,21 @@ if __name__ == '__main__':
auth_token = ''
username = ''
password = ''
zabbix_auth_file = ''
zabbix_auth_token_file = ''

zabbix_auth_file = os.getenv('HOME') + '/.zabbix-cli_auth'
zabbix_auth_token_file = os.getenv('HOME') + '/.zabbix-cli_auth_token'
if os.getenv('HOME') is not None:

zabbix_auth_file = os.getenv('HOME') + '/.zabbix-cli_auth'
zabbix_auth_token_file = os.getenv('HOME') + '/.zabbix-cli_auth_token'

else:
print '\n[ERROR]: The $HOME environment variable is not defined. Zabbix-CLI cannot read ~/.zabbix-cli_auth or ~/.zabbix-cli_auth_token'

if conf.logging == 'ON':
logs.logger.error('The $HOME environment variable is not defined. Zabbix-CLI cannot read ~/.zabbix-cli_auth or ~/.zabbix-cli_auth_token')

sys.exit(1)

if os.path.isfile(zabbix_auth_file):

Expand Down Expand Up @@ -326,4 +338,5 @@ if __name__ == '__main__':

sys.exit(0)


except Exception as e:
print '\n[ERROR]: %s\n',e
8 changes: 7 additions & 1 deletion bin/zabbix-cli-init
Expand Up @@ -46,7 +46,13 @@ def replace(file_path, pattern, subst):

if __name__ == "__main__":

zabbixconfdir = getenv('HOME')+"/.zabbix-cli/"
if os.getenv('HOME') is not None:
zabbixconfdir = getenv('HOME')+"/.zabbix-cli/"

else:
print '\n[ERROR]: The $HOME environment variable is not defined. zabbix-cli-init cannot generate the configuration file in your home directory.'
sys.exit(1)

defconf="/usr/share/zabbix-cli/zabbix-cli.conf"
filename="zabbix-cli.conf"

Expand Down

0 comments on commit 42862c9

Please sign in to comment.