diff options
author | Ryan Petrello <rpetrell@redhat.com> | 2018-10-24 14:49:35 +0200 |
---|---|---|
committer | Ryan Petrello <rpetrell@redhat.com> | 2018-10-24 16:11:53 +0200 |
commit | c695ba2e101ef82b345bf93cc48c1a326826b693 (patch) | |
tree | a9031f037bfaf06ebd516a3a35552e090d0473ed | |
parent | Merge pull request #2514 from farcaller/patch-1 (diff) | |
download | awx-c695ba2e101ef82b345bf93cc48c1a326826b693.tar.xz awx-c695ba2e101ef82b345bf93cc48c1a326826b693.zip |
fix flake8
-rw-r--r-- | awx/api/serializers.py | 14 | ||||
-rw-r--r-- | awx/main/expect/isolated_manager.py | 2 | ||||
-rwxr-xr-x | awx/main/expect/run.py | 2 | ||||
-rw-r--r-- | awx/main/fields.py | 10 | ||||
-rw-r--r-- | awx/main/models/schedules.py | 2 | ||||
-rw-r--r-- | awx/main/tests/docs/test_swagger_generation.py | 2 | ||||
-rw-r--r-- | awx/main/tests/unit/test_tasks.py | 12 | ||||
-rw-r--r-- | awx/main/utils/filters.py | 4 | ||||
-rw-r--r-- | awx/main/utils/safe_yaml.py | 4 | ||||
-rw-r--r-- | awx/plugins/library/scan_services.py | 8 | ||||
-rwxr-xr-x | setup.cfg | 2 |
11 files changed, 31 insertions, 31 deletions
diff --git a/awx/api/serializers.py b/awx/api/serializers.py index bed1c1b4fb..0d9867f49c 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -4535,13 +4535,13 @@ class SchedulePreviewSerializer(BaseSerializer): # - COUNT > 999 def validate_rrule(self, value): rrule_value = value - multi_by_month_day = ".*?BYMONTHDAY[\:\=][0-9]+,-*[0-9]+" - multi_by_month = ".*?BYMONTH[\:\=][0-9]+,[0-9]+" - by_day_with_numeric_prefix = ".*?BYDAY[\:\=][0-9]+[a-zA-Z]{2}" - match_count = re.match(".*?(COUNT\=[0-9]+)", rrule_value) - match_multiple_dtstart = re.findall(".*?(DTSTART(;[^:]+)?\:[0-9]+T[0-9]+Z?)", rrule_value) - match_native_dtstart = re.findall(".*?(DTSTART:[0-9]+T[0-9]+) ", rrule_value) - match_multiple_rrule = re.findall(".*?(RRULE\:)", rrule_value) + multi_by_month_day = r".*?BYMONTHDAY[\:\=][0-9]+,-*[0-9]+" + multi_by_month = r".*?BYMONTH[\:\=][0-9]+,[0-9]+" + by_day_with_numeric_prefix = r".*?BYDAY[\:\=][0-9]+[a-zA-Z]{2}" + match_count = re.match(r".*?(COUNT\=[0-9]+)", rrule_value) + match_multiple_dtstart = re.findall(r".*?(DTSTART(;[^:]+)?\:[0-9]+T[0-9]+Z?)", rrule_value) + match_native_dtstart = re.findall(r".*?(DTSTART:[0-9]+T[0-9]+) ", rrule_value) + match_multiple_rrule = re.findall(r".*?(RRULE\:)", rrule_value) if not len(match_multiple_dtstart): raise serializers.ValidationError(_('Valid DTSTART required in rrule. Value should start with: DTSTART:YYYYMMDDTHHMMSSZ')) if len(match_native_dtstart): diff --git a/awx/main/expect/isolated_manager.py b/awx/main/expect/isolated_manager.py index 016d3e8f28..fad9fc89ed 100644 --- a/awx/main/expect/isolated_manager.py +++ b/awx/main/expect/isolated_manager.py @@ -38,7 +38,7 @@ class IsolatedManager(object): :param stdout_handle: a file-like object for capturing stdout :param ssh_key_path: a filepath where SSH key data can be read :param expect_passwords: a dict of regular expression password prompts - to input values, i.e., {r'Password:\s*?$': + to input values, i.e., {r'Password:*?$': 'some_password'} :param cancelled_callback: a callable - which returns `True` or `False` - signifying if the job has been prematurely diff --git a/awx/main/expect/run.py b/awx/main/expect/run.py index 601790757c..96d7e6ce90 100755 --- a/awx/main/expect/run.py +++ b/awx/main/expect/run.py @@ -71,7 +71,7 @@ def run_pexpect(args, cwd, env, logfile, - signifying if the job has been prematurely cancelled :param expect_passwords: a dict of regular expression password prompts - to input values, i.e., {r'Password:\s*?$': + to input values, i.e., {r'Password:*?$': 'some_password'} :param extra_update_fields: a dict used to specify DB fields which should be updated on the underlying model diff --git a/awx/main/fields.py b/awx/main/fields.py index 5bed9407bf..7be0e3b281 100644 --- a/awx/main/fields.py +++ b/awx/main/fields.py @@ -573,10 +573,10 @@ class CredentialInputField(JSONSchemaField): # string) match = re.search( # 'foo' is a dependency of 'bar' - "'" # apostrophe - "([^']+)" # one or more non-apostrophes (first group) - "'[\w ]+'" # one or more words/spaces - "([^']+)", # second group + r"'" # apostrophe + r"([^']+)" # one or more non-apostrophes (first group) + r"'[\w ]+'" # one or more words/spaces + r"([^']+)", # second group error.message, ) if match: @@ -755,7 +755,7 @@ class CredentialTypeInjectorField(JSONSchemaField): 'file': { 'type': 'object', 'patternProperties': { - '^template(\.[a-zA-Z_]+[a-zA-Z0-9_]*)?$': {'type': 'string'}, + r'^template(\.[a-zA-Z_]+[a-zA-Z0-9_]*)?$': {'type': 'string'}, }, 'additionalProperties': False, }, diff --git a/awx/main/models/schedules.py b/awx/main/models/schedules.py index 55cd7f2053..617c436534 100644 --- a/awx/main/models/schedules.py +++ b/awx/main/models/schedules.py @@ -153,7 +153,7 @@ class Schedule(CommonModel, LaunchTimeConfig): if 'until=' in rrule.lower(): # if DTSTART;TZID= is used, coerce "naive" UNTIL values # to the proper UTC date - match_until = re.match(".*?(?P<until>UNTIL\=[0-9]+T[0-9]+)(?P<utcflag>Z?)", rrule) + match_until = re.match(r".*?(?P<until>UNTIL\=[0-9]+T[0-9]+)(?P<utcflag>Z?)", rrule) if not len(match_until.group('utcflag')): # rrule = DTSTART;TZID=America/New_York:20200601T120000 RRULE:...;UNTIL=20200601T170000 diff --git a/awx/main/tests/docs/test_swagger_generation.py b/awx/main/tests/docs/test_swagger_generation.py index b84e4e9a52..fc6bfa25a1 100644 --- a/awx/main/tests/docs/test_swagger_generation.py +++ b/awx/main/tests/docs/test_swagger_generation.py @@ -119,7 +119,7 @@ class TestSwaggerGeneration(): def test_autogen_response_examples(self, swagger_autogen): for pattern, node in TestSwaggerGeneration.JSON['paths'].items(): pattern = pattern.replace('{id}', '[0-9]+') - pattern = pattern.replace('{category_slug}', '[a-zA-Z0-9\-]+') + pattern = pattern.replace(r'{category_slug}', r'[a-zA-Z0-9\-]+') for path, result in swagger_autogen.items(): if re.match('^{}$'.format(pattern), path): for key, value in result.items(): diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 6d86fec711..050b9c8b07 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -891,9 +891,9 @@ class TestJobCredentials(TestJobExecution): (k.pattern, v) for k, v in call_kwargs['expect_passwords'].items() if 'Vault' in k.pattern ) - assert vault_passwords['Vault password \(prod\):\\s*?$'] == 'pass@prod' - assert vault_passwords['Vault password \(dev\):\\s*?$'] == 'pass@dev' - assert vault_passwords['Vault password:\\s*?$'] == '' + assert vault_passwords['Vault password \(prod\):\\s*?$'] == 'pass@prod' # noqa + assert vault_passwords['Vault password \(dev\):\\s*?$'] == 'pass@dev' # noqa + assert vault_passwords['Vault password:\\s*?$'] == '' # noqa assert '--ask-vault-pass' not in ' '.join(args) assert '--vault-id dev@prompt' in ' '.join(args) assert '--vault-id prod@prompt' in ' '.join(args) @@ -935,9 +935,9 @@ class TestJobCredentials(TestJobExecution): (k.pattern, v) for k, v in call_kwargs['expect_passwords'].items() if 'Vault' in k.pattern ) - assert vault_passwords['Vault password \(prod\):\\s*?$'] == 'provided-at-launch@prod' - assert vault_passwords['Vault password \(dev\):\\s*?$'] == 'provided-at-launch@dev' - assert vault_passwords['Vault password:\\s*?$'] == '' + assert vault_passwords['Vault password \(prod\):\\s*?$'] == 'provided-at-launch@prod' # noqa + assert vault_passwords['Vault password \(dev\):\\s*?$'] == 'provided-at-launch@dev' # noqa + assert vault_passwords['Vault password:\\s*?$'] == '' # noqa assert '--ask-vault-pass' not in ' '.join(args) assert '--vault-id dev@prompt' in ' '.join(args) assert '--vault-id prod@prompt' in ' '.join(args) diff --git a/awx/main/utils/filters.py b/awx/main/utils/filters.py index 5e6d3f4221..eaf8c805b6 100644 --- a/awx/main/utils/filters.py +++ b/awx/main/utils/filters.py @@ -118,10 +118,10 @@ def string_to_type(t): elif t == u'false': return False - if re.search('^[-+]?[0-9]+$',t): + if re.search(r'^[-+]?[0-9]+$',t): return int(t) - if re.search('^[-+]?[0-9]+\.[0-9]+$',t): + if re.search(r'^[-+]?[0-9]+\.[0-9]+$',t): return float(t) return t diff --git a/awx/main/utils/safe_yaml.py b/awx/main/utils/safe_yaml.py index 28c4dc4694..8fe6cc9da1 100644 --- a/awx/main/utils/safe_yaml.py +++ b/awx/main/utils/safe_yaml.py @@ -78,10 +78,10 @@ def sanitize_jinja(arg): if isinstance(arg, six.string_types): # If the argument looks like it contains Jinja expressions # {{ x }} ... - if re.search('\{\{[^}]+}}', arg) is not None: + if re.search(r'\{\{[^}]+}}', arg) is not None: raise ValueError('Inline Jinja variables are not allowed.') # If the argument looks like it contains Jinja statements/control flow... # {% if x.foo() %} ... - if re.search('\{%[^%]+%}', arg) is not None: + if re.search(r'\{%[^%]+%}', arg) is not None: raise ValueError('Inline Jinja variables are not allowed.') return arg diff --git a/awx/plugins/library/scan_services.py b/awx/plugins/library/scan_services.py index 7b331a4abf..fee1464588 100644 --- a/awx/plugins/library/scan_services.py +++ b/awx/plugins/library/scan_services.py @@ -69,7 +69,7 @@ class ServiceScanService(BaseService): # Upstart if initctl_path is not None and chkconfig_path is None: - p = re.compile('^\s?(?P<name>.*)\s(?P<goal>\w+)\/(?P<state>\w+)(\,\sprocess\s(?P<pid>[0-9]+))?\s*$') + p = re.compile(r'^\s?(?P<name>.*)\s(?P<goal>\w+)\/(?P<state>\w+)(\,\sprocess\s(?P<pid>[0-9]+))?\s*$') rc, stdout, stderr = self.module.run_command("%s list" % initctl_path) real_stdout = stdout.replace("\r","") for line in real_stdout.split("\n"): @@ -90,8 +90,8 @@ class ServiceScanService(BaseService): elif chkconfig_path is not None: #print '%s --status-all | grep -E "is (running|stopped)"' % service_path p = re.compile( - '(?P<service>.*?)\s+[0-9]:(?P<rl0>on|off)\s+[0-9]:(?P<rl1>on|off)\s+[0-9]:(?P<rl2>on|off)\s+' - '[0-9]:(?P<rl3>on|off)\s+[0-9]:(?P<rl4>on|off)\s+[0-9]:(?P<rl5>on|off)\s+[0-9]:(?P<rl6>on|off)') + r'(?P<service>.*?)\s+[0-9]:(?P<rl0>on|off)\s+[0-9]:(?P<rl1>on|off)\s+[0-9]:(?P<rl2>on|off)\s+' + r'[0-9]:(?P<rl3>on|off)\s+[0-9]:(?P<rl4>on|off)\s+[0-9]:(?P<rl5>on|off)\s+[0-9]:(?P<rl6>on|off)') rc, stdout, stderr = self.module.run_command('%s' % chkconfig_path, use_unsafe_shell=True) # Check for special cases where stdout does not fit pattern match_any = False @@ -99,7 +99,7 @@ class ServiceScanService(BaseService): if p.match(line): match_any = True if not match_any: - p_simple = re.compile('(?P<service>.*?)\s+(?P<rl0>on|off)') + p_simple = re.compile(r'(?P<service>.*?)\s+(?P<rl0>on|off)') match_any = False for line in stdout.split('\n'): if p_simple.match(line): @@ -17,5 +17,5 @@ exclude=.tox,venv,awx/lib/site-packages,awx/plugins/inventory/ec2.py,awx/plugins [flake8] max-line-length=160 -ignore=E201,E203,E221,E225,E231,E241,E251,E261,E265,E303,W291,W391,W293,E731,F405 +ignore=E201,E203,E221,E225,E231,E241,E251,E261,E265,E303,W291,W391,W293,E731,F405,W504 exclude=.tox,venv,awx/lib/site-packages,awx/plugins/inventory,awx/ui,awx/api/urls.py,awx/main/migrations,awx/main/tests/data,node_modules/,awx/projects/,tools/docker,awx/settings/local_*.py,installer/openshift/settings.py,build/,installer/ |