aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikraman Choudhury <vikraman.choudhury@gmail.com>2011-06-19 23:40:21 +0530
committerVikraman Choudhury <vikraman.choudhury@gmail.com>2011-06-19 23:40:21 +0530
commit76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df (patch)
tree4fdd622befc108d941d92c950781375edfff4d56
parentinitial version of ebuild for client (diff)
downloadgentoostats-76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df.tar.gz
gentoostats-76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df.tar.bz2
gentoostats-76dc7f6db42c5cd8ff4862308fafa2e7a0b7a8df.zip
update client to handle uuid and passwd
-rwxr-xr-xclient/gentoostats-send29
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():