summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraldot <rep.dot.nop@gmail.com>2015-03-02 16:18:34 +0100
committerJeremy Kerr <jk@ozlabs.org>2015-05-03 13:40:02 +0800
commitf0ad2c6a249c0ee3a4b356e10033ea0041ecbea4 (patch)
tree3a8355ebc6c871ab22ee8b41c8bf7db1fd9fddb4
parent86f645abb13ff65ef04b085b443168d5b5622e4d (diff)
downloadpatchwork-f0ad2c6a249c0ee3a4b356e10033ea0041ecbea4.tar.bz2
patchwork-f0ad2c6a249c0ee3a4b356e10033ea0041ecbea4.tar.xz
pwclient: honor PAGER for view
Use the PAGER of the environment to view patches Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rwxr-xr-xapps/patchwork/bin/pwclient23
1 files changed, 19 insertions, 4 deletions
diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 0a477c2..8d1f476 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -684,10 +684,25 @@ def main():
action_states(rpc)
elif action == 'view':
- for patch_id in non_empty(h, patch_ids):
- s = rpc.patch_get_mbox(patch_id)
- if len(s) > 0:
- print unicode(s).encode("utf-8")
+ pager = os.environ.get('PAGER')
+ if pager:
+ pager = subprocess.Popen(
+ pager.split(), stdin=subprocess.PIPE
+ )
+ if pager:
+ i = list()
+ for patch_id in non_empty(h, patch_ids):
+ s = rpc.patch_get_mbox(patch_id)
+ if len(s) > 0:
+ i.append(unicode(s).encode("utf-8"))
+ if len(i) > 0:
+ pager.communicate(input="\n".join(i))
+ pager.stdin.close()
+ else:
+ for patch_id in non_empty(h, patch_ids):
+ s = rpc.patch_get_mbox(patch_id)
+ if len(s) > 0:
+ print unicode(s).encode("utf-8")
elif action == 'info':
for patch_id in non_empty(h, patch_ids):