From e2fb45fcd4a2a5251f4c35fa2abe7505fd92b53f Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Tue, 23 Nov 2021 09:45:34 +0100 Subject: [PATCH 1/3] Remove py3.7 support --- .devcontainer/devcontainer.json | 6 +- Dockerfile | 9 +- commands/sync-doc.py | 8 +- .../background/sa-profile/images/__init__.py | 22 +- pyproject.toml | 234 +++++++++--------- requirements.txt | 6 +- services/correlator/models/clearreq.py | 8 +- services/correlator/models/ensuregroupreq.py | 8 +- services/correlator/models/eventreq.py | 7 +- services/correlator/models/raisereq.py | 8 +- services/login/models/token.py | 9 +- services/mib/paths/jsonrpc_mib.py | 11 +- .../web/apps/fm/reporteventsummary/views.py | 2 +- services/web/apps/sa/objectlist/views.py | 10 +- 14 files changed, 160 insertions(+), 188 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 45012916b4..25332c0b5d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,7 +14,11 @@ "target": "dev" }, // Set *default* container specific settings.json values on container create. - "settings": {}, + "settings": { + "python.formatting.blackPath": "/usr/local/bin/black", + "python.formatting.provider": "black", + "python.pythonPath": "/usr/local/bin/python" + }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-python.python", diff --git a/Dockerfile b/Dockerfile index 498e00504b..5a17d3f4e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ # # Base layer containing system packages and requirements # -FROM python:3.8.12-slim-buster AS code +FROM python:3.9.9-slim-bullseye AS code ENV\ DJANGO_SETTINGS_MODULE=noc.settings \ NOC_THREAD_STACK_SIZE=524288 \ NOC_PYTHON_INTERPRETER=/usr/local/bin/python3 \ NOC_LISTEN="auto:1200" \ - PYTHONPATH=/opt/noc:/opt:/usr/local/bin/python3.8 \ + PYTHONPATH=/opt/noc:/opt:/usr/local/bin/python3.9 \ PROJ_DIR=/usr \ IP_SO="build/rust/release/libip.so" @@ -20,13 +20,12 @@ RUN \ apt update && apt-get install -y --no-install-recommends \ bzip2 \ curl \ - libffi6 \ + libffi7 \ libjemalloc2 \ - libmemcached11 \ libpq-dev \ $BUILD_PACKAGES \ && pip3 install --upgrade pip \ - && (./scripts/build/get-noc-requirements.py activator classifier cache-memcached cache-redis login-ldap login-pam login-radius prod-tools cython testing sender-kafka | pip3 install -r /dev/stdin )\ + && (./scripts/build/get-noc-requirements.py activator classifier cache-redis login-ldap login-pam login-radius prod-tools cython testing sender-kafka | pip3 install -r /dev/stdin )\ && python3 ./scripts/deploy/install-packages requirements/web.json \ && python3 ./scripts/deploy/install-packages requirements/card.json \ && python3 ./scripts/deploy/install-packages requirements/bi.json \ diff --git a/commands/sync-doc.py b/commands/sync-doc.py index 4979805b55..4a5a130f19 100644 --- a/commands/sync-doc.py +++ b/commands/sync-doc.py @@ -93,7 +93,7 @@ class Command(BaseCommand): return h + "\n" + ["=", "-", "~"][level] * len(h) + "\n" def path_to_mod(f): - """ Convert file path to module name""" + """Convert file path to module name""" if f.endswith(INIT): f = f[:-12] else: @@ -101,13 +101,13 @@ class Command(BaseCommand): return "noc." + f.replace(os.sep, ".") def path_to_doc(f): - """ Convert path fo RST file name""" + """Convert path fo RST file name""" if f == INIT: return "index.rst" return path_to_mod(f) + ".rst" def package_doc(f): - """ Generate package doc""" + """Generate package doc""" m = path_to_mod(f) r = header(":mod:`%s` Package" % m) r += ".. automodule:: %s\n :members:\n\n" % m @@ -127,7 +127,7 @@ class Command(BaseCommand): return r def package_files(f): - """ Return a list of package files""" + """Return a list of package files""" def is_child(ff): pp = ff.split(os.sep) diff --git a/docs/ru/docs/dev/background/sa-profile/images/__init__.py b/docs/ru/docs/dev/background/sa-profile/images/__init__.py index 4e62268287..19c8548a08 100644 --- a/docs/ru/docs/dev/background/sa-profile/images/__init__.py +++ b/docs/ru/docs/dev/background/sa-profile/images/__init__.py @@ -20,7 +20,7 @@ class Profile(BaseProfile): (r"[Cc]onfirm?\S+", "y\n\r"), (r" [Aa]re you sure?\S+", "y\n\r"), (r"^Delete flash:", "y\n\r"), - (r"^Squeeze flash:", "y\n\r") + (r"^Squeeze flash:", "y\n\r"), ] pattern_prompt = r"^[<#\[](?P[a-zA-Z0-9-_\.\[/`\s]+)(?:-[a-zA-Z0-9/]+)*[>#\]]" pattern_syntax_error = r"(Error: |% Wrong parameter found at|% Unrecognized command found at|Error:Too many parameters found|% Too many parameters found at|% Ambiguous command found at)" @@ -39,8 +39,7 @@ class Profile(BaseProfile): p += " le 32" return "undo ip ip-prefix %s\n" % name + "\n".join([p % x.replace("/", " ") for x in pl]) - rx_interface_name = re.compile( - r"^(?PXGE|GE|Eth|MEth)(?P[\d/]+(\.\d+)?)$") + rx_interface_name = re.compile(r"^(?PXGE|GE|Eth|MEth)(?P[\d/]+(\.\d+)?)$") def convert_interface_name(self, s): """ @@ -56,13 +55,16 @@ class Profile(BaseProfile): match = self.rx_interface_name.match(s) if not match: return s - return "%s%s" % ({ - "XGE": "XGigabitEthernet", - "GE": "GigabitEthernet", - "Eth": "Ethernet", - "MEth": "M-Ethernet", - # "Vlanif": "Vlan-interface" - need testing - }[match.group("type")], match.group("number")) + return "%s%s" % ( + { + "XGE": "XGigabitEthernet", + "GE": "GigabitEthernet", + "Eth": "Ethernet", + "MEth": "M-Ethernet", + # "Vlanif": "Vlan-interface" - need testing + }[match.group("type")], + match.group("number"), + ) def convert_mac(self, mac): """ diff --git a/pyproject.toml b/pyproject.toml index b1d45d6488..76705dcadd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ # Black section [tool.black] line-length = 100 -target-version = ['py37'] +target-version = ['py39'] [tool.coverage.run] omit = ['*tests*'] @@ -11,118 +11,120 @@ ignore_errors = true # Pylint section [tool.pylint] - [tool.pylint.master] - ignore=['CVS'] - jobs=0 - persistent=['yes'] - unsafe-load-any-extension=['no'] - - [tool.pylint.'MESSAGES CONTROL'] - disable=['all'] - enable=['old-ne-operator,old-octal-literal,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,unichr-builtin,C0203,C0204,C0303,C0304,C0321,C0325,C1001,E0001,E0101,E0104,E0105,E0108,E0213,E0601,E0602,E0701,E0710,E0711,E0712,E1001-E1004,E1121,E1122,E1200,E1201,E1205,E1206,E1300-E1306,W0101,W0104,W0107,W0109,W0231,W0401'] - - [tool.pylint.'REPORTS'] - evaluation=['10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)'] - output-format=['text'] - reports=['no'] - score=['yes'] - - [tool.pylint.'REFACTORING'] - max-nested-blocks=5 - - [tool.pylint.'MISCELLANEOUS'] - notes=['FIXME,XXX,TODO'] - - [tool.pylint.'TYPECHECK'] - contextmanager-decorators=['contextlib.contextmanager'] - ignore-mixin-members=['yes'] - ignore-on-opaque-inference=['yes'] - ignored-classes=['optparse.Values,thread._local,_thread._local'] - missing-member-hint=['yes'] - missing-member-hint-distance=1 - missing-member-max-choices=1 - - [tool.pylint.'FORMAT'] - ignore-long-lines=['^\s*(# )??$'] - indent-after-paren=4 - indent-string=' ' - max-line-length=100 - max-module-lines=1000 - no-space-check=['trailing-comma,dict-separator'] - single-line-class-stmt=['no'] - single-line-if-stmt=['no'] - - [tool.pylint.'LOGGING'] - logging-modules=['logging'] - - [tool.pylint.'BASIC'] - argument-name-hint=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - argument-rgx=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - attr-name-hint=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - attr-rgx=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - bad-names=['foo,bar,baz,toto,tutu,tata'] - class-attribute-name-hint=['([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$'] - class-attribute-rgx=['([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$'] - class-name-hint=['[A-Z_][a-zA-Z0-9]+$'] - class-rgx=['[A-Z_][a-zA-Z0-9]+$'] - const-name-hint=['(([A-Z_][A-Z0-9_]*)|(__.*__))$'] - const-rgx=['(([A-Z_][A-Z0-9_]*)|(__.*__))$'] - docstring-min-length=-1 - function-name-hint=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - function-rgx=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - good-names=['i,j,k,ex,Run,_,x,y,o,id'] - include-naming-hint=['no'] - inlinevar-name-hint=['[A-Za-z_][A-Za-z0-9_]*$'] - inlinevar-rgx=['[A-Za-z_][A-Za-z0-9_]*$'] - method-name-hint=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - method-rgx=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - module-name-hint=['(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$'] - module-rgx=['(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$'] - no-docstring-rgx=['^_'] - property-classes=['abc.abstractproperty'] - variable-name-hint=['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - variable-rgx=['(([^lO])|([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] - - [tool.pylint.'VARIABLES'] - allow-global-unused-variables=['yes'] - callbacks=['cb_,_cb'] - dummy-variables-rgx=['_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_'] - ignored-argument-names=['_.*|^ignored_|^unused_'] - init-import=['no'] - redefining-builtins-modules=['six.moves,future.builtins'] - - [tool.pylint.'SIMILARITIES'] - ignore-comments=['yes'] - ignore-docstrings=['yes'] - ignore-imports=['no'] - min-similarity-lines=4 - - [tool.pylint.'SPELLING'] - spelling-store-unknown-words=['no'] - - [tool.pylint.'DESIGN'] - max-args=5 - max-attributes=7 - max-bool-expr=5 - max-branches=12 - max-locals=15 - max-parents=7 - max-public-methods=20 - max-returns=6 - max-statements=50 - min-public-methods=2 - - [tool.pylint.'IMPORTS'] - allow-wildcard-with-all=['no'] - analyse-fallback-blocks=['no'] - deprecated-modules=['regsub,TERMIOS,Bastion,rexec'] - known-third-party=['enchant'] - - [tool.pylint.'CLASSES'] - defining-attr-methods=['__init__,__new__,setUp'] - exclude-protected=['_asdict,_fields,_replace,_source,_make'] - valid-classmethod-first-arg=['cls'] - valid-metaclass-classmethod-first-arg=['mcs'] - - [tool.pylint.'EXCEPTIONS'] - overgeneral-exceptions=['Exception'] +[tool.pylint.master] +ignore = ['CVS'] +jobs = 0 +persistent = ['yes'] +unsafe-load-any-extension = ['no'] + +[tool.pylint.'MESSAGES CONTROL'] +disable = ['all'] +enable = [ + 'old-ne-operator,old-octal-literal,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,unichr-builtin,C0203,C0204,C0303,C0304,C0321,C0325,C1001,E0001,E0101,E0104,E0105,E0108,E0213,E0601,E0602,E0701,E0710,E0711,E0712,E1001-E1004,E1121,E1122,E1200,E1201,E1205,E1206,E1300-E1306,W0101,W0104,W0107,W0109,W0231,W0401', +] + +[tool.pylint.'REPORTS'] +evaluation = ['10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)'] +output-format = ['text'] +reports = ['no'] +score = ['yes'] + +[tool.pylint.'REFACTORING'] +max-nested-blocks = 5 + +[tool.pylint.'MISCELLANEOUS'] +notes = ['FIXME,XXX,TODO'] + +[tool.pylint.'TYPECHECK'] +contextmanager-decorators = ['contextlib.contextmanager'] +ignore-mixin-members = ['yes'] +ignore-on-opaque-inference = ['yes'] +ignored-classes = ['optparse.Values,thread._local,_thread._local'] +missing-member-hint = ['yes'] +missing-member-hint-distance = 1 +missing-member-max-choices = 1 + +[tool.pylint.'FORMAT'] +ignore-long-lines = ['^\s*(# )??$'] +indent-after-paren = 4 +indent-string = ' ' +max-line-length = 100 +max-module-lines = 1000 +no-space-check = ['trailing-comma,dict-separator'] +single-line-class-stmt = ['no'] +single-line-if-stmt = ['no'] + +[tool.pylint.'LOGGING'] +logging-modules = ['logging'] + +[tool.pylint.'BASIC'] +argument-name-hint = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +argument-rgx = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +attr-name-hint = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +attr-rgx = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +bad-names = ['foo,bar,baz,toto,tutu,tata'] +class-attribute-name-hint = ['([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$'] +class-attribute-rgx = ['([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$'] +class-name-hint = ['[A-Z_][a-zA-Z0-9]+$'] +class-rgx = ['[A-Z_][a-zA-Z0-9]+$'] +const-name-hint = ['(([A-Z_][A-Z0-9_]*)|(__.*__))$'] +const-rgx = ['(([A-Z_][A-Z0-9_]*)|(__.*__))$'] +docstring-min-length = -1 +function-name-hint = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +function-rgx = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +good-names = ['i,j,k,ex,Run,_,x,y,o,id'] +include-naming-hint = ['no'] +inlinevar-name-hint = ['[A-Za-z_][A-Za-z0-9_]*$'] +inlinevar-rgx = ['[A-Za-z_][A-Za-z0-9_]*$'] +method-name-hint = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +method-rgx = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +module-name-hint = ['(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$'] +module-rgx = ['(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$'] +no-docstring-rgx = ['^_'] +property-classes = ['abc.abstractproperty'] +variable-name-hint = ['(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] +variable-rgx = ['(([^lO])|([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$'] + +[tool.pylint.'VARIABLES'] +allow-global-unused-variables = ['yes'] +callbacks = ['cb_,_cb'] +dummy-variables-rgx = ['_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_'] +ignored-argument-names = ['_.*|^ignored_|^unused_'] +init-import = ['no'] +redefining-builtins-modules = ['six.moves,future.builtins'] + +[tool.pylint.'SIMILARITIES'] +ignore-comments = ['yes'] +ignore-docstrings = ['yes'] +ignore-imports = ['no'] +min-similarity-lines = 4 + +[tool.pylint.'SPELLING'] +spelling-store-unknown-words = ['no'] + +[tool.pylint.'DESIGN'] +max-args = 5 +max-attributes = 7 +max-bool-expr = 5 +max-branches = 12 +max-locals = 15 +max-parents = 7 +max-public-methods = 20 +max-returns = 6 +max-statements = 50 +min-public-methods = 2 + +[tool.pylint.'IMPORTS'] +allow-wildcard-with-all = ['no'] +analyse-fallback-blocks = ['no'] +deprecated-modules = ['regsub,TERMIOS,Bastion,rexec'] +known-third-party = ['enchant'] + +[tool.pylint.'CLASSES'] +defining-attr-methods = ['__init__,__new__,setUp'] +exclude-protected = ['_asdict,_fields,_replace,_source,_make'] +valid-classmethod-first-arg = ['cls'] +valid-metaclass-classmethod-first-arg = ['mcs'] + +[tool.pylint.'EXCEPTIONS'] +overgeneral-exceptions = ['Exception'] diff --git a/requirements.txt b/requirements.txt index 7d863fc6a2..b6c853b3e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ atomicl==0.1.1 asgiref>=3.4.0 blinker==1.4 bsdiff4==1.2.1 -cachetools==4.2.1 +cachetools==4.2.4 crontab==0.22.9 csiphash==0.0.5 demjson==2.2.4 @@ -61,7 +61,6 @@ pytz==2021.1 requests==2.26.0 setproctitle==1.2.2 tornado==6.0.4 -typing-extensions==3.10.0.2; python_version < '3.8' uvicorn==0.15.0 yappi==1.3.3 # Activator requirements @@ -75,12 +74,13 @@ redis==3.5.3; extra == "cache-redis" pylibmc==1.5.1; extra == "cache-memcached" # Dev requirements Babel==2.3.4; extra == "dev" -ipython==7.18.1; extra == "dev" +ipython==7.29.0; extra == "dev" pojson==0.7; extra == "dev" flake8==4.0.1; extra == "dev" mypy==0.910; extra == "dev" black==21.9b0; extra == "dev" mongo-types==0.14.2; extra == "dev" +types-cachetools==4.2.4; extra == "dev" # Login LDAP ldap3==2.8.1; extra == "login-ldap" # Login PAM diff --git a/services/correlator/models/clearreq.py b/services/correlator/models/clearreq.py index 9b3bed88d2..29a9a5435b 100644 --- a/services/correlator/models/clearreq.py +++ b/services/correlator/models/clearreq.py @@ -6,13 +6,7 @@ # --------------------------------------------------------------------- # Python modules -from typing import Optional - -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal # py3.7 support - +from typing import Optional, Literal # Third-party modules from pydantic import BaseModel, Field diff --git a/services/correlator/models/ensuregroupreq.py b/services/correlator/models/ensuregroupreq.py index fc3de0393e..70c3838a1f 100644 --- a/services/correlator/models/ensuregroupreq.py +++ b/services/correlator/models/ensuregroupreq.py @@ -6,13 +6,7 @@ # --------------------------------------------------------------------- # Python modules -from typing import Optional, Dict, Any, List - -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal # py3.7 support - +from typing import Optional, Dict, Any, List, Literal # Third-party modules from pydantic import BaseModel, Field diff --git a/services/correlator/models/eventreq.py b/services/correlator/models/eventreq.py index 766abf131a..19c8740fdf 100644 --- a/services/correlator/models/eventreq.py +++ b/services/correlator/models/eventreq.py @@ -6,12 +6,7 @@ # --------------------------------------------------------------------- # Python modules - -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal # py3.7 support - +from typing import Literal # Third-party modules from pydantic import BaseModel, Field diff --git a/services/correlator/models/raisereq.py b/services/correlator/models/raisereq.py index 47583b1e56..79eb8baec1 100644 --- a/services/correlator/models/raisereq.py +++ b/services/correlator/models/raisereq.py @@ -6,13 +6,7 @@ # --------------------------------------------------------------------- # Python modules -from typing import Optional, Dict, Any, List - -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal # py3.7 support - +from typing import Optional, Dict, Any, List, Literal # Third-party modules from pydantic import BaseModel, Field diff --git a/services/login/models/token.py b/services/login/models/token.py index 30165000b4..7443376ef2 100644 --- a/services/login/models/token.py +++ b/services/login/models/token.py @@ -1,17 +1,12 @@ # ---------------------------------------------------------------------- # TokenResponse # ---------------------------------------------------------------------- -# Copyright (C) 2007-2020 The NOC Project +# Copyright (C) 2007-2021 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- # Python modules -from typing import Optional, Union - -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal # py3.7 support +from typing import Optional, Union, Literal # Third-party modules from pydantic import BaseModel diff --git a/services/mib/paths/jsonrpc_mib.py b/services/mib/paths/jsonrpc_mib.py index 4d32e6b3fc..8c435395e0 100644 --- a/services/mib/paths/jsonrpc_mib.py +++ b/services/mib/paths/jsonrpc_mib.py @@ -22,10 +22,7 @@ router = APIRouter() @router.post("/api/mib") def api_mib(req: JSONRemoteProcedureCall): if req.method not in MIBAPI.get_methods(): - return { - "error": f"Invalid method: '{req.method}'", - "id": req.id - } + return {"error": f"Invalid method: '{req.method}'", "id": req.id} service = get_service() api = MIBAPI(service, None, None) api_method = getattr(api, req.method) @@ -38,8 +35,4 @@ def api_mib(req: JSONRemoteProcedureCall): except Exception as e: error_report() error = f"Failed: {e}" - return { - "result": result, - "error": error, - "id": req.id - } + return {"result": result, "error": error, "id": req.id} diff --git a/services/web/apps/fm/reporteventsummary/views.py b/services/web/apps/fm/reporteventsummary/views.py index 4e118c9004..e15221653f 100644 --- a/services/web/apps/fm/reporteventsummary/views.py +++ b/services/web/apps/fm/reporteventsummary/views.py @@ -36,7 +36,7 @@ class EventSummaryReport(SimpleReport): @staticmethod def get_by_event_class(): - """ Summary by event class """ + """Summary by event class""" c = ActiveEvent.objects.item_frequencies("event_class") r = [] for k, v in c.items(): diff --git a/services/web/apps/sa/objectlist/views.py b/services/web/apps/sa/objectlist/views.py index 9811e1200d..ca3b61b2d2 100644 --- a/services/web/apps/sa/objectlist/views.py +++ b/services/web/apps/sa/objectlist/views.py @@ -18,7 +18,7 @@ from noc.inv.models.capability import Capability from noc.sa.interfaces.base import ListOfParameter, IPv4Parameter, DictParameter from noc.sa.models.useraccess import UserAccess -JP_CLAUSE_PATTERN = 'jsonb_path_exists(caps, \'$[*] ? (@.capability == "{}") ? (@.value {} {})\')' +JP_CLAUSE_PATTERN = "jsonb_path_exists(caps, '$[*] ? (@.capability == \"{}\") ? (@.value {} {})')" class ObjectListApplication(ExtApplication): @@ -94,13 +94,13 @@ class ObjectListApplication(ExtApplication): if "~" in c_query: l, r = c_query.split("~") if not l: - jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, '<=', r)) + jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, "<=", r)) elif not r: - jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, '>=', l)) + jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, ">=", l)) else: # TODO This functionality is not implemented in frontend - jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, '<=', r)) - jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, '>=', l)) + jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, "<=", r)) + jp_clauses.append(JP_CLAUSE_PATTERN.format(caps.id, ">=", l)) elif c_query in ("false", "true"): q &= d_Q(caps__contains=[{"capability": str(caps.id), "value": c_query == "true"}]) elif c_query == "exists": -- GitLab From afa3fd80ebf8d542a7b37542ededaead81e663b8 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Tue, 23 Nov 2021 09:53:38 +0100 Subject: [PATCH 2/3] Fix --- .../background/sa-profile/images/__init__.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/ru/docs/dev/background/sa-profile/images/__init__.py b/docs/ru/docs/dev/background/sa-profile/images/__init__.py index 19c8548a08..3362c9a961 100644 --- a/docs/ru/docs/dev/background/sa-profile/images/__init__.py +++ b/docs/ru/docs/dev/background/sa-profile/images/__init__.py @@ -1,16 +1,17 @@ -# -*- coding: utf-8 -*- -""" -##---------------------------------------------------------------------- -## Vendor: Huawei -## OS: VRP -##---------------------------------------------------------------------- -## Copyright (C) 2007-2014 The NOC Project -## See LICENSE for details -##---------------------------------------------------------------------- -""" -from noc.core.profile.base import BaseProfile +# ---------------------------------------------------------------------- +# Vendor: Huawei +# OS: VRP +# ---------------------------------------------------------------------- +# Copyright (C) 2007-2014 The NOC Project +# See LICENSE for details +# ---------------------------------------------------------------------- + +# Python modules import re +# NOC modules +from noc.core.profile.base import BaseProfile + class Profile(BaseProfile): name = "Huawei.VRP" @@ -73,7 +74,7 @@ class Profile(BaseProfile): v = mac.replace(":", "").lower() return "%s-%s-%s" % (v[:4], v[4:8], v[8:]) - spaces_rx = re.compile("^\s{42}|^\s{16}", re.DOTALL | re.MULTILINE) + spaces_rx = re.compile(r"^\s{42}|^\s{16}", re.DOTALL | re.MULTILINE) def clean_spaces(self, config): config = self.spaces_rx.sub("", config) -- GitLab From 280dc0985cf2d3db196a2128880cbbb08d91896e Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Tue, 23 Nov 2021 12:23:58 +0100 Subject: [PATCH 3/3] Fix --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5a17d3f4e3..9d1fc585af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,11 @@ RUN \ curl \ libffi7 \ libjemalloc2 \ + libmemcached11 \ libpq-dev \ $BUILD_PACKAGES \ && pip3 install --upgrade pip \ - && (./scripts/build/get-noc-requirements.py activator classifier cache-redis login-ldap login-pam login-radius prod-tools cython testing sender-kafka | pip3 install -r /dev/stdin )\ + && (./scripts/build/get-noc-requirements.py activator classifier cache-memcached cache-redis login-ldap login-pam login-radius prod-tools cython testing sender-kafka | pip3 install -r /dev/stdin )\ && python3 ./scripts/deploy/install-packages requirements/web.json \ && python3 ./scripts/deploy/install-packages requirements/card.json \ && python3 ./scripts/deploy/install-packages requirements/bi.json \ -- GitLab