[PATCH 2/3] pwclient: add get-bundle command
Aristeu Sergio Rozanski Filho
aris at ruivo.org
Fri Mar 20 03:57:04 EST 2009
This patch adds get-bundle command that will get more information about a
given bundle.
Signed-off-by: Aristeu Rozanski <aris at redhat.com>
---
apps/patchwork/bin/pwclient | 18 ++++++++++++++++++
apps/patchwork/views/xmlrpc.py | 18 ++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 25488cf..7fc2d94 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -111,6 +111,7 @@ def usage():
by name
search [str] : Same as 'list'
list-bundles : List available bundles. Can be filtered by -p <project>
+ get-bundle <ID> : Get information about a single bundle
view <ID> : View a patch
update [-s state] [-c commit-ref] <ID>
: Update patch\n""")
@@ -292,6 +293,15 @@ def action_list_bundles(rpc, project_str):
for bundle in bundles:
print("%i\t%s" % (bundle['id'], bundle['name']))
+def action_get_bundle(rpc, bundle_id):
+ if bundle_id.isdigit():
+ bundle = rpc.bundle_get(bundle_id)
+ else:
+ bundle = rpc.bundle_get_byname(bundle_id)
+
+ if len(bundle) > 0:
+ print("%i\t%s\t%i\t%s" % (bundle['id'], bundle['name'], bundle['n_patches'], bundle['public_url']))
+
def patch_id_from_hash(rpc, hash):
patch = rpc.patch_get_by_hash(hash)
if patch == {}:
@@ -448,6 +458,14 @@ def main():
elif action == 'list-bundles':
action_list_bundles(rpc, project_str)
+ elif action == 'get-bundle':
+ try:
+ bundle_id = args[0]
+ except:
+ sys.stderr.write("No bundle ID given\n")
+ sys.exit(1)
+ action_get_bundle(rpc, bundle_id)
+
else:
sys.stderr.write("Unknown action '%s'\n" % action)
usage()
diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py
index 4c6e0d6..d36a120 100644
--- a/apps/patchwork/views/xmlrpc.py
+++ b/apps/patchwork/views/xmlrpc.py
@@ -443,3 +443,21 @@ def bundle_list(project_id="", max_count=0):
except:
return []
+ at xmlrpc_method(False)
+def bundle_get(bundle_id):
+ """Gets a bundle by id"""
+ try:
+ bundle = Bundle.objects.filter(id = bundle_id)[0]
+ return bundle_to_dict(bundle)
+ except:
+ return {}
+
+ at xmlrpc_method(False)
+def bundle_get_byname(bundle_name):
+ """Gets a bundle by id"""
+ try:
+ bundle = Bundle.objects.get(name = bundle_name)
+ return bundle_to_dict(bundle)
+ except:
+ return {}
+
--
1.6.2
More information about the Patchwork
mailing list