From mboxrd@z Thu Jan 1 00:00:00 1970 From: nicolas.iooss@m4x.org (Nicolas Iooss) Date: Thu, 27 Mar 2014 14:40:22 +0100 Subject: [refpolicy] [PATCH] Make scripts compatible with Python 3 In-Reply-To: <1395608745-10514-1-git-send-email-nicolas.iooss@m4x.org> References: <1395608745-10514-1-git-send-email-nicolas.iooss@m4x.org> Message-ID: To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com 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. Regards, Nicolas [1] http://docs.python.org/2/library/commands.html [2] http://docs.python.org/3.0/library/subprocess.html#subprocess.getstatusoutput