[PATCH 1/3] pwclient: add list-bundles command
Aristeu Sergio Rozanski Filho
aris at ruivo.org
Fri Mar 20 03:56:54 EST 2009
This patch adds list-bundles to pwclient and bundle_list() to xmlrpc interface.
Signed-off-by: Aristeu Rozanski <aris at redhat.com>
---
apps/patchwork/bin/pwclient | 10 ++++++++++
apps/patchwork/views/xmlrpc.py | 19 ++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index e25212a..25488cf 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -110,6 +110,7 @@ def usage():
below and an optional substring to search for patches
by name
search [str] : Same as 'list'
+ list-bundles : List available bundles. Can be filtered by -p <project>
view <ID> : View a patch
update [-s state] [-c commit-ref] <ID>
: Update patch\n""")
@@ -285,6 +286,12 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
if not success:
sys.stderr.write("Patch not updated\n")
+def action_list_bundles(rpc, project_str):
+ bundles = rpc.bundle_list(project_str)
+
+ for bundle in bundles:
+ print("%i\t%s" % (bundle['id'], bundle['name']))
+
def patch_id_from_hash(rpc, hash):
patch = rpc.patch_get_by_hash(hash)
if patch == {}:
@@ -438,6 +445,9 @@ def main():
action_update_patch(rpc, patch_id, state = state_str,
commit = commit_str)
+ elif action == 'list-bundles':
+ action_list_bundles(rpc, project_str)
+
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 89c6bd6..4c6e0d6 100644
--- a/apps/patchwork/views/xmlrpc.py
+++ b/apps/patchwork/views/xmlrpc.py
@@ -205,7 +205,7 @@ def bundle_to_dict(obj):
'id' : obj.id,
'name' : obj.name,
'n_patches' : obj.n_patches(),
- 'public_url' : obj.public_url(),
+ 'public_url' : max(obj.public_url(), ''),
}
def state_to_dict(obj):
@@ -426,3 +426,20 @@ def state_get(state_id):
return state_to_dict(state)
except:
return {}
+
+ at xmlrpc_method(False)
+def bundle_list(project_id="", max_count=0):
+ """Lists the available bundles"""
+ try:
+ if len(project_id) > 0:
+ bundles = Bundle.objects.filter(project_id = project_id)
+ else:
+ bundles = Bundle.objects.all()
+
+ if max_count > 0:
+ return map(bundle_to_dict, bundles)[:max_count]
+ else:
+ return map(bundle_to_dict, bundles)
+ except:
+ return []
+
--
1.6.2
More information about the Patchwork
mailing list