python3: Fix PEP8 and avoid crash when listing

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Stéphane Graber 2013-12-03 16:39:46 -05:00
parent c5d32181c5
commit 2edd7a881d
4 changed files with 12 additions and 5 deletions

View File

@ -19,7 +19,8 @@
# #
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
# #
import warnings import warnings

View File

@ -20,7 +20,8 @@
# #
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
# #
import warnings import warnings

View File

@ -20,7 +20,8 @@
# #
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
# #
import warnings import warnings

View File

@ -18,7 +18,8 @@
# #
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
# #
import _lxc import _lxc
@ -346,7 +347,6 @@ class Container(_lxc.Container):
return _lxc.Container.get_interfaces(self) return _lxc.Container.get_interfaces(self)
def get_ips(self, interface=None, family=None, scope=None, timeout=0): def get_ips(self, interface=None, family=None, scope=None, timeout=0):
""" """
Get a tuple of IPs for the container. Get a tuple of IPs for the container.
@ -430,6 +430,8 @@ def list_containers(active=True, defined=True,
""" """
if config_path: if config_path:
if not os.path.exists(config_path):
return tuple()
entries = _lxc.list_containers(active=active, defined=defined, entries = _lxc.list_containers(active=active, defined=defined,
config_path=config_path) config_path=config_path)
else: else:
@ -456,6 +458,7 @@ def attach_run_command(cmd):
else: else:
return _lxc.attach_run_command((cmd, [cmd])) return _lxc.attach_run_command((cmd, [cmd]))
def attach_run_shell(): def attach_run_shell():
""" """
Run a shell when attaching Run a shell when attaching
@ -466,6 +469,7 @@ def attach_run_shell():
""" """
return _lxc.attach_run_shell(None) return _lxc.attach_run_shell(None)
def arch_to_personality(arch): def arch_to_personality(arch):
""" """
Determine the process personality corresponding to the architecture Determine the process personality corresponding to the architecture