From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iL15d-0007R6-Pe for ptxdist@pengutronix.de; Thu, 17 Oct 2019 10:24:57 +0200 Received: from rhi by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iL15d-000223-H1 for ptxdist@pengutronix.de; Thu, 17 Oct 2019 10:24:57 +0200 Date: Thu, 17 Oct 2019 10:24:57 +0200 From: Roland Hieber Message-ID: <20191017082457.bgrmfiadfsvql4as@pengutronix.de> References: <20190911075048.8125-1-rhi@pengutronix.de> <20190925131339.17018-1-rhi@pengutronix.de> <20191016105310.w3fmq26kuahbyrob@pengutronix.de> <20191016113856.aad2nol5dsfy6pq6@pengutronix.de> <20191016115807.vwdada7sosnryivw@pengutronix.de> <20191016132615.yjhjtnpae5gown6f@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191016132615.yjhjtnpae5gown6f@pengutronix.de> Subject: Re: [ptxdist] [PATCH v2] configure_helper.py: check for emptyish ptxdist environment variables List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de On Wed, Oct 16, 2019 at 03:26:15PM +0200, Michael Olbrich wrote: > On Wed, Oct 16, 2019 at 01:58:07PM +0200, Roland Hieber wrote: > > On Wed, Oct 16, 2019 at 01:38:56PM +0200, Michael Olbrich wrote: > > > On Wed, Oct 16, 2019 at 12:53:10PM +0200, Roland Hieber wrote: > > > > Michael, any comments? It does not seem to be applied yet. > > > > > > Right, this got lost. I'm not sure I like this. Why would there be an empty > > > PTXDIST env variable? > > > > I don't know, but somehow it happened to me, and the script can be more robust in that case. Also when that happens it is not very > > easy to find out what is the fault just from the Python stacktrace: > > > > Traceback (most recent call last): > > File "./scripts/configure_helper.py", line 497, in > > (tool, d, pkg_subdir, pkg_conf_opt, sysroot_host) = ask_ptxdist(ptx_PKG) > > File "./scripts/configure_helper.py", line 165, in ask_ptxdist > > universal_newlines=True) > > File "/usr/lib/python3.7/subprocess.py", line 775, in __init__ > > restore_signals, start_new_session) > > File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child > > raise child_exception_type(errno_num, err_msg, err_filename) > > PermissionError: [Errno 13] Permission denied: '' > > I think, catching the exception and printing an error with the failing > commandline would be better. Other bogus, non-empty strings will cause > exceptions as well. Yeah, after having a night of sleep over this, I think this is also the better approach. - Roland > > Michael > > > > > > > > On Wed, Sep 25, 2019 at 03:13:40PM +0200, Roland Hieber wrote: > > > > > When the environment variable exists, but is empty, os.environment.get() > > > > > will return its value instead of using the supplied default. Check for > > > > > cases like that to prevent calling an empty command. > > > > > > > > > > Signed-off-by: Roland Hieber > > > > > --- > > > > > v1 -> v2: > > > > > - prevent "AttributeError: 'NoneType' object has no attribute 'strip'" > > > > > if none of the checked environment variables are set > > > > > > > > > > scripts/configure_helper.py | 7 ++++++- > > > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/scripts/configure_helper.py b/scripts/configure_helper.py > > > > > index c7b46f3b3846..73dd4a2add1c 100755 > > > > > --- a/scripts/configure_helper.py > > > > > +++ b/scripts/configure_helper.py > > > > > @@ -151,7 +151,12 @@ def abort(message): > > > > > exit(1) > > > > > > > > > > def ask_ptxdist(pkg): > > > > > - ptxdist = os.environ.get("PTXDIST", os.environ.get("ptxdist", "ptxdist")) > > > > > + ptxdist = os.environ.get("PTXDIST") > > > > > + if not ptxdist or not ptxdist.strip(): > > > > > + ptxdist = os.environ.get("ptxdist") > > > > > + if not ptxdist or not ptxdist.strip(): > > > > > + ptxdist = "ptxdist" > > > > > + > > > > > p = subprocess.Popen([ ptxdist, "-k", "make", > > > > > "/print-%s_DIR" % pkg, > > > > > "/print-%s_SUBDIR" % pkg, > > > > > -- > > > > > 2.23.0 -- Roland Hieber | r.hieber@pengutronix.de | Pengutronix e.K. | https://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de