From 4dcd1e2f6adf56823b17e7a1169578ce04d82a8c Mon Sep 17 00:00:00 2001 From: Andrew Bogott Date: Tue, 5 Mar 2019 16:31:37 +0000 Subject: [PATCH 1/4] tox: disable W504 "Line break occurred after a binary operator" This is a new coding rule, which actively contradicts the previous pep8 rule, W503 "line break before binary operator". Both rules are currently in force, which doesn't make a lot of sense. Until the standards people work this out, I'm arbitrarily choosing to disable the rule that involes the fewest coding changes. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index eaad4bc..a6e5971 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist = flake8, pylint, yamllint, unit, integration, docs [flake8] -ignore = E221,E241,E501 +ignore = E221,E241,E501,W504 max-line-length = 110 [testenv] From bfe2d1f3baf4d0d129f7093aa7789d0d4d8f86c3 Mon Sep 17 00:00:00 2001 From: Andrew Bogott Date: Tue, 5 Mar 2019 16:36:11 +0000 Subject: [PATCH 2/4] flake8 fixes: correct some indentations --- bootstrapvz/base/tasklist.py | 2 +- bootstrapvz/common/tasks/apt.py | 2 +- bootstrapvz/plugins/prebootstrapped/tasks.py | 30 ++++----- bootstrapvz/providers/ec2/__init__.py | 10 +-- tests/system/providers/ec2/__init__.py | 2 +- tests/system/tools/__init__.py | 66 ++++++++++---------- 6 files changed, 56 insertions(+), 56 deletions(-) diff --git a/bootstrapvz/base/tasklist.py b/bootstrapvz/base/tasklist.py index ed1c74e..5aa9e35 100644 --- a/bootstrapvz/base/tasklist.py +++ b/bootstrapvz/base/tasklist.py @@ -189,7 +189,7 @@ def get_all_classes(path=None, prefix='', excludes=[]): for class_name, obj in classes: # We only want classes that are defined in the module, and not imported ones if obj.__module__ == module_name: - yield obj + yield obj def check_ordering(task): diff --git a/bootstrapvz/common/tasks/apt.py b/bootstrapvz/common/tasks/apt.py index bde3a04..07b8bd3 100644 --- a/bootstrapvz/common/tasks/apt.py +++ b/bootstrapvz/common/tasks/apt.py @@ -100,7 +100,7 @@ class AddManifestPreferences(Task): @classmethod def run(cls, info): for name, preferences in info.manifest.packages['preferences'].iteritems(): - info.preference_lists.add(name, preferences) + info.preference_lists.add(name, preferences) class InstallTrustedKeys(Task): diff --git a/bootstrapvz/plugins/prebootstrapped/tasks.py b/bootstrapvz/plugins/prebootstrapped/tasks.py index 85240ff..4a23aa6 100644 --- a/bootstrapvz/plugins/prebootstrapped/tasks.py +++ b/bootstrapvz/plugins/prebootstrapped/tasks.py @@ -104,20 +104,20 @@ class CreateFromFolder(Task): def set_fs_states(vol): - vol.fsm.current = 'detached' + vol.fsm.current = 'detached' - p_map = vol.partition_map - from bootstrapvz.base.fs.partitionmaps.none import NoPartitions - if not isinstance(p_map, NoPartitions): - p_map.fsm.current = 'unmapped' + p_map = vol.partition_map + from bootstrapvz.base.fs.partitionmaps.none import NoPartitions + if not isinstance(p_map, NoPartitions): + p_map.fsm.current = 'unmapped' - from bootstrapvz.base.fs.partitions.unformatted import UnformattedPartition - from bootstrapvz.base.fs.partitions.single import SinglePartition - for partition in p_map.partitions: - if isinstance(partition, UnformattedPartition): - partition.fsm.current = 'unmapped' - continue - if isinstance(partition, SinglePartition): - partition.fsm.current = 'formatted' - continue - partition.fsm.current = 'unmapped_fmt' + from bootstrapvz.base.fs.partitions.unformatted import UnformattedPartition + from bootstrapvz.base.fs.partitions.single import SinglePartition + for partition in p_map.partitions: + if isinstance(partition, UnformattedPartition): + partition.fsm.current = 'unmapped' + continue + if isinstance(partition, SinglePartition): + partition.fsm.current = 'formatted' + continue + partition.fsm.current = 'unmapped_fmt' diff --git a/bootstrapvz/providers/ec2/__init__.py b/bootstrapvz/providers/ec2/__init__.py index 1684142..d219105 100644 --- a/bootstrapvz/providers/ec2/__init__.py +++ b/bootstrapvz/providers/ec2/__init__.py @@ -35,19 +35,19 @@ def validate_manifest(data, validator, error): error('Paravirtualized AMIs only support pvgrub as a bootloader', ['system', 'bootloader']) if backing != 'ebs' and virtualization == 'hvm': - error('HVM AMIs currently only work when they are EBS backed', ['volume', 'backing']) + error('HVM AMIs currently only work when they are EBS backed', ['volume', 'backing']) if backing == 's3' and partition_type != 'none': - error('S3 backed AMIs currently only work with unpartitioned volumes', ['system', 'bootloader']) + error('S3 backed AMIs currently only work with unpartitioned volumes', ['system', 'bootloader']) if backing != 'ebs' and encrypted: - error('Encryption is supported only on EBS volumes') + error('Encryption is supported only on EBS volumes') if encrypted is False and kms_key_id is not None: - error('KMS Key Id can be set only when encryption is enabled') + error('KMS Key Id can be set only when encryption is enabled') if enhanced_networking == 'simple' and virtualization != 'hvm': - error('Enhanced networking only works with HVM virtualization', ['provider', 'virtualization']) + error('Enhanced networking only works with HVM virtualization', ['provider', 'virtualization']) def resolve_tasks(taskset, manifest): diff --git a/tests/system/providers/ec2/__init__.py b/tests/system/providers/ec2/__init__.py index 795760b..f7d043c 100644 --- a/tests/system/providers/ec2/__init__.py +++ b/tests/system/providers/ec2/__init__.py @@ -23,7 +23,7 @@ def prepare_bootstrap(manifest, build_server): bucket.delete_key(item.key) s3_connection.delete_bucket(manifest.image['bucket']) else: - yield + yield @contextmanager diff --git a/tests/system/tools/__init__.py b/tests/system/tools/__init__.py index 6db90ce..07b7d0b 100644 --- a/tests/system/tools/__init__.py +++ b/tests/system/tools/__init__.py @@ -46,42 +46,42 @@ def waituntil(predicate, timeout=5, interval=0.05): def read_from_socket(socket_path, termination_string, timeout, read_timeout=0.5): - import socket - import select - import errno - console = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - console.connect(socket_path) - console.setblocking(0) + import socket + import select + import errno + console = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + console.connect(socket_path) + console.setblocking(0) - from timeit import default_timer - start = default_timer() + from timeit import default_timer + start = default_timer() - output = '' - ptr = 0 - continue_select = True - while continue_select: - read_ready, _, _ = select.select([console], [], [], read_timeout) - if console in read_ready: - while True: - try: - output += console.recv(1024) - if termination_string in output[ptr:]: - continue_select = False - else: - ptr = len(output) - len(termination_string) - break - except socket.error, e: - if e.errno != errno.EWOULDBLOCK: - raise Exception(e) + output = '' + ptr = 0 + continue_select = True + while continue_select: + read_ready, _, _ = select.select([console], [], [], read_timeout) + if console in read_ready: + while True: + try: + output += console.recv(1024) + if termination_string in output[ptr:]: continue_select = False - if default_timer() - start > timeout: - from .exceptions import SocketReadTimeout - msg = ('Reading from socket `{path}\' timed out after {seconds} seconds.\n' - 'Here is the output so far:\n{output}' - .format(path=socket_path, seconds=timeout, output=output)) - raise SocketReadTimeout(msg) - console.close() - return output + else: + ptr = len(output) - len(termination_string) + break + except socket.error, e: + if e.errno != errno.EWOULDBLOCK: + raise Exception(e) + continue_select = False + if default_timer() - start > timeout: + from .exceptions import SocketReadTimeout + msg = ('Reading from socket `{path}\' timed out after {seconds} seconds.\n' + 'Here is the output so far:\n{output}' + .format(path=socket_path, seconds=timeout, output=output)) + raise SocketReadTimeout(msg) + console.close() + return output @contextmanager From b9dda552dba5bbf113742aac120deec799dd72c5 Mon Sep 17 00:00:00 2001 From: Andrew Bogott Date: Tue, 5 Mar 2019 19:01:05 +0000 Subject: [PATCH 3/4] flake8: resolve W605 'invalid escape sequence' warnings This patch scares me since every fix involves adding a character to a regex. I am /pretty sure/ that this is a no-op but I don't have the capacity to test this beyond what tox can do. --- bootstrapvz/base/fs/partitionmaps/abstract.py | 6 +++--- bootstrapvz/base/pkg/sourceslist.py | 10 +++++----- bootstrapvz/common/bytes.py | 2 +- bootstrapvz/common/fs/__init__.py | 2 +- bootstrapvz/common/tasks/host.py | 2 +- bootstrapvz/plugins/cloud_init/tasks.py | 6 +++--- bootstrapvz/plugins/minimize_size/tasks/dpkg.py | 2 +- bootstrapvz/plugins/ntp/tasks.py | 2 +- bootstrapvz/plugins/puppet/tasks.py | 2 +- bootstrapvz/providers/ec2/tasks/boot.py | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bootstrapvz/base/fs/partitionmaps/abstract.py b/bootstrapvz/base/fs/partitionmaps/abstract.py index 407eecf..5278110 100644 --- a/bootstrapvz/base/fs/partitionmaps/abstract.py +++ b/bootstrapvz/base/fs/partitionmaps/abstract.py @@ -69,9 +69,9 @@ class AbstractPartitionMap(FSMProxy): # Ask kpartx how the partitions will be mapped before actually attaching them. mappings = log_check_call(['kpartx', '-l', volume.device_path]) import re - regexp = re.compile('^(?P.+[^\d](?P\d+)) : ' - '(?P\d) (?P\d+) ' - '{device_path} (?P\d+)$' + regexp = re.compile('^(?P.+[^\\d](?P\\d+)) : ' + '(?P\\d) (?P\\d+) ' + '{device_path} (?P\\d+)$' .format(device_path=volume.device_path)) log_check_call(['kpartx', '-as', volume.device_path]) diff --git a/bootstrapvz/base/pkg/sourceslist.py b/bootstrapvz/base/pkg/sourceslist.py index 76c9daa..2f8fa4f 100644 --- a/bootstrapvz/base/pkg/sourceslist.py +++ b/bootstrapvz/base/pkg/sourceslist.py @@ -56,11 +56,11 @@ class Source(object): # The format is taken from `man sources.list` # or: http://manpages.debian.org/cgi-bin/man.cgi?sektion=5&query=sources.list&apropos=0&manpath=sid&locale=en import re - regexp = re.compile('^(?Pdeb|deb-src)\s+' - '(\[\s*(?P.+\S)?\s*\]\s+)?' - '(?P\S+)\s+' - '(?P\S+)' - '(\s+(?P.+\S))?\s*$') + regexp = re.compile('^(?Pdeb|deb-src)\\s+' + '(\\[\\s*(?P.+\\S)?\\s*\\]\\s+)?' + '(?P\\S+)\\s+' + '(?P\\S+)' + '(\\s+(?P.+\\S))?\\s*$') match = regexp.match(line).groupdict() if match is None: from .exceptions import SourceError diff --git a/bootstrapvz/common/bytes.py b/bootstrapvz/common/bytes.py index 2ec7b91..3f29525 100644 --- a/bootstrapvz/common/bytes.py +++ b/bootstrapvz/common/bytes.py @@ -29,7 +29,7 @@ class Bytes(object): @staticmethod def parse(qty_str): import re - regex = re.compile('^(?P\d+)(?P[KMGT]i?B|B)$') + regex = re.compile('^(?P\\d+)(?P[KMGT]i?B|B)$') parsed = regex.match(qty_str) if parsed is None: raise UnitError('Unable to parse ' + qty_str) diff --git a/bootstrapvz/common/fs/__init__.py b/bootstrapvz/common/fs/__init__.py index 300765a..191dc73 100644 --- a/bootstrapvz/common/fs/__init__.py +++ b/bootstrapvz/common/fs/__init__.py @@ -3,7 +3,7 @@ from contextlib import contextmanager def get_partitions(): import re - regexp = re.compile('^ *(?P\d+) *(?P\d+) *(?P\d+) (?P\S+)$') + regexp = re.compile('^ *(?P\\d+) *(?P\\d+) *(?P\\d+) (?P\\S+)$') matches = {} path = '/proc/partitions' with open(path) as partitions: diff --git a/bootstrapvz/common/tasks/host.py b/bootstrapvz/common/tasks/host.py index 8285b81..64b41c3 100644 --- a/bootstrapvz/common/tasks/host.py +++ b/bootstrapvz/common/tasks/host.py @@ -21,7 +21,7 @@ class CheckExternalCommands(Task): log.debug('Checking availability of ' + command) path = find_executable(command) if path is None or not os.access(path, os.X_OK): - if re.match('^https?:\/\/', package): + if re.match('^https?:\\/\\/', package): msg = ('The command `{command}\' is not available, ' 'you can download the software at `{package}\'.' .format(command=command, package=package)) diff --git a/bootstrapvz/plugins/cloud_init/tasks.py b/bootstrapvz/plugins/cloud_init/tasks.py index ac4bf89..3382237 100644 --- a/bootstrapvz/plugins/cloud_init/tasks.py +++ b/bootstrapvz/plugins/cloud_init/tasks.py @@ -51,8 +51,8 @@ class SetGroups(Task): from bootstrapvz.common.tools import sed_i cloud_cfg = os.path.join(info.root, 'etc/cloud/cloud.cfg') groups = info.manifest.plugins['cloud_init']['groups'] - search = ('^ groups: \[adm, audio, cdrom, dialout, floppy, video,' - ' plugdev, dip\]$') + search = ('^ groups: \\[adm, audio, cdrom, dialout, floppy, video,' + ' plugdev, dip\\]$') replace = (' groups: [adm, audio, cdrom, dialout, floppy, video,' ' plugdev, dip, {groups}]').format(groups=', '.join(groups)) sed_i(cloud_cfg, search, replace) @@ -92,7 +92,7 @@ class DisableModules(Task): if patterns != "": patterns = patterns + "|" + pattern else: - patterns = "^\s+-\s+(" + pattern + patterns = "^\\s+-\\s+(" + pattern patterns = patterns + ")$" regex = re.compile(patterns) diff --git a/bootstrapvz/plugins/minimize_size/tasks/dpkg.py b/bootstrapvz/plugins/minimize_size/tasks/dpkg.py index 48b2f3e..afd920a 100644 --- a/bootstrapvz/plugins/minimize_size/tasks/dpkg.py +++ b/bootstrapvz/plugins/minimize_size/tasks/dpkg.py @@ -44,7 +44,7 @@ class CreateBootstrapFilterScripts(Task): # The pattern matching when excluding is needed in order to filter # everything below e.g. /usr/share/locale but not the folder itself filter_lists = info._minimize_size['bootstrap_filter'] - exclude_list = '\|'.join(map(lambda p: '.' + p + '.\+', filter_lists['exclude'])) + exclude_list = '\\|'.join(map(lambda p: '.' + p + '.\\+', filter_lists['exclude'])) include_list = '\n'.join(map(lambda p: '.' + p, filter_lists['include'])) sed_i(filter_script, r'EXCLUDE_PATTERN', exclude_list) sed_i(filter_script, r'INCLUDE_PATHS', include_list) diff --git a/bootstrapvz/plugins/ntp/tasks.py b/bootstrapvz/plugins/ntp/tasks.py index 9e6c7f9..2fb31b9 100644 --- a/bootstrapvz/plugins/ntp/tasks.py +++ b/bootstrapvz/plugins/ntp/tasks.py @@ -24,7 +24,7 @@ class SetNtpServers(Task): import re ntp_path = os.path.join(info.root, 'etc/ntp.conf') servers = list(info.manifest.plugins['ntp']['servers']) - debian_ntp_server = re.compile('.*[0-9]\.debian\.pool\.ntp\.org.*') + debian_ntp_server = re.compile('.*[0-9]\\.debian\\.pool\\.ntp\\.org.*') for line in fileinput.input(files=ntp_path, inplace=True): # Will write all the specified servers on the first match, then supress all other default servers if re.match(debian_ntp_server, line): diff --git a/bootstrapvz/plugins/puppet/tasks.py b/bootstrapvz/plugins/puppet/tasks.py index 2607a76..58d9424 100644 --- a/bootstrapvz/plugins/puppet/tasks.py +++ b/bootstrapvz/plugins/puppet/tasks.py @@ -147,7 +147,7 @@ class ApplyPuppetManifest(Task): log_check_call(['chroot', info.root, 'puppet', 'apply', '--verbose', '--debug', manifest_path]) os.remove(manifest_dst) hosts_path = os.path.join(info.root, 'etc/hosts') - sed_i(hosts_path, '127.0.0.1\s*{hostname}\n?'.format(hostname=hostname), '') + sed_i(hosts_path, '127.0.0.1\\s*{hostname}\n?'.format(hostname=hostname), '') class EnableAgent(Task): diff --git a/bootstrapvz/providers/ec2/tasks/boot.py b/bootstrapvz/providers/ec2/tasks/boot.py index 15426a5..9ef6493 100644 --- a/bootstrapvz/providers/ec2/tasks/boot.py +++ b/bootstrapvz/providers/ec2/tasks/boot.py @@ -53,7 +53,7 @@ class CreatePVGrubCustomRule(Task): grub_device = 'GRUB_DEVICE=/dev/xvda' + str(root_idx) sed_i(script_dst, '^GRUB_DEVICE=/dev/xvda$', grub_device) grub_root = '\troot (hd0,{idx})'.format(idx=root_idx - 1) - sed_i(script_dst, '^\troot \(hd0\)$', grub_root) + sed_i(script_dst, r'^\troot \(hd0\)$', grub_root) if info.manifest.volume['backing'] == 's3': from bootstrapvz.common.tools import sed_i From 43b321ce917620a007298b5139be2c5d032c85f5 Mon Sep 17 00:00:00 2001 From: Andrew Bogott Date: Tue, 5 Mar 2019 19:01:05 +0000 Subject: [PATCH 4/4] Replace a bunch of \\ escapes with raw strings There are a few cases where changing to a raw string will change the behavior; I'll address that in a later patch. --- bootstrapvz/base/fs/partitionmaps/abstract.py | 6 +++--- bootstrapvz/base/pkg/sourceslist.py | 10 +++++----- bootstrapvz/common/bytes.py | 2 +- bootstrapvz/common/fs/__init__.py | 2 +- bootstrapvz/common/tasks/host.py | 2 +- bootstrapvz/plugins/cloud_init/tasks.py | 6 +++--- bootstrapvz/plugins/minimize_size/tasks/dpkg.py | 2 +- bootstrapvz/plugins/ntp/tasks.py | 2 +- bootstrapvz/providers/ec2/tasks/boot.py | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bootstrapvz/base/fs/partitionmaps/abstract.py b/bootstrapvz/base/fs/partitionmaps/abstract.py index 5278110..be0eea4 100644 --- a/bootstrapvz/base/fs/partitionmaps/abstract.py +++ b/bootstrapvz/base/fs/partitionmaps/abstract.py @@ -69,9 +69,9 @@ class AbstractPartitionMap(FSMProxy): # Ask kpartx how the partitions will be mapped before actually attaching them. mappings = log_check_call(['kpartx', '-l', volume.device_path]) import re - regexp = re.compile('^(?P.+[^\\d](?P\\d+)) : ' - '(?P\\d) (?P\\d+) ' - '{device_path} (?P\\d+)$' + regexp = re.compile(r'^(?P.+[^\d](?P\d+)) : ' + r'(?P\d) (?P\d+) ' + r'{device_path} (?P\d+)$' .format(device_path=volume.device_path)) log_check_call(['kpartx', '-as', volume.device_path]) diff --git a/bootstrapvz/base/pkg/sourceslist.py b/bootstrapvz/base/pkg/sourceslist.py index 2f8fa4f..049b054 100644 --- a/bootstrapvz/base/pkg/sourceslist.py +++ b/bootstrapvz/base/pkg/sourceslist.py @@ -56,11 +56,11 @@ class Source(object): # The format is taken from `man sources.list` # or: http://manpages.debian.org/cgi-bin/man.cgi?sektion=5&query=sources.list&apropos=0&manpath=sid&locale=en import re - regexp = re.compile('^(?Pdeb|deb-src)\\s+' - '(\\[\\s*(?P.+\\S)?\\s*\\]\\s+)?' - '(?P\\S+)\\s+' - '(?P\\S+)' - '(\\s+(?P.+\\S))?\\s*$') + regexp = re.compile(r'^(?Pdeb|deb-src)\s+' + r'(\[\s*(?P.+\S)?\s*\]\s+)?' + r'(?P\S+)\s+' + r'(?P\S+)' + r'(\s+(?P.+\S))?\s*$') match = regexp.match(line).groupdict() if match is None: from .exceptions import SourceError diff --git a/bootstrapvz/common/bytes.py b/bootstrapvz/common/bytes.py index 3f29525..572ba23 100644 --- a/bootstrapvz/common/bytes.py +++ b/bootstrapvz/common/bytes.py @@ -29,7 +29,7 @@ class Bytes(object): @staticmethod def parse(qty_str): import re - regex = re.compile('^(?P\\d+)(?P[KMGT]i?B|B)$') + regex = re.compile(r'^(?P\d+)(?P[KMGT]i?B|B)$') parsed = regex.match(qty_str) if parsed is None: raise UnitError('Unable to parse ' + qty_str) diff --git a/bootstrapvz/common/fs/__init__.py b/bootstrapvz/common/fs/__init__.py index 191dc73..0f93c75 100644 --- a/bootstrapvz/common/fs/__init__.py +++ b/bootstrapvz/common/fs/__init__.py @@ -3,7 +3,7 @@ from contextlib import contextmanager def get_partitions(): import re - regexp = re.compile('^ *(?P\\d+) *(?P\\d+) *(?P\\d+) (?P\\S+)$') + regexp = re.compile(r'^ *(?P\d+) *(?P\d+) *(?P\d+) (?P\S+)$') matches = {} path = '/proc/partitions' with open(path) as partitions: diff --git a/bootstrapvz/common/tasks/host.py b/bootstrapvz/common/tasks/host.py index 64b41c3..2f5b480 100644 --- a/bootstrapvz/common/tasks/host.py +++ b/bootstrapvz/common/tasks/host.py @@ -21,7 +21,7 @@ class CheckExternalCommands(Task): log.debug('Checking availability of ' + command) path = find_executable(command) if path is None or not os.access(path, os.X_OK): - if re.match('^https?:\\/\\/', package): + if re.match(r'^https?:\/\/', package): msg = ('The command `{command}\' is not available, ' 'you can download the software at `{package}\'.' .format(command=command, package=package)) diff --git a/bootstrapvz/plugins/cloud_init/tasks.py b/bootstrapvz/plugins/cloud_init/tasks.py index 3382237..45ad979 100644 --- a/bootstrapvz/plugins/cloud_init/tasks.py +++ b/bootstrapvz/plugins/cloud_init/tasks.py @@ -51,8 +51,8 @@ class SetGroups(Task): from bootstrapvz.common.tools import sed_i cloud_cfg = os.path.join(info.root, 'etc/cloud/cloud.cfg') groups = info.manifest.plugins['cloud_init']['groups'] - search = ('^ groups: \\[adm, audio, cdrom, dialout, floppy, video,' - ' plugdev, dip\\]$') + search = (r'^ groups: \[adm, audio, cdrom, dialout, floppy, video,' + r' plugdev, dip\]$') replace = (' groups: [adm, audio, cdrom, dialout, floppy, video,' ' plugdev, dip, {groups}]').format(groups=', '.join(groups)) sed_i(cloud_cfg, search, replace) @@ -92,7 +92,7 @@ class DisableModules(Task): if patterns != "": patterns = patterns + "|" + pattern else: - patterns = "^\\s+-\\s+(" + pattern + patterns = r"^\s+-\s+(" + pattern patterns = patterns + ")$" regex = re.compile(patterns) diff --git a/bootstrapvz/plugins/minimize_size/tasks/dpkg.py b/bootstrapvz/plugins/minimize_size/tasks/dpkg.py index afd920a..652e107 100644 --- a/bootstrapvz/plugins/minimize_size/tasks/dpkg.py +++ b/bootstrapvz/plugins/minimize_size/tasks/dpkg.py @@ -44,7 +44,7 @@ class CreateBootstrapFilterScripts(Task): # The pattern matching when excluding is needed in order to filter # everything below e.g. /usr/share/locale but not the folder itself filter_lists = info._minimize_size['bootstrap_filter'] - exclude_list = '\\|'.join(map(lambda p: '.' + p + '.\\+', filter_lists['exclude'])) + exclude_list = r'\|'.join(map(lambda p: '.' + p + r'.\+', filter_lists['exclude'])) include_list = '\n'.join(map(lambda p: '.' + p, filter_lists['include'])) sed_i(filter_script, r'EXCLUDE_PATTERN', exclude_list) sed_i(filter_script, r'INCLUDE_PATHS', include_list) diff --git a/bootstrapvz/plugins/ntp/tasks.py b/bootstrapvz/plugins/ntp/tasks.py index 2fb31b9..9741a06 100644 --- a/bootstrapvz/plugins/ntp/tasks.py +++ b/bootstrapvz/plugins/ntp/tasks.py @@ -24,7 +24,7 @@ class SetNtpServers(Task): import re ntp_path = os.path.join(info.root, 'etc/ntp.conf') servers = list(info.manifest.plugins['ntp']['servers']) - debian_ntp_server = re.compile('.*[0-9]\\.debian\\.pool\\.ntp\\.org.*') + debian_ntp_server = re.compile(r'.*[0-9]\.debian\.pool\.ntp\.org.*') for line in fileinput.input(files=ntp_path, inplace=True): # Will write all the specified servers on the first match, then supress all other default servers if re.match(debian_ntp_server, line): diff --git a/bootstrapvz/providers/ec2/tasks/boot.py b/bootstrapvz/providers/ec2/tasks/boot.py index 9ef6493..3b630c1 100644 --- a/bootstrapvz/providers/ec2/tasks/boot.py +++ b/bootstrapvz/providers/ec2/tasks/boot.py @@ -53,7 +53,7 @@ class CreatePVGrubCustomRule(Task): grub_device = 'GRUB_DEVICE=/dev/xvda' + str(root_idx) sed_i(script_dst, '^GRUB_DEVICE=/dev/xvda$', grub_device) grub_root = '\troot (hd0,{idx})'.format(idx=root_idx - 1) - sed_i(script_dst, r'^\troot \(hd0\)$', grub_root) + sed_i(script_dst, '^\troot \\(hd0\\)$', grub_root) if info.manifest.volume['backing'] == 's3': from bootstrapvz.common.tools import sed_i