From patchwork Thu Dec 13 11:16:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 153628 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp675021ljp; Thu, 13 Dec 2018 03:16:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKFdweR4W1mRwCAH4rCluCR0pbFjTVxsDQLJaaSTp9WVUcT+osYJQ2cIjHM502thc0sHKU X-Received: by 2002:a63:ef47:: with SMTP id c7mr21775653pgk.386.1544699772515; Thu, 13 Dec 2018 03:16:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544699772; cv=none; d=google.com; s=arc-20160816; b=ouJoI8iVpEwlOctCog6qft5zfC4C5OBRdyHTh7smzLE1UccdE2yGyP32pcWGQ0ZUlD HyV5MdnmdVSXF04n6PUgLbMvFJymOLKzsFL+aokLCz1ICf0cQ1P0R5K9deRJ+LZ0agtg fP86tzdb0Rm8ZwJIpsuPJNLDrvLFo13bI8tdlMiv0jtvTEu/5F/4P0rVq4658SgToQqG 9Lhx8H6/I7C81p3ecOuFN046vnnqVOrSEhgMW1Esuid+mMVGvrl0kdMTxONqoisJNJEa UK6saWhbN4wKVAxI6tLyWIzUBnzU569QqYrbrzg/Iwa56hemZjj+mbR3RKiMe4nhBGWe RJyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to; bh=BYipjOzLnKBDpDGqQPgUK7yj4XvcINxp9pS3FjwaL44=; b=vq4HR6WFof2fjKUXd8IPBEwKQAvpJrSkcYQtOo3xMf4Vg8bIJlYahPSCg0ubKHdhZq NCW5LHce19+y5gO3W/Jx30pE6u85Lx8KigLMW+GHEuFEYPJJJw8pLUhO1ignD64UOI0E dLnDaYE83HZTur2ufBM6qzsW1jEfN+e+qVcHyLc4C+Chc/c87dHcnXat+kWbz5B4cMBJ CQQUVAFZqC+o2VR9iOoRiFkvFfxNhq3+R43q7JQOLa4lK/zgW00m/f8/q+NPqH7c7thW fRRM/QYHRvcal+pj7O3lfliMmEmyJpTwRy0v+sp/8Z5ASiGZ0xwE9HIg69YZ4l7Thj07 TKLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=0EtSXAEJ; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id l184si1258024pgd.523.2018.12.13.03.16.11; Thu, 13 Dec 2018 03:16:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=0EtSXAEJ; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from 165.28.230.35.bc.googleusercontent.com (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id E24186C117; Thu, 13 Dec 2018 11:16:08 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mail.openembedded.org (Postfix) with ESMTP id 36EEE6C0EB for ; Thu, 13 Dec 2018 11:16:07 +0000 (UTC) Received: by mail-wr1-f45.google.com with SMTP id u4so602479wrp.3 for ; Thu, 13 Dec 2018 03:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=r8dqyueJAhiVoPqxbLtiGpvnt+PJW2iGnDLdQ83x0ec=; b=0EtSXAEJOl9V8npb9u+K3GW951oI2Cupx5bkJtTEAV2EVTVnCUgo6FEI0W9SFxABR7 PPiwHULfECceydMgLLZ21Kyzr5VNJe7jajvF+p3UDB3JtC9Tg6/g7xYJ4r5Wvz2sADI1 gBMiMqZ/06FGvvQ0Dy2ADlozFr7DEZ8ni5Kz5zdTJcHfYw3QABddQhV1nuKUduk/cKGu y1bbvPOuVK/SBsLrQ9VA32tNWBYKjDlSzhawnxtFOqhyLPI6+3q7Y25d9s7hNq6eAx/6 cy/dqzlXg0eMoR8yL83txM990l32VorRZSpVjAk4sjM3ROAbhg8O2Por124KmaMs/wb0 MHPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=r8dqyueJAhiVoPqxbLtiGpvnt+PJW2iGnDLdQ83x0ec=; b=lrjyn/mB8rRIV185z+wps3wXKB//D05YSkilMt7toOWloiqSRoRbU+1q+nfhVFz28L dj5twKjAcFkfcjcdasG8giCUB4QFkOnCBMJXdmhHggI90LsZvRnaAZLY3omNXV+i3v90 qg4SPDdErii2vkmgO/5uJEDtFDcIL0FB0xynzBsxBecHtfGWEHTuTxCDaONVtLE5Deye qtUAHyRPu46IrHXCBDiiCigb4o62pHdOV0E3/vjx4rac224JoAsWRJNb/nh50M8k3BQS +ffJdoJ3h+2KTpfGfd0AQx7v3UZwX9oDoYRcvuvc7QPWvIfuvbFpgGRWAebOl+M+EXAs gw+Q== X-Gm-Message-State: AA+aEWZWvOAq44iNlPmXJC3sfz8f+K+C1UG5o44Bwb0PjDSe7Qa6K3XZ nDQcz5d+vLSSj0tnKt8MXKzX4ideXWU= X-Received: by 2002:adf:c505:: with SMTP id q5mr20263224wrf.84.1544699767242; Thu, 13 Dec 2018 03:16:07 -0800 (PST) Received: from flashheart.burtonini.com (35.106.2.81.in-addr.arpa. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id v19sm2919416wrd.46.2018.12.13.03.16.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 03:16:06 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Thu, 13 Dec 2018 11:16:03 +0000 Message-Id: <20181213111604.6353-1-ross.burton@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [OE-core] [PATCH 1/2] runqemu: clean up subprocess usage X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Where possible pass lists instead of strings, don't use a subshell, and call check*() instead of using Popen directly. Signed-off-by: Ross Burton --- scripts/runqemu | 63 ++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 34 deletions(-) -- 2.11.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/scripts/runqemu b/scripts/runqemu index f661892aecf..c4a0ca811d9 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -116,9 +116,9 @@ def check_tun(): raise RunQemuError("TUN control device %s is not writable, please fix (e.g. sudo chmod 666 %s)" % (dev_tun, dev_tun)) def check_libgl(qemu_bin): - cmd = 'ldd %s' % qemu_bin - logger.debug('Running %s...' % cmd) - need_gl = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') + cmd = ('ldd', qemu_bin) + logger.debug('Running %s...' % str(cmd)) + need_gl = subprocess.check_output(cmd).decode('utf-8') if re.search('libGLU', need_gl): # We can't run without a libGL.so libgl = False @@ -400,7 +400,7 @@ class BaseConfig(object): cmd = 'MACHINE=%s bitbake -e' % arg logger.info('Running %s...' % cmd) - self.bitbake_e = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') + self.bitbake_e = subprocess.check_output(cmd, shell=True).decode('utf-8') # bitbake -e doesn't report invalid MACHINE as an error, so # let's check DEPLOY_DIR_IMAGE to make sure that it is a valid # MACHINE. @@ -843,10 +843,7 @@ class BaseConfig(object): self.nfs_server = '192.168.7.1' # Figure out a new nfs_instance to allow multiple qemus running. - # CentOS 7.1's ps doesn't print full command line without "ww" - # when invoke by subprocess.Popen(). - cmd = "ps auxww" - ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') + ps = subprocess.check_output(("ps", "auxww")).decode('utf-8') pattern = '/bin/unfsd .* -i .*\.pid -e .*/exports([0-9]+) ' all_instances = re.findall(pattern, ps, re.M) if all_instances: @@ -886,17 +883,17 @@ class BaseConfig(object): if not src: raise RunQemuError("No NFS_DIR is set, and can't find %s or %s to extract" % (src1, src2)) logger.info('NFS_DIR not found, extracting %s to %s' % (src, dest)) - cmd = 'runqemu-extract-sdk %s %s' % (src, dest) - logger.info('Running %s...' % cmd) - if subprocess.call(cmd, shell=True) != 0: + cmd = ('runqemu-extract-sdk', src, dest) + logger.info('Running %s...' % str(cmd)) + if subprocess.call(cmd) != 0: raise RunQemuError('Failed to run %s' % cmd) self.clean_nfs_dir = True self.rootfs = dest # Start the userspace NFS server - cmd = 'runqemu-export-rootfs start %s' % self.rootfs - logger.info('Running %s...' % cmd) - if subprocess.call(cmd, shell=True) != 0: + cmd = ('runqemu-export-rootfs', 'start', self.rootfs) + logger.info('Running %s...' % str(cmd)) + if subprocess.call(cmd) != 0: raise RunQemuError('Failed to run %s' % cmd) self.nfs_running = True @@ -962,9 +959,9 @@ class BaseConfig(object): except FileExistsError: pass - cmd = '%s link' % ip - logger.debug('Running %s...' % cmd) - ip_link = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') + cmd = (ip, 'link') + logger.debug('Running %s...' % str(cmd)) + ip_link = subprocess.check_output(cmd).decode('utf-8') # Matches line like: 6: tap0: possibles = re.findall('^[0-9]+: +(tap[0-9]+): <.*', ip_link, re.M) tap = "" @@ -989,8 +986,8 @@ class BaseConfig(object): gid = os.getgid() uid = os.getuid() logger.info("Setting up tap interface under sudo") - cmd = 'sudo %s %s %s %s' % (self.qemuifup, uid, gid, self.bindir_native) - tap = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8').rstrip('\n') + cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native) + tap = subprocess.check_output(cmd).decode('utf-8').strip() lockfile = os.path.join(lockdir, tap) self.lock = lockfile + '.lock' self.acquire_lock() @@ -1025,7 +1022,7 @@ class BaseConfig(object): if self.get('QB_NET') == 'none': return if sys.stdin.isatty(): - self.saved_stty = subprocess.check_output("stty -g", shell=True).decode('utf-8') + self.saved_stty = subprocess.check_output(("stty", "-g")).decode('utf-8').strip() self.network_device = self.get('QB_NETWORK_DEVICE') or self.network_device if self.slirp_enabled: self.setup_slirp() @@ -1139,7 +1136,7 @@ class BaseConfig(object): if not qemu_system: raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") - qemu_bin = '%s/%s' % (self.bindir_native, qemu_system) + qemu_bin = os.path.join(self.bindir_native, qemu_system) # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't # find QEMU in sysroot, it needs to use host's qemu. @@ -1177,7 +1174,7 @@ class BaseConfig(object): if self.serialconsole: if sys.stdin.isatty(): - subprocess.check_call("stty intr ^]", shell=True) + subprocess.check_call(("stty", "intr", "^]")) logger.info("Interrupt character is '^]'") first_serial = "" @@ -1241,20 +1238,19 @@ class BaseConfig(object): logger.info("Cleaning up") if self.cleantap: - cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native) - logger.debug('Running %s' % cmd) - subprocess.check_call(cmd, shell=True) + cmd = ('sudo', self.qemuifdown, self.tap, self.bindir_native) + logger.debug('Running %s' % str(cmd)) + subprocess.check_call(cmd) self.release_lock() if self.nfs_running: logger.info("Shutting down the userspace NFS server...") - cmd = "runqemu-export-rootfs stop %s" % self.rootfs - logger.debug('Running %s' % cmd) - subprocess.check_call(cmd, shell=True) + cmd = ("runqemu-export-rootfs", "stop", self.rootfs) + logger.debug('Running %s' % str(cmd)) + subprocess.check_call(cmd) if self.saved_stty: - cmd = "stty %s" % self.saved_stty - subprocess.check_call(cmd, shell=True) + subprocess.check_call(("stty", self.saved_stty)) if self.clean_nfs_dir: logger.info('Removing %s' % self.rootfs) @@ -1296,10 +1292,9 @@ class BaseConfig(object): if result and os.path.exists(result): return result - cmd = 'bitbake qemu-helper-native -e' - logger.info('Running %s...' % cmd) - out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) - out = out.stdout.read().decode('utf-8') + cmd = ('bitbake', 'qemu-helper-native', '-e') + logger.info('Running %s...' % str(cmd)) + out = subprocess.check_output(cmd).decode('utf-8') match = re.search('^STAGING_BINDIR_NATIVE="(.*)"', out, re.M) if match: From patchwork Thu Dec 13 11:16:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 153629 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp675248ljp; Thu, 13 Dec 2018 03:16:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VKHU/HBOwkJ9MGb1lexQcmP8Wsp2wnMc+YYovRKsgr/ItvFewqiUDpn74zv85V6E8ZXHB9 X-Received: by 2002:a62:a209:: with SMTP id m9mr24169106pff.218.1544699784625; Thu, 13 Dec 2018 03:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544699784; cv=none; d=google.com; s=arc-20160816; b=J4qTXJBz6se6nfvXTFKmuPX2Msx7gj/sE/J7YpM9PB0WU/SJVcvjXLU9Z5dWnKgl8o ZJ5jxFHRncWwgk5IsZTwfUTS4wG08wDU1QElW5o8ILBjb+p0E4JeXuvJLgTZHTknOcvw KbgEETm0uvtyWBpkI/SBp0GEEGN5vxBQGF8oqFTwT/K8YmDC68CGSQvk9FKpkwGtJHUH gzqvuaZMhI38tdbuiondty4+FmGqKBHEDmOPOI8lbGId9cARoPRL0huP93hyXwfx8An+ tImkdoHyqmOC8Rd2tLz74r4eteiOhteSXY9n0YiWKGxfFw324rY8x4wDgNHzttLoXN2A /c3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Vs3KVoUyFUtnyp7ayH9nedCSVwAC5VaNnCFqmw0iOfQ=; b=wwyDQv4n5FCd4GxyHDlrkUVP04QoruoxKjhA4jE4EW94NxZVoZ1yI5iuDSQVpAY1y6 HqshkMlv3mxAcQK8hrKd811Fr2gVSJg9z8k6MiSxo4N0sepFWLaolI13F2HziSTw6zyx LXzStoK1tu7Lc8e0HjW8z73frZ1GapTjnW9/JH9uPYIYI9UHCKsU8YIHpYhd8l6p3tRC 67+5jv8pmgoAwf+yhDMJlfMnOZ9XGqRjKMVjVlkW8xKNanfob3w2mOPCvSDaA47BeaBI qtZ02OZbtI2gVg04TssRPi84Yp8dZCrGWX9HzuKKddI2lTnjYabccAkFMTglaiFIuV3H YXxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="lWcg+/PA"; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id m20si1400123pgk.323.2018.12.13.03.16.24; Thu, 13 Dec 2018 03:16:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="lWcg+/PA"; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from 165.28.230.35.bc.googleusercontent.com (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 9B8946C108; Thu, 13 Dec 2018 11:16:21 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mail.openembedded.org (Postfix) with ESMTP id EBC416C0EB for ; Thu, 13 Dec 2018 11:16:07 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id y139so1898668wmc.5 for ; Thu, 13 Dec 2018 03:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=f2eQbXmFibP6C1IhqcTnVuX9YW5bvJX9XY4pD4sVtb8=; b=lWcg+/PASComFW2PjRDWcGkDiu0Q7QKvk3HNoDhU5zmWmUVmSTXNFYhLNczGxH8coD TblTn++AIhMIbLWPxtW5gWb4srsKKW+gkXMD5+lfKQngpW+ov9LaNKwcjG5WrDuMWz5d p30oPYBN8dlxSROmq4foiWOdIDI/9IA/aqU6AgfJtDN3SecHvrVVhrFLdgbyv9snTSnL 9zob80lLgy1A+35H3yDlXUOFclS887KEYVepsz3zOmI523RkUi2eqF415RtgVXc7lTVe NEFcvLVrPtl2Z1aqFj/W4fn+2iT+BNaoRdox1/n/nEBLIP2yQypMaOBpgz0IEoYR/FxV 0i1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=f2eQbXmFibP6C1IhqcTnVuX9YW5bvJX9XY4pD4sVtb8=; b=rLPrQJOAShg82hHWXgjghYHlCtVD0qgU7ZWiLyDl8icD1xkjYbQ6FZpbydVRirim7R 6BxGQ28rmut4uw+7FWKE2HTWKPp+CR/fRt03g+PgSEiUO5fg2Y/Pq0fHj84VScMfauck ly8CxoQjBcuNScF3La72aD3C1pm1OV8nT2sIubu3oCpLbVnDxfcHZEBi5si8k21sSyRI 3IEpnC3Yzom7VAfm//WbPF/2K0N9prfP89Gpc7/vXatGldQXeOFXEDK5CRR1gt1+BROs b6BVLrDys2qby7+99OKL1ZQs5RugM08NDCA/tdekpBDW0tzNJ6NMj8aK/zsLQwBGqZHd vwLA== X-Gm-Message-State: AA+aEWYH7py/K2Iv/UCltAGlVHhO9T/uJ9KycuuDXFhOanUth8JHX2aO m2FstD52MS2FtlSFboHZpNKNoFaPgkg= X-Received: by 2002:a1c:a104:: with SMTP id k4mr6596136wme.54.1544699768167; Thu, 13 Dec 2018 03:16:08 -0800 (PST) Received: from flashheart.burtonini.com (35.106.2.81.in-addr.arpa. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id v19sm2919416wrd.46.2018.12.13.03.16.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 03:16:07 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Thu, 13 Dec 2018 11:16:04 +0000 Message-Id: <20181213111604.6353-2-ross.burton@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181213111604.6353-1-ross.burton@intel.com> References: <20181213111604.6353-1-ross.burton@intel.com> Subject: [OE-core] [PATCH 2/2] runqemu: formatting cleanups suggested by PyLint X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Mostly whitespace fixes but also some r"" strings to clarify regular expressions. Signed-off-by: Ross Burton --- scripts/runqemu | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.11.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/scripts/runqemu b/scripts/runqemu index c4a0ca811d9..9beb7b00fc0 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -127,7 +127,7 @@ def check_libgl(qemu_bin): ('/usr/lib/*-linux-gnu/libGL.so', '/usr/lib/*-linux-gnu/libGLU.so')) for (f1, f2) in check_files: - if re.search('\*', f1): + if re.search(r'\*', f1): for g1 in glob.glob(f1): if libgl: break @@ -179,12 +179,12 @@ class BaseConfig(object): # Supported env vars, add it here if a var can be got from env, # and don't use os.getenv in the code. self.env_vars = ('MACHINE', - 'ROOTFS', - 'KERNEL', - 'DEVICE_TREE', - 'DEPLOY_DIR_IMAGE', - 'OE_TMPDIR', - 'OECORE_NATIVE_SYSROOT', + 'ROOTFS', + 'KERNEL', + 'DEVICE_TREE', + 'DEPLOY_DIR_IMAGE', + 'OE_TMPDIR', + 'OECORE_NATIVE_SYSROOT', ) self.qemu_opt = '' @@ -329,10 +329,10 @@ class BaseConfig(object): if p.endswith('.qemuboot.conf'): self.qemuboot = p self.qbconfload = True - elif re.search('\.bin$', p) or re.search('bzImage', p) or \ + elif re.search(r'\.bin$', p) or re.search('bzImage', p) or \ re.search('zImage', p) or re.search('vmlinux', p) or \ re.search('fitImage', p) or re.search('uImage', p): - self.kernel = p + self.kernel = p elif os.path.exists(p) and (not os.path.isdir(p)) and '-image-' in os.path.basename(p): self.rootfs = p # Check filename against self.fstypes can hanlde .cpio.gz, @@ -343,13 +343,13 @@ class BaseConfig(object): fst = t break if not fst: - m = re.search('.*\.(.*)$', self.rootfs) + m = re.search(r'.*\.(.*)$', self.rootfs) if m: - fst = m.group(1) + fst = m.group(1) if fst: self.check_arg_fstype(fst) - qb = re.sub('\.' + fst + "$", '', self.rootfs) - qb = '%s%s' % (re.sub('\.rootfs$', '', qb), '.qemuboot.conf') + qb = re.sub(r'\.' + fst + "$", '', self.rootfs) + qb = '%s%s' % (re.sub(r'\.rootfs$', '', qb), '.qemuboot.conf') if os.path.exists(qb): self.qemuboot = qb self.qbconfload = True @@ -538,9 +538,9 @@ class BaseConfig(object): raise RunQemuError(yocto_paravirt_kvm_wiki) if not os.access(dev_kvm, os.W_OK|os.R_OK): - logger.error("You have no read or write permission on /dev/vhost-net.") - logger.error("Please change the ownership of this file as described at:") - raise RunQemuError(yocto_kvm_wiki) + logger.error("You have no read or write permission on /dev/vhost-net.") + logger.error("Please change the ownership of this file as described at:") + raise RunQemuError(yocto_kvm_wiki) def check_fstype(self): """Check and setup FSTYPE""" @@ -569,8 +569,8 @@ class BaseConfig(object): if self.rootfs and not os.path.exists(self.rootfs): # Lazy rootfs self.rootfs = "%s/%s-%s.%s" % (self.get('DEPLOY_DIR_IMAGE'), - self.rootfs, self.get('MACHINE'), - self.fstype) + self.rootfs, self.get('MACHINE'), + self.fstype) elif not self.rootfs: cmd_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype) cmd_link = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_LINK_NAME'), self.fstype) @@ -826,7 +826,7 @@ class BaseConfig(object): print('DTB: [%s]' % self.dtb) print('MACHINE: [%s]' % self.get('MACHINE')) print('FSTYPE: [%s]' % self.fstype) - if self.fstype == 'nfs': + if self.fstype == 'nfs': print('NFS_DIR: [%s]' % self.rootfs) else: print('ROOTFS: [%s]' % self.rootfs) @@ -844,7 +844,7 @@ class BaseConfig(object): # Figure out a new nfs_instance to allow multiple qemus running. ps = subprocess.check_output(("ps", "auxww")).decode('utf-8') - pattern = '/bin/unfsd .* -i .*\.pid -e .*/exports([0-9]+) ' + pattern = r'/bin/unfsd .* -i .*\.pid -e .*/exports([0-9]+) ' all_instances = re.findall(pattern, ps, re.M) if all_instances: all_instances.sort(key=int) @@ -863,7 +863,7 @@ class BaseConfig(object): # Use '%s' since they are integers os.putenv(k, '%s' % v) - self.unfs_opts="nfsvers=3,port=%s,udp,mountport=%s" % (nfsd_port, mountd_port) + self.unfs_opts = "nfsvers=3,port=%s,udp,mountport=%s" % (nfsd_port, mountd_port) # Extract .tar.bz2 or .tar.bz if no nfs dir if not (self.rootfs and os.path.isdir(self.rootfs)): @@ -1160,8 +1160,8 @@ class BaseConfig(object): self.qemu_opt = "%s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) for ovmf in self.ovmf_bios: - format = ovmf.rsplit('.', 1)[-1] - self.qemu_opt += ' -drive if=pflash,format=%s,file=%s' % (format, ovmf) + fmt = ovmf.rsplit('.', 1)[-1] + self.qemu_opt += ' -drive if=pflash,format=%s,file=%s' % (fmt, ovmf) if self.ovmf_bios: # OVMF only supports normal VGA, i.e. we need to override a -vga vmware # that gets added for example for normal qemux86.