[meld] Move cmdout from misc module to vc.svk, which is its only use
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Move cmdout from misc module to vc.svk, which is its only use
- Date: Mon, 3 Jun 2013 20:03:07 +0000 (UTC)
commit 624fcf19fb7f3b1b43c06e54571c43f07189ac21
Author: Kai Willadsen <kai willadsen gmail com>
Date: Thu Jun 28 07:25:23 2012 +1000
Move cmdout from misc module to vc.svk, which is its only use
meld/misc.py | 16 ----------------
meld/vc/svk.py | 28 ++++++++++++++++++++++++----
meld/vcview.py | 3 ++-
3 files changed, 26 insertions(+), 21 deletions(-)
---
diff --git a/meld/misc.py b/meld/misc.py
index 3049fd1..e01cd80 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -34,7 +34,6 @@ import gtk
whitespace_re = re.compile(r"\s")
-NULL = open(os.devnull, "w+b")
if os.name != "nt":
from select import select
@@ -46,21 +45,6 @@ else:
return rlist, wlist, xlist
-def cmdout(cmd, text=None, **kwargs):
- stdin = NULL
- if text is not None:
- stdin = subprocess.PIPE
- new_kwargs = {
- 'stdin': stdin,
- 'stdout': subprocess.PIPE,
- 'stderr': NULL,
- }
- new_kwargs.update(kwargs)
- p = subprocess.Popen(cmd, **new_kwargs)
- out = p.communicate(text)[0]
- status = p.wait()
- return out, status
-
def shelljoin( command ):
def quote(s):
return ((whitespace_re.search(s) is None) and s or ('"%s"' % s))
diff --git a/meld/vc/svk.py b/meld/vc/svk.py
index 4bb304f..76c377c 100644
--- a/meld/vc/svk.py
+++ b/meld/vc/svk.py
@@ -21,9 +21,29 @@
### (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from meld import misc
+import os
+import subprocess
+
from . import svn
+NULL = open(os.devnull, "w+b")
+
+
+def cmdout(cmd, text=None, **kwargs):
+ stdin = NULL
+ if text is not None:
+ stdin = subprocess.PIPE
+ new_kwargs = {
+ 'stdin': stdin,
+ 'stdout': subprocess.PIPE,
+ 'stderr': NULL,
+ }
+ new_kwargs.update(kwargs)
+ p = subprocess.Popen(cmd, **new_kwargs)
+ out = p.communicate(text)[0]
+ status = p.wait()
+ return out, status
+
class Vc(svn.Vc):
@@ -35,11 +55,11 @@ class Vc(svn.Vc):
try:
# `svk info` may be interactive. It can ask to create its repository, we
# don't want that to happen, so provide the right answer with `text="n"`
- status = misc.cmdout([self.CMD, "info"], cwd=location, stdout=misc.NULL,
- stderr=misc.NULL, text='n')[1]
+ status = cmdout([self.CMD, "info"], cwd=location, stdout=NULL,
+ stderr=NULL, text='n')[1]
# SVK does evil things to the real stdin, even when having its input
# stream redirected to a newly created pipe, restore sanity manually
- misc.cmdout(['stty', 'sane'], stdout=misc.NULL, stderr=misc.NULL, stdin=None)
+ cmdout(['stty', 'sane'], stdout=NULL, stderr=NULL, stdin=None)
except OSError:
raise ValueError()
if status != 0:
diff --git a/meld/vcview.py b/meld/vcview.py
index 91441a1..dc7d3bd 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -862,7 +862,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
patchcmd = self.vc.patch_command(tmpdir)
try:
- result = misc.write_pipe(patchcmd, patch, error=misc.NULL)
+ with open(os.devnull, "w") as NULL:
+ result = misc.write_pipe(patchcmd, patch, error=NULL)
except OSError:
result = 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]