aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/update.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-03-23 01:27:16 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit59b66d55057c9eb5ad8420ffeac0a83139e7c591 (patch)
tree848629c7613c2e9e62a2e79859bb8a96e689dc13 /layerindex/update.py
parent50aab7c03ac52fe8ddc7e8f802e4133249b3ea6e (diff)
downloadopenembedded-core-contrib-59b66d55057c9eb5ad8420ffeac0a83139e7c591.tar.gz
openembedded-core-contrib-59b66d55057c9eb5ad8420ffeac0a83139e7c591.tar.bz2
openembedded-core-contrib-59b66d55057c9eb5ad8420ffeac0a83139e7c591.zip
Move run_command_interruptible() to utils
Make this function more easily reusable from the RRS code. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/update.py')
-rwxr-xr-xlayerindex/update.py35
1 files changed, 2 insertions, 33 deletions
diff --git a/layerindex/update.py b/layerindex/update.py
index 39f5ae9300..06c61a7900 100755
--- a/layerindex/update.py
+++ b/layerindex/update.py
@@ -14,7 +14,6 @@ import optparse
import codecs
import logging
import subprocess
-import signal
from datetime import datetime, timedelta
from distutils.version import LooseVersion
import utils
@@ -35,36 +34,6 @@ except ImportError:
sys.exit(1)
-def reenable_sigint():
- signal.signal(signal.SIGINT, signal.SIG_DFL)
-
-def run_command_interruptible(cmd):
- """
- Run a command with output displayed on the console, but ensure any Ctrl+C is
- processed only by the child process.
- """
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- try:
- process = subprocess.Popen(
- cmd, cwd=os.path.dirname(sys.argv[0]), shell=True, preexec_fn=reenable_sigint, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
- )
-
- reader = codecs.getreader('utf-8')(process.stdout, errors='surrogateescape')
- buf = ''
- while True:
- out = reader.read(1, 1)
- if out:
- sys.stdout.write(out)
- sys.stdout.flush()
- buf += out
- elif out == '' and process.poll() != None:
- break
-
- finally:
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- return process.returncode, buf
-
-
def prepare_update_layer_command(options, branch, layer, initial=False):
"""Prepare the update_layer.py command line"""
if branch.update_environment:
@@ -417,7 +386,7 @@ def main():
cmd = prepare_update_layer_command(options, branchobj, layer, initial=True)
logger.debug('Running layer update command: %s' % cmd)
- ret, output = run_command_interruptible(cmd)
+ ret, output = utils.run_command_interruptible(cmd)
logger.debug('output: %s' % output)
if ret == 254:
# Interrupted by user, break out of loop
@@ -491,7 +460,7 @@ def main():
cmd = prepare_update_layer_command(options, branchobj, layer)
logger.debug('Running layer update command: %s' % cmd)
layerupdate.started = datetime.now()
- ret, output = run_command_interruptible(cmd)
+ ret, output = utils.run_command_interruptible(cmd)
layerupdate.finished = datetime.now()
# We need to get layerbranch here because it might not have existed until