Commit a3168c7a authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'del_with_statement' into 'master'

del_with_statement

See merge request noc/noc!1981
parents 345f013e a42f7706
......@@ -2,12 +2,12 @@
# ---------------------------------------------------------------------
# Import data from CSV
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement, print_function
from __future__ import print_function
import argparse
import sys
# Django modules
......
......@@ -2,13 +2,12 @@
# ---------------------------------------------------------------------
# Inject event from JSON files
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
# Python modules
from __future__ import with_statement
from __future__ import print_function
import sys
import time
import json
......@@ -30,7 +29,7 @@ class Command(BaseCommand):
nargs=argparse.REMAINDER)
def _usage(self):
print "./noc inject-event <object name> [<file1> [ .. <fileN>]]"
print("./noc inject-event <object name> [<file1> [ .. <fileN>]]")
sys.exit(0)
def handle(self, *args, **options):
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# Cisco.NXOS.remove_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2009 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iremovevlan import IRemoveVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DES21xx.add_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iaddvlan import IAddVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DES21xx.remove_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iremovevlan import IRemoveVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DGS3100.add_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iaddvlan import IAddVlan
......
......@@ -6,8 +6,6 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iremovevlan import IRemoveVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DxS.add_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iaddvlan import IAddVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DxS.remove_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iremovevlan import IRemoveVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DxS_Cisco_CLI.remove_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iremovevlan import IRemoveVlan
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# DLink.DxS_Smart.get_interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2007-2014 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
import re
# NOC modules
from noc.core.script.base import BaseScript
......@@ -19,9 +18,9 @@ class Script(BaseScript):
name = "DLink.DxS_Smart.get_interfaces"
interface = IGetInterfaces
rx_ipif = re.compile(r"IP Address\s+:\s+(?P<ip_address>\S+)\s*\n"
r"Subnet Mask\s+:\s+(?P<ip_subnet>\S+)\s*\n",
re.IGNORECASE | re.MULTILINE | re.DOTALL)
rx_ipif = re.compile(
r"IP Address\s+:\s+(?P<ip_address>\S+)\s*\n"
r"Subnet Mask\s+:\s+(?P<ip_subnet>\S+)\s*\n", re.IGNORECASE | re.MULTILINE | re.DOTALL)
rx_mgmt_vlan = re.compile(
r"^802.1Q Management VLAN\s+: (?P<vlan>\S+)\s*\n")
......@@ -42,8 +41,7 @@ class Script(BaseScript):
for n, s in self.snmp.join_tables(
"1.3.6.1.2.1.31.1.1.1.1",
"1.3.6.1.2.1.2.2.1.7"): # IF-MIB
if n[:3] == 'Aux' or n[:4] == 'Vlan' \
or n[:11] == 'InLoopBack':
if n[:3] == 'Aux' or n[:4] == 'Vlan' or n[:11] == 'InLoopBack':
continue
else:
if n[:6] == "Slot0/":
......
......@@ -2,12 +2,10 @@
# ---------------------------------------------------------------------
# Eltex.MES.add_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2012 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iaddvlan import IAddVlan
......
......@@ -2,12 +2,10 @@
# ---------------------------------------------------------------------
# Eltex.MES.remove_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iremovevlan import IRemoveVlan
......
......@@ -2,12 +2,10 @@
# ---------------------------------------------------------------------
# Eltex.PON.add_vlan
# ---------------------------------------------------------------------
# Copyright (C) 2007-2014 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iaddvlan import IAddVlan
......@@ -48,15 +46,15 @@ class Script(BaseScript):
# Fallback to CLI
with self.profile.switch(self):
# with self.configure(): # Fix BUG...
self.cli("configure\r") # Fix BUG...
self.cli("vlan %d\r" % vlan_id)
if name:
self.cli("name %s\r" % name)
if tagged_ports:
for port in tagged_ports:
self.cli("tagged %s\r" % port)
self.cli("exit\r") # Fix BUG...
self.cli("exit\r") # Fix BUG...
# with self.configure(): # Fix BUG...
self.cli("configure\r") # Fix BUG...
self.cli("vlan %d\r" % vlan_id)
if name:
self.cli("name %s\r" % name)
if tagged_ports:
for port in tagged_ports:
self.cli("tagged %s\r" % port)
self.cli("exit\r") # Fix BUG...
self.cli("exit\r") # Fix BUG...
self.save_config()
return True
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# Eltex.PON.get_arp
# ---------------------------------------------------------------------
# Copyright (C) 2007-2014 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
import re
# NOC modules
from noc.core.script.base import BaseScript
......@@ -56,11 +55,11 @@ class Script(BaseScript):
"ip": match.group("ip"),
"mac": None,
"interface": None
})
})
else:
r.append({
"ip": match.group("ip"),
"mac": mac,
"interface": match.group("interface")
})
})
return r
......@@ -6,8 +6,6 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetconfig import IGetConfig
......
......@@ -2,12 +2,11 @@
# ---------------------------------------------------------------------
# Eltex.PON.get_vlans
# ---------------------------------------------------------------------
# Copyright (C) 2007-2014 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import with_statement
import re
# NOC modules
from noc.core.script.base import BaseScript
......@@ -26,13 +25,11 @@ class Script(BaseScript):
# Try snmp first
if self.has_snmp():
try:
for vlan, name in self.snmp.join_tables(
"1.3.6.1.2.1.17.7.1.4.3.1.5",
"1.3.6.1.2.1.17.7.1.4.3.1.1"):
for vlan, name in self.snmp.join_tables("1.3.6.1.2.1.17.7.1.4.3.1.5", "1.3.6.1.2.1.17.7.1.4.3.1.1"):
r.append({
"vlan_id": vlan,
"name": name
})
})
return r
except self.snmp.TimeOutError:
pass
......@@ -43,5 +40,5 @@ class Script(BaseScript):
r.append({
"vlan_id": int(match.group("vlan")),
"name": match.group("name")
})
})
return r
......@@ -2,11 +2,11 @@
# ---------------------------------------------------------------------
# Distutils setup.py
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
from __future__ import with_statement
# Python modules
from distutils.core import setup
import distutils.command.sdist
from distutils.command.install import INSTALL_SCHEMES
......@@ -27,6 +27,7 @@ def get_version():
with open("VERSION") as f:
return f.read().strip()
MANIFEST = []
......@@ -39,8 +40,7 @@ def get_manifest():
if not MANIFEST:
if os.path.exists(".hg"):
# Rebuild MANIFEST file every time mercurial repo found
proc = subprocess.Popen(["hg", "locate"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc = subprocess.Popen(["hg", "locate"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
mf = stdout.splitlines()
if os.path.exists(".hgsub"):
......@@ -50,8 +50,7 @@ def get_manifest():
continue
sr, r = l.split("=", 1)
sr = sr.strip()
proc = subprocess.Popen(["hg", "-R", sr, "locate"],
stdout=subprocess.PIPE,
proc = subprocess.Popen(["hg", "-R", sr, "locate"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
mf += [sr + "/" + x for x in stdout.splitlines()]
......@@ -98,6 +97,8 @@ class noc_sdist(distutils.command.sdist.sdist):
#
# Monkeypatch distutils to install noc to the desired location
#
for scheme in INSTALL_SCHEMES.values():
scheme["purelib"] = PREFIX
scheme["data"] = PREFIX
......
Supports Markdown
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