summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2012-05-24 17:08:53 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-05-25 11:17:54 +0100
commitc071fd9b85fcd679ac214b589eaa1b4573371582 (patch)
tree8fe16450b22b503f3a578a258a613cc84ae635c4 /meta
parent70caf1e1bcb329404da2a858f777332a7c99c9b9 (diff)
downloadpoky-c071fd9b85fcd679ac214b589eaa1b4573371582.tar.gz
oe/process.py: remove it since it is unused and duplicated
The meta/lib/oe/process.py is only used by oe_run and oe_popen in meta/classes/utils.bbclass, and they will be removed, we have a better one: bitbake/lib/bb/process.py, which can replace of it. [YOCTO #2489] (From OE-Core rev: d56062cbf92ef206bf06c767befacb66927a9a36) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oe/process.py74
1 files changed, 0 insertions, 74 deletions
diff --git a/meta/lib/oe/process.py b/meta/lib/oe/process.py
deleted file mode 100644
index 26c3e65910..0000000000
--- a/meta/lib/oe/process.py
+++ /dev/null
@@ -1,74 +0,0 @@
1import subprocess
2import signal
3
4def subprocess_setup():
5 # Python installs a SIGPIPE handler by default. This is usually not what
6 # non-Python subprocesses expect.
7 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
8
9class CmdError(RuntimeError):
10 def __init__(self, command):
11 self.command = command
12
13 def __str__(self):
14 if not isinstance(self.command, basestring):
15 cmd = subprocess.list2cmdline(self.command)
16 else:
17 cmd = self.command
18
19 return "Execution of '%s' failed" % cmd
20
21class NotFoundError(CmdError):
22 def __str__(self):
23 return CmdError.__str__(self) + ": command not found"
24
25class ExecutionError(CmdError):
26 def __init__(self, command, exitcode, stdout = None, stderr = None):
27 CmdError.__init__(self, command)
28 self.exitcode = exitcode
29 self.stdout = stdout
30 self.stderr = stderr
31
32 def __str__(self):
33 message = ""
34 if self.stderr:
35 message += self.stderr
36 if self.stdout:
37 message += self.stdout
38 if message:
39 message = ":\n" + message
40 return (CmdError.__str__(self) +
41 " with exit code %s" % self.exitcode + message)
42
43class Popen(subprocess.Popen):
44 defaults = {
45 "close_fds": True,
46 "preexec_fn": subprocess_setup,
47 "stdout": subprocess.PIPE,
48 "stderr": subprocess.STDOUT,
49 "stdin": subprocess.PIPE,
50 "shell": False,
51 }
52
53 def __init__(self, *args, **kwargs):
54 options = dict(self.defaults)
55 options.update(kwargs)
56 subprocess.Popen.__init__(self, *args, **options)
57
58def run(cmd, input=None, **options):
59 """Convenience function to run a command and return its output, raising an
60 exception when the command fails"""
61
62 if isinstance(cmd, basestring) and not "shell" in options:
63 options["shell"] = True
64 try:
65 pipe = Popen(cmd, **options)
66 except OSError, exc:
67 if exc.errno == 2:
68 raise NotFoundError(cmd)
69 else:
70 raise
71 stdout, stderr = pipe.communicate(input)
72 if pipe.returncode != 0:
73 raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
74 return stdout