diff options
author | 2011-06-19 23:40:21 +0530 | |
---|---|---|
committer | 2011-06-19 23:40:21 +0530 | |
commit | 76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df (patch) | |
tree | 4fdd622befc108d941d92c950781375edfff4d56 /client | |
parent | initial version of ebuild for client (diff) | |
download | gentoostats-76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df.tar.gz gentoostats-76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df.tar.bz2 gentoostats-76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df.zip |
update client to handle uuid and passwd
Diffstat (limited to 'client')
-rwxr-xr-x | client/gentoostats-send | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/client/gentoostats-send b/client/gentoostats-send index d749c2a..9a9cd39 100755 --- a/client/gentoostats-send +++ b/client/gentoostats-send @@ -1,24 +1,33 @@ #!/usr/bin/env python from gentoostats.payload import Payload +import ConfigParser +import sys import json import urllib, httplib def getAuthInfo(): - #TODO: Return public uuid and md5sum of password - auth_info = { - "UUID": "254e308c-d6a0-405c-aa1f-f21d9c1ea6e1", - "PASSWD": "5f4dcc3b5aa765d61d8327deb882cf99" - } - return auth_info + config = ConfigParser.ConfigParser() + if len(config.read('/etc/gentoostats/auth.cfg')) == 0: + sys.stderr.write('Cannot read auth.cfg') + sys.exit(1) + + try: + uuid = config.get('AUTH', 'UUID') + passwd = config.get('AUTH', 'PASSWD') + auth_info = {'UUID' : uuid, 'PASSWD' : passwd} + return auth_info + except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): + sys.stderr.write('Malformed auth.cfg') + sys.exit(1) def serialize(object, human=False): if human: - indent = 2 - sort_keys = True + indent = 2 + sort_keys = True else: - indent = None - sort_keys = False + indent = None + sort_keys = False return json.JSONEncoder(indent=indent, sort_keys=sort_keys).encode(object) def main(): |