Commit 5b1f1628 authored by Dmitry Volodin's avatar Dmitry Volodin Committed by Andrey Vertiprahov
Browse files

Remove python 3.7 support

parent 1e41a597
......@@ -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",
......
#
# 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,7 +20,7 @@ RUN \
apt update && apt-get install -y --no-install-recommends \
bzip2 \
curl \
libffi6 \
libffi7 \
libjemalloc2 \
libmemcached11 \
libpq-dev \
......
......@@ -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)
......
# -*- 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"
......@@ -20,7 +21,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<hostname>[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 +40,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"^(?P<type>XGE|GE|Eth|MEth)(?P<number>[\d/]+(\.\d+)?)$")
rx_interface_name = re.compile(r"^(?P<type>XGE|GE|Eth|MEth)(?P<number>[\d/]+(\.\d+)?)$")
def convert_interface_name(self, s):
"""
......@@ -56,13 +56,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):
"""
......@@ -71,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)
......
# 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*(# )?<?https?://\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*(# )?<?https?://\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']
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
# ----------------------------------------------------------------------
# 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
......
......@@ -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}
......@@ -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():
......
......@@ -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":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment