1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Thu, 19 Jul 2012 16:55:12 +0100
Subject: [PATCH] opkg.py: Add check_output defintion so it works on python 2.6
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
opkg.py | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/opkg.py b/opkg.py
index 84a8eb1..45a6119 100644
--- a/opkg.py
+++ b/opkg.py
@@ -326,10 +326,30 @@ class Package:
return self.license
def get_file_list_dir(self, directory):
+ def check_output(*popenargs, **kwargs):
+ """Run command with arguments and return its output as a byte string.
+
+ Backported from Python 2.7 as it's implemented as pure python on stdlib.
+
+ >>> check_output(['/usr/bin/python', '--version'])
+ Python 2.6.2
+ """
+ process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
+ output, unused_err = process.communicate()
+ retcode = process.poll()
+ if retcode:
+ cmd = kwargs.get("args")
+ if cmd is None:
+ cmd = popenargs[0]
+ error = subprocess.CalledProcessError(retcode, cmd)
+ error.output = output
+ raise error
+ return output
+
if not self.fn:
try:
cmd = "find %s -name %s | head -n 1" % (directory, self.filename)
- rc = subprocess.check_output(cmd, shell=True)
+ rc = check_output(cmd, shell=True)
if rc != "":
newfn = str(rc).split()[0]
# sys.stderr.write("Package '%s' with empty fn and filename is '%s' was found in '%s', updating fn\n" % (self.package, self.filename, newfn))
|