diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 7cec9010..2c8f4f0a 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -4,17 +4,18 @@ import os import tempfile import time from Queue import Queue, Empty +from builtins import int import grpc from concurrent import futures -from core.emulator.emudata import NodeOptions, InterfaceData, LinkOptions -from core.emulator.enumerations import NodeTypes, EventTypes, LinkTypes from core.api.grpc import core_pb2 from core.api.grpc import core_pb2_grpc +from core.emulator.emudata import NodeOptions, InterfaceData, LinkOptions +from core.emulator.enumerations import NodeTypes, EventTypes, LinkTypes +from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility from core.nodes import nodeutils from core.nodes.ipaddress import MacAddress -from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility from core.services.coreservices import ServiceManager _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/daemon/core/api/tlv/coreapi.py b/daemon/core/api/tlv/coreapi.py index afc35a11..4a556ade 100644 --- a/daemon/core/api/tlv/coreapi.py +++ b/daemon/core/api/tlv/coreapi.py @@ -788,7 +788,7 @@ class CoreMessage(object): :rtype: str """ message_flags = [] - flag = 1L + flag = 1 while True: if self.flags & flag: diff --git a/daemon/core/location/mobility.py b/daemon/core/location/mobility.py index 2890e9c2..f627a0a7 100644 --- a/daemon/core/location/mobility.py +++ b/daemon/core/location/mobility.py @@ -8,12 +8,13 @@ import math import os import threading import time +from builtins import int +from core import utils from core.config import ConfigGroup from core.config import ConfigurableOptions from core.config import Configuration from core.config import ModelManager -from core.nodes.base import CoreNodeBase from core.emulator.data import EventData from core.emulator.data import LinkData from core.emulator.enumerations import ConfigDataTypes @@ -23,7 +24,7 @@ from core.emulator.enumerations import MessageFlags from core.emulator.enumerations import MessageTypes from core.emulator.enumerations import NodeTlvs from core.emulator.enumerations import RegisterTlvs -from core import utils +from core.nodes.base import CoreNodeBase from core.nodes.ipaddress import IpAddress diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 49e54a99..06c6a735 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -559,7 +559,6 @@ class CoreNode(CoreNodeBase): finally: self.rmnodedir() - def cmd(self, args, wait=True): """ Runs shell command on node, with option to not wait for a result. @@ -928,10 +927,10 @@ class CoreNode(CoreNodeBase): hostfilename = self.hostfilename(filename) dirname, _basename = os.path.split(hostfilename) if not os.path.isdir(dirname): - os.makedirs(dirname, mode=0755) + os.makedirs(dirname, mode=0o755) return open(hostfilename, mode) - def nodefile(self, filename, contents, mode=0644): + def nodefile(self, filename, contents, mode=0o644): """ Create a node file with a given mode. diff --git a/daemon/core/nodes/interface.py b/daemon/core/nodes/interface.py index 855d8dfd..1b628408 100644 --- a/daemon/core/nodes/interface.py +++ b/daemon/core/nodes/interface.py @@ -4,6 +4,7 @@ virtual ethernet classes that implement the interfaces available under Linux. import logging import time +from builtins import int from builtins import range from core import CoreCommandError, utils diff --git a/daemon/core/nodes/ipaddress.py b/daemon/core/nodes/ipaddress.py index a378631a..864b0296 100644 --- a/daemon/core/nodes/ipaddress.py +++ b/daemon/core/nodes/ipaddress.py @@ -44,12 +44,12 @@ class MacAddress(object): if not self.addr: return IpAddress.from_string("::") tmp = struct.unpack("!Q", "\x00\x00" + self.addr)[0] - nic = long(tmp) & 0x000000FFFFFFL - oui = long(tmp) & 0xFFFFFF000000L + nic = long(tmp) & 0x000000FFFFFF + oui = long(tmp) & 0xFFFFFF000000 # toggle U/L bit - oui ^= 0x020000000000L + oui ^= 0x020000000000 # append EUI-48 octets - oui = (oui << 16) | 0xFFFE000000L + oui = (oui << 16) | 0xFFFE000000 return IpAddress(AF_INET6, struct.pack("!QQ", 0xfe80 << 48, oui | nic)) @classmethod @@ -234,7 +234,7 @@ class IpPrefix(object): self.prefix = socket.inet_pton(self.af, tmp[0]) if self.addrlen > self.prefixlen: addrbits = self.addrlen - self.prefixlen - netmask = ((1L << self.prefixlen) - 1) << addrbits + netmask = ((1 << self.prefixlen) - 1) << addrbits prefix = "" for i in range(-1, -(addrbits >> 3) - 2, -1): prefix = chr(ord(self.prefix[i]) & (netmask & 0xff)) + prefix @@ -376,7 +376,7 @@ class IpPrefix(object): :rtype: str """ addrbits = self.addrlen - self.prefixlen - netmask = ((1L << self.prefixlen) - 1) << addrbits + netmask = ((1 << self.prefixlen) - 1) << addrbits netmaskbytes = struct.pack("!L", netmask) return IpAddress(af=AF_INET, address=netmaskbytes).__str__() diff --git a/daemon/core/nodes/physical.py b/daemon/core/nodes/physical.py index 1e9d3a89..388cddb6 100644 --- a/daemon/core/nodes/physical.py +++ b/daemon/core/nodes/physical.py @@ -234,12 +234,12 @@ class PhysicalNode(CoreNodeBase): dirname = dirname.replace("/", ".") dirname = os.path.join(self.nodedir, dirname) if not os.path.isdir(dirname): - os.makedirs(dirname, mode=0755) + os.makedirs(dirname, mode=0o755) hostfilename = os.path.join(dirname, basename) return open(hostfilename, mode) - def nodefile(self, filename, contents, mode=0644): + def nodefile(self, filename, contents, mode=0o644): with self.opennodefile(filename, "w") as node_file: node_file.write(contents) os.chmod(node_file.name, mode) diff --git a/daemon/core/services/coreservices.py b/daemon/core/services/coreservices.py index 9b762fe1..a12c0a70 100644 --- a/daemon/core/services/coreservices.py +++ b/daemon/core/services/coreservices.py @@ -520,7 +520,7 @@ class CoreServices(object): src = src.split('\n')[0] src = utils.expand_corepath(src, node.session, node) # TODO: glob here - node.nodefilecopy(filename, src, mode=0644) + node.nodefilecopy(filename, src, mode=0o644) return True return False diff --git a/daemon/examples/netns/ospfmanetmdrtest.py b/daemon/examples/netns/ospfmanetmdrtest.py index 9689fa86..4ba85ca5 100755 --- a/daemon/examples/netns/ospfmanetmdrtest.py +++ b/daemon/examples/netns/ospfmanetmdrtest.py @@ -84,7 +84,7 @@ ip forwarding f.close() tmp = self.bootscript() if tmp: - self.nodefile(self.bootsh, tmp, mode=0755) + self.nodefile(self.bootsh, tmp, mode=0o755) def boot(self): self.config() diff --git a/daemon/tests/test_grpc.py b/daemon/tests/test_grpc.py index 22cd3afe..7e2186b4 100644 --- a/daemon/tests/test_grpc.py +++ b/daemon/tests/test_grpc.py @@ -1,16 +1,16 @@ import time - from Queue import Queue +from builtins import int import grpc import pytest -from core.config import ConfigShim -from core.emulator.data import EventData -from core.emane.ieee80211abg import EmaneIeee80211abgModel -from core.emulator.enumerations import NodeTypes, EventTypes, ConfigFlags, ExceptionLevels from core.api.grpc import core_pb2 from core.api.grpc.client import CoreGrpcClient +from core.config import ConfigShim +from core.emane.ieee80211abg import EmaneIeee80211abgModel +from core.emulator.data import EventData +from core.emulator.enumerations import NodeTypes, EventTypes, ConfigFlags, ExceptionLevels from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility diff --git a/ns3/corens3/obj.py b/ns3/corens3/obj.py index 3dc23052..70291d3b 100644 --- a/ns3/corens3/obj.py +++ b/ns3/corens3/obj.py @@ -491,7 +491,7 @@ class Ns3Session(Session): net.mobility.setendtime() net.mobility.refresh_ms = 300 net.mobility.empty_queue_stop = False - of = ns.network.OutputStreamWrapper(filename, filemode=777) + of = ns.network.OutputStreamWrapper(filename, filemode=0o777) self.mobhelper.EnableAsciiAll(of) self.mobilitytracethread = threading.Thread( target=self.mobilitytrace,