All of lore.kernel.org
 help / color / mirror / Atom feed
From: nicolas.iooss@m4x.org (Nicolas Iooss)
To: refpolicy@oss.tresys.com
Subject: [refpolicy] [PATCH] Make scripts compatible with Python 3
Date: Thu, 27 Mar 2014 14:40:22 +0100	[thread overview]
Message-ID: <CAJfZ7=mzDMC2xYHU53Fd=9q9RnPzfCB=Laohg8hbuu-L_=r2aA@mail.gmail.com> (raw)
In-Reply-To: <1395608745-10514-1-git-send-email-nicolas.iooss@m4x.org>

2014-03-23 22:05 GMT+01:00 Nicolas Iooss <nicolas.iooss@m4x.org>:
> 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

  reply	other threads:[~2014-03-27 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-23 21:05 [refpolicy] [PATCH] Make scripts compatible with Python 3 Nicolas Iooss
2014-03-27 13:40 ` Nicolas Iooss [this message]
2014-03-27 16:44   ` Christopher J. PeBenito

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJfZ7=mzDMC2xYHU53Fd=9q9RnPzfCB=Laohg8hbuu-L_=r2aA@mail.gmail.com' \
    --to=nicolas.iooss@m4x.org \
    --cc=refpolicy@oss.tresys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.