first pass at removing all python2 specific dependencies, updating python requirements.txt/setup.py/Pipfiles/Makefiles, and removing python2 compat imports
This commit is contained in:
parent
5d5ffb70c2
commit
6edd6a7fdb
13 changed files with 89 additions and 143 deletions
|
@ -9,8 +9,6 @@ import socket
|
|||
import struct
|
||||
from enum import Enum
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
from core.api.tlv import structutils
|
||||
from core.emulator.enumerations import (
|
||||
ConfigTlvs,
|
||||
|
@ -181,7 +179,7 @@ class CoreTlvDataString(CoreTlvData):
|
|||
:return: length of data packed and the packed data
|
||||
:rtype: tuple
|
||||
"""
|
||||
if not isinstance(value, basestring):
|
||||
if not isinstance(value, str):
|
||||
raise ValueError("value not a string: %s" % type(value))
|
||||
value = value.encode("utf-8")
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ Utilities for working with python struct data.
|
|||
|
||||
import logging
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
|
||||
def pack_values(clazz, packers):
|
||||
"""
|
||||
|
@ -31,7 +29,7 @@ def pack_values(clazz, packers):
|
|||
|
||||
# only pack actual values and avoid packing empty strings
|
||||
# protobuf defaults to empty strings and does no imply a value to set
|
||||
if value is None or (isinstance(value, basestring) and not value):
|
||||
if value is None or (isinstance(value, str) and not value):
|
||||
continue
|
||||
|
||||
# transform values as needed
|
||||
|
|
|
@ -7,7 +7,6 @@ import os
|
|||
from builtins import int
|
||||
|
||||
from lxml import etree
|
||||
from past.builtins import basestring
|
||||
|
||||
from core.config import ConfigGroup
|
||||
from core.emane import emanemanifest, emanemodel
|
||||
|
@ -26,7 +25,7 @@ def convert_none(x):
|
|||
"""
|
||||
Helper to use 0 for None values.
|
||||
"""
|
||||
if isinstance(x, basestring):
|
||||
if isinstance(x, str):
|
||||
x = float(x)
|
||||
if x is None:
|
||||
return 0
|
||||
|
|
|
@ -5,8 +5,7 @@ event.py: event loop implementation using a heap queue and threads.
|
|||
import heapq
|
||||
import threading
|
||||
import time
|
||||
|
||||
from past.builtins import cmp
|
||||
from functools import total_ordering
|
||||
|
||||
|
||||
class Timer(threading.Thread):
|
||||
|
@ -70,6 +69,7 @@ class Timer(threading.Thread):
|
|||
self.finished.set()
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Event(object):
|
||||
"""
|
||||
Provides event objects that can be used within the EventLoop class.
|
||||
|
@ -92,18 +92,11 @@ class Event(object):
|
|||
self.kwds = kwds
|
||||
self.canceled = False
|
||||
|
||||
def __cmp__(self, other):
|
||||
"""
|
||||
Comparison function.
|
||||
|
||||
:param Event other: event to compare with
|
||||
:return: comparison result
|
||||
:rtype: int
|
||||
"""
|
||||
tmp = cmp(self.time, other.time)
|
||||
if tmp == 0:
|
||||
tmp = cmp(self.eventnum, other.eventnum)
|
||||
return tmp
|
||||
def __lt__(self, other):
|
||||
result = self.time < other.time
|
||||
if result:
|
||||
result = self.eventnum < other.eventnum
|
||||
return result
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
|
|
|
@ -4,8 +4,7 @@ sdt.py: Scripted Display Tool (SDT3D) helper
|
|||
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from future.moves.urllib.parse import urlparse
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from core import constants
|
||||
from core.emane.nodes import EmaneNet
|
||||
|
|
|
@ -3,8 +3,6 @@ nrl.py: defines services provided by NRL protolib tools hosted here:
|
|||
http://www.nrl.navy.mil/itd/ncs/products
|
||||
"""
|
||||
|
||||
from past.builtins import filter
|
||||
|
||||
from core import utils
|
||||
from core.nodes.ipaddress import Ipv4Prefix
|
||||
from core.services.coreservices import CoreService
|
||||
|
@ -94,7 +92,7 @@ class NrlNhdp(NrlService):
|
|||
cmd += " -flooding ecds"
|
||||
cmd += " -smfClient %s_smf" % node.name
|
||||
|
||||
netifs = filter(lambda x: not getattr(x, "control", False), node.netifs())
|
||||
netifs = list(filter(lambda x: not getattr(x, "control", False), node.netifs()))
|
||||
if len(netifs) > 0:
|
||||
interfacenames = map(lambda x: x.name, netifs)
|
||||
cmd += " -i "
|
||||
|
@ -128,7 +126,7 @@ class NrlSmf(NrlService):
|
|||
cmd = "nrlsmf instance %s_smf" % node.name
|
||||
|
||||
servicenames = map(lambda x: x.name, node.services)
|
||||
netifs = filter(lambda x: not getattr(x, "control", False), node.netifs())
|
||||
netifs = list(filter(lambda x: not getattr(x, "control", False), node.netifs()))
|
||||
if len(netifs) == 0:
|
||||
return ""
|
||||
|
||||
|
@ -218,7 +216,7 @@ class NrlOlsrv2(NrlService):
|
|||
|
||||
cmd += " -p olsr"
|
||||
|
||||
netifs = filter(lambda x: not getattr(x, "control", False), node.netifs())
|
||||
netifs = list(filter(lambda x: not getattr(x, "control", False), node.netifs()))
|
||||
if len(netifs) > 0:
|
||||
interfacenames = map(lambda x: x.name, netifs)
|
||||
cmd += " -i "
|
||||
|
@ -246,7 +244,7 @@ class OlsrOrg(NrlService):
|
|||
Generate the appropriate command-line based on node interfaces.
|
||||
"""
|
||||
cmd = cls.startup[0]
|
||||
netifs = filter(lambda x: not getattr(x, "control", False), node.netifs())
|
||||
netifs = list(filter(lambda x: not getattr(x, "control", False), node.netifs()))
|
||||
if len(netifs) > 0:
|
||||
interfacenames = map(lambda x: x.name, netifs)
|
||||
cmd += " -i "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue