[lxc-devel] [PATCH] python: Update scripts to respect PEP-8 spec

Stéphane Graber stgraber at ubuntu.com
Tue Jul 9 14:07:11 UTC 2013


On Tue, Jul 09, 2013 at 09:49:08AM -0400, Dwight Engen wrote:
> Hi Stéphane, sorry I didn't even know about the existence of
> https://pypi.python.org/pypi/pep8, is that the tool to use in the
> future if I happen to touch any of the python stuff? Thanks.

Hi Dwight,

Yep, I usually run pep8 and pyflakes against all python scripts, the
first is a very basic static analysis tool which will spot most obvious
problems (undefined variables, useless imports, missing imports, ...)
and the second validates the code against the PEP-8 spec.


> On Mon, 8 Jul 2013 10:43:32 -0500
> Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> 
> > Quoting Stéphane Graber (stgraber at ubuntu.com):
> > > Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
> > 
> > Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> > 
> > > ---
> > >  src/python-lxc/examples/pyconsole-vte.py | 2 ++
> > >  src/python-lxc/examples/pyconsole.py     | 3 ++-
> > >  src/python-lxc/lxc/__init__.py           | 7 ++++---
> > >  3 files changed, 8 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/src/python-lxc/examples/pyconsole-vte.py
> > > b/src/python-lxc/examples/pyconsole-vte.py index 7926758..9938e6a
> > > 100755 --- a/src/python-lxc/examples/pyconsole-vte.py
> > > +++ b/src/python-lxc/examples/pyconsole-vte.py
> > > @@ -11,9 +11,11 @@ import vte
> > >  import lxc
> > >  import sys
> > >  
> > > +
> > >  def gtk_exit_cb(terminal):
> > >      gtk.main_quit()
> > >  
> > > +
> > >  def vte_con(ct, ttynum):
> > >      print("Doing console in a VTE widget...")
> > >      masterfd = ct.console_getfd(ttynum)
> > > diff --git a/src/python-lxc/examples/pyconsole.py
> > > b/src/python-lxc/examples/pyconsole.py index 7661ef4..36d4838 100755
> > > --- a/src/python-lxc/examples/pyconsole.py
> > > +++ b/src/python-lxc/examples/pyconsole.py
> > > @@ -22,7 +22,8 @@ if __name__ == '__main__':
> > >  
> > >      ct = lxc.Container(sys.argv[1])
> > >  
> > > -    print("Container:%s tty:%d Ctrl-%c q to quit" % (ct.name,
> > > ttynum, ord('a') + escape-1))
> > > +    print("Container:%s tty:%d Ctrl-%c q to quit" %
> > > +          (ct.name, ttynum, ord('a') + escape-1))
> > >      time.sleep(1)
> > >      if not ct.defined:
> > >          sys.exit("Container %s not defined" % ct.name)
> > > diff --git a/src/python-lxc/lxc/__init__.py
> > > b/src/python-lxc/lxc/__init__.py index c15cfad..9ada7ff 100644
> > > --- a/src/python-lxc/lxc/__init__.py
> > > +++ b/src/python-lxc/lxc/__init__.py
> > > @@ -292,7 +292,7 @@ class Container(_lxc.Container):
> > >          self.load_config()
> > >          return True
> > >  
> > > -    def console(self, ttynum = -1, stdinfd = 0, stdoutfd = 1,
> > > stderrfd = 2, escape = 1):
> > > +    def console(self, ttynum=-1, stdinfd=0, stdoutfd=1,
> > > stderrfd=2, escape=1): """
> > >              Attach to console of running container.
> > >          """
> > > @@ -300,9 +300,10 @@ class Container(_lxc.Container):
> > >          if not self.running:
> > >              return False
> > >  
> > > -        return _lxc.Container.console(self, ttynum, stdinfd,
> > > stdoutfd, stderrfd, escape)
> > > +        return _lxc.Container.console(self, ttynum, stdinfd,
> > > stdoutfd,
> > > +                                      stderrfd, escape)
> > >  
> > > -    def console_getfd(self, ttynum = -1):
> > > +    def console_getfd(self, ttynum=-1):
> > >          """
> > >              Attach to console of running container.
> > >          """
> > > -- 
> > > 1.8.3.2
> > > 
> > > 
> > > ------------------------------------------------------------------------------
> > > This SF.net email is sponsored by Windows:
> > > 
> > > Build for Windows Store.
> > > 
> > > http://p.sf.net/sfu/windows-dev2dev
> > > _______________________________________________
> > > Lxc-devel mailing list
> > > Lxc-devel at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/lxc-devel
> > 
> > ------------------------------------------------------------------------------
> > This SF.net email is sponsored by Windows:
> > 
> > Build for Windows Store.
> > 
> > http://p.sf.net/sfu/windows-dev2dev
> > _______________________________________________
> > Lxc-devel mailing list
> > Lxc-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130709/7bb98b18/attachment.pgp>


More information about the lxc-devel mailing list