From: "Vikraman Choudhury" <vikraman.choudhury@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoostats:master commit in: client/gentoostats/, client/
Date: Mon, 1 Aug 2011 23:04:01 +0000 (UTC) [thread overview]
Message-ID: <a1a9949f57f294cd001d8589fdc727de9c19aae8.vikraman@gentoo> (raw)
commit: a1a9949f57f294cd001d8589fdc727de9c19aae8
Author: Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
AuthorDate: Mon Aug 1 23:03:09 2011 +0000
Commit: Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
CommitDate: Mon Aug 1 23:03:09 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoostats.git;a=commit;h=a1a9949f
add search to gentoostats-cli
---
client/gentoostats-cli | 4 ++--
client/gentoostats/search.py | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/client/gentoostats-cli b/client/gentoostats-cli
index 6a237fc..a22ccc7 100755
--- a/client/gentoostats-cli
+++ b/client/gentoostats-cli
@@ -3,7 +3,7 @@
import argparse
from gentoostats import list
-#from gentoostats import search
+from gentoostats import search
def main():
parser = argparse.ArgumentParser()
@@ -13,7 +13,7 @@ def main():
subparsers = parser.add_subparsers()
list.add_parser(subparsers)
-# search.add_parser(subparsers)
+ search.add_parser(subparsers)
args = parser.parse_args()
args.func(args)
diff --git a/client/gentoostats/search.py b/client/gentoostats/search.py
new file mode 100644
index 0000000..165733e
--- /dev/null
+++ b/client/gentoostats/search.py
@@ -0,0 +1,37 @@
+
+import utils
+
+def pprint(title, object):
+ # TODO: write a custom pretty printer here
+ import pprint
+ print title
+ pprint.pprint(object)
+
+def add_parser(subparsers):
+ # TODO: add help and descriptions for all opts
+ search_parser = subparsers.add_parser('search')
+ search_parser.add_argument('-c', '--category')
+ search_parser.add_argument('-p', '--package')
+ search_parser.add_argument('-v', '--version')
+ search_parser.add_argument('-r', '--repo')
+ search_parser.add_argument('--min_hosts', type=int)
+ search_parser.add_argument('--max_hosts', type=int)
+ search_parser.set_defaults(func=search)
+
+def search(args):
+ url_base = '/search'
+ url_extra = ''
+
+ url_extra += ('?', '&')[bool(url_extra)] + 'cat=' + args.category if args.category else ''
+ url_extra += ('?', '&')[bool(url_extra)] + 'pkg=' + args.package if args.package else ''
+ url_extra += ('?', '&')[bool(url_extra)] + 'ver=' + args.version if args.version else ''
+ url_extra += ('?', '&')[bool(url_extra)] + 'repo=' + args.repo if args.repo else ''
+ url_extra += ('?', '&')[bool(url_extra)] + 'min_hosts=' + str(args.min_hosts) if args.min_hosts else ''
+ url_extra += ('?', '&')[bool(url_extra)] + 'max_hosts=' + str(args.max_hosts) if args.max_hosts else ''
+
+ print args.server + args.url + url_base + url_extra
+
+ get_data = utils.GET(server = args.server, url = args.url + url_base + url_extra, headers = utils.headers)
+ data = utils.deserialize(get_data)
+
+ pprint ('Search results', data)
next reply other threads:[~2011-08-01 23:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-01 23:04 Vikraman Choudhury [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-04-17 14:15 [gentoo-commits] proj/gentoostats:master commit in: client/gentoostats/, client/ Vikraman Choudhury
2011-08-21 23:15 Vikraman Choudhury
2011-08-01 22:24 Vikraman Choudhury
2011-08-01 22:24 Vikraman Choudhury
2011-07-25 12:35 Vikraman Choudhury
2011-06-23 15:14 Vikraman Choudhury
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=a1a9949f57f294cd001d8589fdc727de9c19aae8.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