Quoting Stéphane Graber (stgra...@ubuntu.com): > The new version of the pep8 command is detecting more indentation > mistakes than it used to, this fixes them. >
Every instance looks like bike-shedding to me, but ok. Acked-by: Serge E. Hallyn <serge.hal...@ubuntu.com> > Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> > --- > src/lxc/lxc-start-ephemeral.in | 81 > +++++++++++++++++++------------------ > src/python-lxc/examples/api_test.py | 20 ++++----- > src/python-lxc/lxc/__init__.py | 51 +++++++++++------------ > src/python-lxc/setup.py | 14 +++---- > 4 files changed, 84 insertions(+), 82 deletions(-) > > diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in > index 3366209..ccf6059 100644 > --- a/src/lxc/lxc-start-ephemeral.in > +++ b/src/lxc/lxc-start-ephemeral.in > @@ -46,16 +46,17 @@ def randomMAC(): > import random > > mac = [0x00, 0x16, 0x3e, > - random.randint(0x00, 0x7f), > - random.randint(0x00, 0xff), > - random.randint(0x00, 0xff)] > + random.randint(0x00, 0x7f), > + random.randint(0x00, 0xff), > + random.randint(0x00, 0xff)] > return ':'.join(map(lambda x: "%02x" % x, mac)) > > # Begin parsing the command line > -parser = argparse.ArgumentParser( > - description=_("LXC: Start an ephemeral container"), > - formatter_class=argparse.RawTextHelpFormatter, epilog=_( > -"""If a COMMAND is given, then the container will run only as long > +parser = argparse.ArgumentParser(description=_( > + "LXC: Start an ephemeral container"), > + > formatter_class=argparse.RawTextHelpFormatter, > + epilog=_("If a COMMAND is given, then the " > + """container will run only as long > as the command runs. > If no COMMAND is given, this command will attach to tty1 and stop the > container when exiting (with ctrl-a-q). > @@ -64,29 +65,31 @@ If no COMMAND is given and -d is used, the name and IP > addresses of the > container will be printed to the console.""")) > > parser.add_argument("--orig", "-o", type=str, required=True, > - help=_("name of the original container")) > + help=_("name of the original container")) > > parser.add_argument("--bdir", "-b", type=str, > - help=_("directory to bind mount into container")) > + help=_("directory to bind mount into container")) > > parser.add_argument("--user", "-u", type=str, > - help=_("the user to connect to the container as")) > + help=_("the user to connect to the container as")) > > parser.add_argument("--key", "-S", type=str, > - help=_("the path to the SSH key to use to connect")) > + help=_("the path to the SSH key to use to connect")) > > parser.add_argument("--daemon", "-d", action="store_true", > - help=_("run in the background")) > + help=_("run in the background")) > > parser.add_argument("--union-type", "-U", type=str, default="overlayfs", > - choices=("overlayfs", "aufs"), > - help=_("type of union (overlayfs or aufs), defaults to overlayfs.")) > + choices=("overlayfs", "aufs"), > + help=_("type of union (overlayfs or aufs), " > + "defaults to overlayfs.")) > > parser.add_argument("--keep-data", "-k", action="store_true", > - help=_("Use a persistent backend instead of tmpfs.")) > + help=_("Use a persistent backend instead of tmpfs.")) > > parser.add_argument("command", metavar='CMD', type=str, nargs="*", > - help=_("Run specific command in container (command as argument)")) > + help=_("Run specific command in container " > + "(command as argument)")) > > args = parser.parse_args() > > @@ -129,7 +132,7 @@ if orig.get_config_item("lxc.mount"): > for line in orig_fd.read().split("\n"): > # Start by replacing any reference to the container rootfs > line.replace(orig.get_config_item("lxc.rootfs"), > - dest.get_config_item("lxc.rootfs")) > + dest.get_config_item("lxc.rootfs")) > > # Skip any line that's not a bind mount > fields = line.split() > @@ -143,17 +146,17 @@ if orig.get_config_item("lxc.mount"): > > # Process any remaining line > dest_mount = os.path.abspath(os.path.join("%s/rootfs/" % ( > - dest_path), fields[1])) > + dest_path), fields[1])) > > if dest_mount == os.path.abspath("%s/rootfs/%s" % ( > - dest_path, args.bdir)): > + dest_path, args.bdir)): > > dest_fd.write("%s\n" % line) > continue > > if "%s/rootfs/" % dest_path not in dest_mount: > - print(_( > -"Skipping mount entry '%s' as it's outside of the container rootfs.") % line) > + print(_("Skipping mount entry '%s' as it's outside " > + "of the container rootfs.") % line) > > overlay_dirs += [(fields[0], dest_mount)] > > @@ -176,27 +179,27 @@ LXC_NAME="%s" > > if args.union_type == "overlayfs": > fd.write("mount -n -t overlayfs" > - " -oupperdir=%s,lowerdir=%s none %s\n" % ( > - target, > - entry[0], > - entry[1])) > + " -oupperdir=%s,lowerdir=%s none %s\n" % ( > + target, > + entry[0], > + entry[1])) > elif args.union_type == "aufs": > fd.write("mount -n -t aufs " > - "-o br=${upper}=rw:${lower}=ro,noplink none %s\n" % ( > - target, > - entry[0], > - entry[1])) > + "-o br=${upper}=rw:${lower}=ro,noplink none %s\n" % ( > + target, > + entry[0], > + entry[1])) > count += 1 > > if args.bdir: > if not os.path.exists(args.bdir): > print(_("Path '%s' doesn't exist, won't be bind-mounted.") % > - args.bdir) > + args.bdir) > else: > src_path = os.path.abspath(args.bdir) > dst_path = "%s/rootfs/%s" % (dest_path, > os.path.abspath(args.bdir)) > fd.write("mkdir -p %s\nmount -n --bind %s %s\n" % ( > - dst_path, src_path, dst_path)) > + dst_path, src_path, dst_path)) > > fd.write(""" > [ -e $LXC_DIR/configured ] && exit 0 > @@ -210,7 +213,7 @@ touch $LXC_DIR/configured > """) > > dest.set_config_item("lxc.hook.pre-mount", > - os.path.join(dest_path, "pre-mount")) > + os.path.join(dest_path, "pre-mount")) > > # Generate post-stop script > if not args.keep_data: > @@ -221,7 +224,7 @@ if not args.keep_data: > """ % (dest_path, dest_path)) > > dest.set_config_item("lxc.hook.post-stop", > - os.path.join(dest_path, "post-stop")) > + os.path.join(dest_path, "post-stop")) > > dest.save_config() > > @@ -248,11 +251,9 @@ if args.daemon: > > You can enter it from the command line with: lxc-console -n %s > The following IP addresses have be found in the container: > -%s""") % ( > - dest.name, > - "\n".join([" - %s" % entry for entry in ips] > - or [" - %s" % _("No address could be found")]) > - )) > +%s""") % (dest.name, > + "\n".join([" - %s" % entry for entry in ips] > + or [" - %s" % _("No address could be found")]))) > sys.exit(0) > > # Now deal with the case where we want to run a command in the container > @@ -265,8 +266,8 @@ if not ips: > > # NOTE: To replace by .attach() once the kernel supports it > cmd = ["ssh", > - "-o", "StrictHostKeyChecking=no", > - "-o", "UserKnownHostsFile=/dev/null"] > + "-o", "StrictHostKeyChecking=no", > + "-o", "UserKnownHostsFile=/dev/null"] > > if args.user: > cmd += ["-l", args.user] > diff --git a/src/python-lxc/examples/api_test.py > b/src/python-lxc/examples/api_test.py > index 14236c7..3ca0267 100644 > --- a/src/python-lxc/examples/api_test.py > +++ b/src/python-lxc/examples/api_test.py > @@ -43,20 +43,20 @@ container = lxc.Container(CONTAINER_NAME) > > # A few basic checks of the current state > assert(container.config_file_name == "%s/%s/config" % > - (LXC_PATH_LIB, CONTAINER_NAME)) > -assert(container.defined == False) > + (LXC_PATH_LIB, CONTAINER_NAME)) > +assert(not container.defined) > assert(container.init_pid == -1) > assert(container.name == CONTAINER_NAME) > -assert(container.running == False) > +assert(not container.running) > assert(container.state == "STOPPED") > > ## Create a rootfs > print("Creating rootfs using '%s'" % LXC_TEMPLATE) > container.create(LXC_TEMPLATE) > > -assert(container.defined == True) > +assert(container.defined) > assert(container.name == CONTAINER_NAME > - == container.get_config_item("lxc.utsname")) > + == container.get_config_item("lxc.utsname")) > assert(container.name in lxc.list_containers()) > > ## Test the config > @@ -86,7 +86,7 @@ container.wait("RUNNING", 3) > > # A few basic checks of the current state > assert(container.init_pid > 1) > -assert(container.running == True) > +assert(container.running) > assert(container.state == "RUNNING") > > ## Checking IP address > @@ -104,7 +104,7 @@ container.wait("FROZEN", 3) > > # A few basic checks of the current state > assert(container.init_pid > 1) > -assert(container.running == True) > +assert(container.running) > assert(container.state == "FROZEN") > > ## Unfreezing the container > @@ -114,7 +114,7 @@ container.wait("RUNNING", 3) > > # A few basic checks of the current state > assert(container.init_pid > 1) > -assert(container.running == True) > +assert(container.running) > assert(container.state == "RUNNING") > > if len(sys.argv) > 1 and sys.argv[1] == "--with-console": > @@ -133,7 +133,7 @@ if container.running: > > # A few basic checks of the current state > assert(container.init_pid == -1) > -assert(container.running == False) > +assert(not container.running) > assert(container.state == "STOPPED") > > ## Cloning the container > @@ -148,4 +148,4 @@ clone.destroy() > print("Destroying the container") > container.destroy() > > -assert(container.defined == False) > +assert(not container.defined) > diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py > index 907303e..c572e10 100644 > --- a/src/python-lxc/lxc/__init__.py > +++ b/src/python-lxc/lxc/__init__.py > @@ -56,7 +56,7 @@ class ContainerNetwork(): > > if key not in self.props: > raise AttributeError("'%s' network has no attribute '%s'" % ( > - self.__get_network_item("type"), key)) > + self.__get_network_item("type"), key)) > > return self.__clear_network_item(self.props[key]) > > @@ -69,7 +69,7 @@ class ContainerNetwork(): > > if key not in self.props: > raise AttributeError("'%s' network has no attribute '%s'" % ( > - self.__get_network_item("type"), key)) > + self.__get_network_item("type"), key)) > > return self.__get_network_item(self.props[key]) > > @@ -79,7 +79,7 @@ class ContainerNetwork(): > > if key not in self.props: > raise AttributeError("'%s' network has no attribute '%s'" % ( > - self.__get_network_item("type"), key)) > + self.__get_network_item("type"), key)) > > return True > > @@ -93,21 +93,21 @@ class ContainerNetwork(): > > if key not in self.props: > raise AttributeError("'%s' network has no attribute '%s'" % ( > - self.__get_network_item("type"), key)) > + self.__get_network_item("type"), key)) > > return self.__set_network_item(self.props[key], value) > > def __clear_network_item(self, key): > return self.container.clear_config_item("lxc.network.%s.%s" % ( > - self.index, key)) > + self.index, key)) > > def __get_network_item(self, key): > return self.container.get_config_item("lxc.network.%s.%s" % ( > - self.index, key)) > + self.index, key)) > > def __set_network_item(self, key, value): > return self.container.set_config_item("lxc.network.%s.%s" % ( > - self.index, key), value) > + self.index, key), value) > > > class ContainerNetworkList(): > @@ -128,7 +128,7 @@ class ContainerNetworkList(): > index = len(self.container.get_config_item("lxc.network")) > > return self.container.set_config_item("lxc.network.%s.type" % index, > - network_type) > + network_type) > > def remove(self, index): > count = len(self.container.get_config_item("lxc.network")) > @@ -272,9 +272,8 @@ class Container(_lxc.Container): > if not source.defined: > return False > > - if subprocess.call( > - ["lxc-clone", "-o", source.name, "-n", self.name], > - universal_newlines=True) != 0: > + if subprocess.call(["lxc-clone", "-o", source.name, "-n", self.name], > + universal_newlines=True) != 0: > return False > > self.load_config() > @@ -288,9 +287,8 @@ class Container(_lxc.Container): > if not self.running: > return False > > - if subprocess.call( > - ["lxc-console", "-n", self.name, "-t", "%s" % tty], > - universal_newlines=True) != 0: > + if subprocess.call(["lxc-console", "-n", self.name, "-t", "%s" % > tty], > + universal_newlines=True) != 0: > return False > return True > > @@ -339,10 +337,11 @@ class Container(_lxc.Container): > ip6_cmd = base_cmd + ["-6", "addr", "show", "scope", > "global"] > if interface: > ip = subprocess.Popen(ip6_cmd + ["dev", interface], > - stdout=subprocess.PIPE, universal_newlines=True) > + stdout=subprocess.PIPE, > + universal_newlines=True) > else: > ip = subprocess.Popen(ip6_cmd, stdout=subprocess.PIPE, > - universal_newlines=True) > + universal_newlines=True) > > ip.wait() > for line in ip.stdout.read().split("\n"): > @@ -355,10 +354,11 @@ class Container(_lxc.Container): > ip4_cmd = base_cmd + ["-4", "addr", "show", "scope", > "global"] > if interface: > ip = subprocess.Popen(ip4_cmd + ["dev", interface], > - stdout=subprocess.PIPE, universal_newlines=True) > + stdout=subprocess.PIPE, > + universal_newlines=True) > else: > ip = subprocess.Popen(ip4_cmd, stdout=subprocess.PIPE, > - universal_newlines=True) > + universal_newlines=True) > > ip.wait() > for line in ip.stdout.read().split("\n"): > @@ -407,14 +407,14 @@ class Container(_lxc.Container): > set_key(key, value) > new_value = self.get_config_item(key) > > - if isinstance(value, str) and isinstance(new_value, str) and \ > - value == new_value: > + if (isinstance(value, str) and isinstance(new_value, str) and > + value == new_value): > return True > - elif isinstance(value, list) and isinstance(new_value, list) and \ > - set(value) == set(new_value): > + elif (isinstance(value, list) and isinstance(new_value, list) and > + set(value) == set(new_value)): > return True > - elif isinstance(value, str) and isinstance(new_value, list) and \ > - set([value]) == set(new_value): > + elif (isinstance(value, str) and isinstance(new_value, list) and > + set([value]) == set(new_value)): > return True > elif old_value: > set_key(key, old_value) > @@ -423,7 +423,7 @@ class Container(_lxc.Container): > self.clear_config_item(key) > return False > > - def wait(self, state, timeout = -1): > + def wait(self, state, timeout=-1): > """ > Wait for the container to reach a given state or timeout. > """ > @@ -433,6 +433,7 @@ class Container(_lxc.Container): > > return _lxc.Container.wait(self, state, timeout) > > + > def list_containers(as_object=False): > """ > List the containers on the system. > diff --git a/src/python-lxc/setup.py b/src/python-lxc/setup.py > index bf635ea..8c22961 100644 > --- a/src/python-lxc/setup.py > +++ b/src/python-lxc/setup.py > @@ -1,10 +1,10 @@ > from distutils.core import setup, Extension > > -module = Extension('_lxc', sources = ['lxc.c'], libraries = ['lxc']) > +module = Extension('_lxc', sources=['lxc.c'], libraries=['lxc']) > > -setup (name = '_lxc', > - version = '0.1', > - description = 'LXC', > - packages = ['lxc'], > - package_dir = {'lxc':'lxc'}, > - ext_modules = [module]) > +setup(name='_lxc', > + version='0.1', > + description='LXC', > + packages=['lxc'], > + package_dir={'lxc': 'lxc'}, > + ext_modules=[module]) > -- > 1.8.0 > > > ------------------------------------------------------------------------------ > Monitor your physical, virtual and cloud infrastructure from a single > web console. Get in-depth insight into apps, servers, databases, vmware, > SAP, cloud infrastructure, etc. Download 30-day Free Trial. > Pricing starts from $795 for 25 servers or applications! > http://p.sf.net/sfu/zoho_dev2dev_nov > _______________________________________________ > Lxc-devel mailing list > Lxc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-devel ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel