Mailinglist Archive: opensuse-buildservice (344 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] add run_pager() and make osc log/diff work like git log/diff
  • From: Danny Kukawka <dkukawka@xxxxxxx>
  • Date: Mon, 3 May 2010 16:11:50 +0200
  • Message-id: <201005031611.51058.dkukawka@xxxxxxx>
From 7fb0bf7e8a1b3a87eb394c646425c70aa7d84c2b Mon Sep 17 00:00:00 2001
From: Danny Kukawka <danny.kukawka@xxxxxx>
Date: Mon, 3 May 2010 10:05:36 +0200
Subject: [PATCH] add run_pager() and make osc log/diff work like git log/diff

Added new function run_pager() to get 'osc log/diff' work like
'git log/diff' which send the output to PAGER (which is by default:
less or what's defined in the environment).

Signed-off-by: Danny Kukawka <danny.kukawka@xxxxxx>
---
osc/commandline.py | 5 +++--
osc/core.py | 17 +++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/osc/commandline.py b/osc/commandline.py
index a8e5d2c..f0325a0 100644
--- a/osc/commandline.py
+++ b/osc/commandline.py
@@ -1894,7 +1894,7 @@ Please submit there instead, or use --nodevelproject to
force direct submission.
diff += server_diff(pac.apiurl, pac.prjname, pac.name, rev1,
pac.prjname, pac.name, rev2, not
opts.plain, opts.missingok)
if len(diff) > 0:
- print diff
+ run_pager(diff)


@cmdln.option('--oldprj', metavar='OLDPRJ',
@@ -3685,7 +3685,8 @@ Please submit there instead, or use --nodevelproject to
force direct submission.
if opts.xml:
format = 'xml'

- print '\n'.join(get_commitlog(apiurl, project, package, rev, format))
+ log = '\n'.join(get_commitlog(apiurl, project, package, rev, format))
+ run_pager(log)

@cmdln.option('-f', '--failed', action='store_true',
help='rebuild all failed packages')
diff --git a/osc/core.py b/osc/core.py
index edac283..0f2c3bb 100644
--- a/osc/core.py
+++ b/osc/core.py
@@ -2480,6 +2480,23 @@ def read_meta_from_spec(specfile, *args):

return spec_data

+def run_pager(message):
+ import tempfile
+
+ tmpfile = None
+
+ if tmpfile is None:
+ tmpfile = tempfile.NamedTemporaryFile()
+
+ tmpfile.write(message)
+ tmpfile.flush()
+ pager = os.getenv('PAGER', default='less')
+ subprocess.call('%s %s' % (pager, tmpfile.name), shell=True)
+
+ if tmpfile is not None:
+ tmpfile.close()
+
+
def run_editor(filename):
if sys.platform[:3] != 'win':
editor = os.getenv('EDITOR', default='vim')
--
1.5.6

--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups