From: cpebenito@tresys.com (Christopher J. PeBenito) Date: Thu, 27 Mar 2014 12:44:17 -0400 Subject: [refpolicy] [PATCH] Make scripts compatible with Python 3 In-Reply-To: References: <1395608745-10514-1-git-send-email-nicolas.iooss@m4x.org> Message-ID: <53345561.207@tresys.com> To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com On 03/27/2014 09:40 AM, Nicolas Iooss wrote: > 2014-03-23 22:05 GMT+01:00 Nicolas Iooss : >> Here are all the changes which are needed to make the scripts compatible with >> Python 3 while keeping compatibility with Python 2.6 and 2.7: >> >> * use subprocess module instead of commands, > > I've learnt today that Python 2 doesn't have > subprocess.getstatusoutput function even though the commands module is > deprecated [1] and Python 3 provides it without documenting "New in > python 3" [2] :( I haven't tested building the monolithic policy with > Python 2 after my patch so it didn't occurred to me that this specific > config is broken. I think it's best to cancel at least the > support/genhomedircon part of this patch for now. > > Looking at that, is there any reason why support/genhomedircon uses > lines like this instead of opening the file with open() and parsing > the file with Python code? > > rc=commands.getstatusoutput("grep \"^/\" %s | cut -f 1 | cut -f 1 > -d \" \" " % (sys.argv[2]) ) > > I believe that every "commands.getstatusoutput" call can be replaced > by pure Python code. I'll send a patch soon (maybe a few days) which > does exactly this, if it's possible and if nobody tells me I'm wrong > in doing that. I wouldn't worry about that script. We kept it around to work on RHEL4 systems. That OS has been end of life for a while, so I'll probably remove the RHEL4 refpolicy stuff very soon. -- Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com