public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Vikraman Choudhury" <vikraman.choudhury@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoostats:master commit in: client/bin/
Date: Fri,  6 May 2011 13:25:01 +0000 (UTC)	[thread overview]
Message-ID: <3c62442a093c2ac94f4bc1335d074e285c18b0b0.vikraman@gentoo> (raw)

commit:     3c62442a093c2ac94f4bc1335d074e285c18b0b0
Author:     Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
AuthorDate: Fri May  6 13:24:17 2011 +0000
Commit:     Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
CommitDate: Fri May  6 13:24:17 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoostats.git;a=commit;h=3c62442a

changes to client to post collected data to server

---
 client/bin/client |   53 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/client/bin/client b/client/bin/client
index c41de84..f920250 100755
--- a/client/bin/client
+++ b/client/bin/client
@@ -3,18 +3,55 @@
 from packages import Packages
 from useflags import UseFlags
 from environment import Environment
+import json
+import urllib, httplib
 
-def main():
+def getAuthInfo():
+  #TODO: Return public uuid and md5sum of password
+  auth_info = {
+      "UUID": "254e308c-d6a0-405c-aa1f-f21d9c1ea6e1",
+      "PASSWD": "5f4dcc3b5aa765d61d8327deb882cf99"
+      }
+  return auth_info
+
+def getPostData():
   p = Packages()
   u = UseFlags()
-  for cpv in p.getInstalledCPVs():
-    print cpv,
-    for x in u.getUseFlags(cpv):
-      print x,
-    print
   e = Environment()
-  for var in ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CHOST', 'FEATURES'):
-    print e.getVar(var)
+
+  post_data = {}
+  post_data['PROTOCOL'] = 1
+  post_data['AUTH'] = getAuthInfo()
+  for key in ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CHOST', 'FEATURES'):
+    post_data[key] = e.getVar(key)
+
+  packages = {}
+  for cpv in p.getInstalledCPVs(sort=True):
+    packages[cpv] = u.getUseFlags(cpv)
+  post_data['PACKAGES'] = packages
+
+  return post_data
+
+def serialize(object, human=False):
+  if human:
+    indent = 2
+    sort_keys = True
+  else:
+    indent = None
+    sort_keys = False
+  return json.JSONEncoder(indent=indent, sort_keys=sort_keys).encode(object)
+
+def main():
+  post_body = serialize(getPostData(), human=True)
+  print post_body
+  post_headers = {"Content-type": "application/json"}
+  myuuid = getAuthInfo()['UUID']
+  conn = httplib.HTTPConnection("127.0.0.1:8080")
+  conn.request('POST', '/' + myuuid, headers=post_headers, body=post_body)
+  #TODO: Handle exceptions
+  response = conn.getresponse()
+  print response.status, response.reason
+  print 'Server response: ' + response.read()
 
 if __name__ == "__main__":
   main()



                 reply	other threads:[~2011-05-06 13:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c62442a093c2ac94f4bc1335d074e285c18b0b0.vikraman@gentoo \
    --to=vikraman.choudhury@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox