Commit 330279c2 authored by Sigmund Augdal's avatar Sigmund Augdal

Read/write zabbixauth in home dir rather than directory of script

parent e77720a6
......@@ -8,8 +8,6 @@ import requests
import sys
import time
base_dir = os.path.dirname(os.path.realpath(__file__))
auth = None
SEVERITIES = {
......@@ -24,7 +22,7 @@ SEVERITIES = {
def get_auth():
try:
with open(os.path.join(base_dir, '.zabbixauth'), 'r') as fh:
with open(os.path.join(os.path.expanduser('~'), '.zabbixauth'), 'r') as fh:
return fh.read().strip()
except:
return None
......@@ -55,7 +53,7 @@ def login():
username = input('Username: ')
password = getpass.getpass()
result = invoke('user.login', user=username, password=password)
with open(os.path.join(base_dir, '.zabbixauth'), 'w') as fh:
with open(os.path.join(os.path.expanduser('~'), '.zabbixauth'), 'w') as fh:
fh.write(result + "\n")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment