fixed basestring check for 2/3 compatibility

This commit is contained in:
bharnden 2019-06-02 19:23:49 -07:00
parent ecc63f4abb
commit 3de37f0f5e
5 changed files with 10 additions and 6 deletions

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT! # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: core/api/grpc/core.proto # source: core/api/grpc/core.proto

View file

@ -7,9 +7,11 @@ CORE API messaging is leveraged for communication with the GUI.
import socket import socket
import struct import struct
from past.builtins import basestring
from enum import Enum from enum import Enum
from core.api.tlv import structutils
from core.emulator.enumerations import ConfigTlvs from core.emulator.enumerations import ConfigTlvs
from core.emulator.enumerations import EventTlvs from core.emulator.enumerations import EventTlvs
from core.emulator.enumerations import EventTypes from core.emulator.enumerations import EventTypes
@ -23,7 +25,6 @@ from core.emulator.enumerations import MessageTypes
from core.emulator.enumerations import NodeTlvs from core.emulator.enumerations import NodeTlvs
from core.emulator.enumerations import RegisterTlvs from core.emulator.enumerations import RegisterTlvs
from core.emulator.enumerations import SessionTlvs from core.emulator.enumerations import SessionTlvs
from core.api.tlv import structutils
from core.nodes.ipaddress import IpAddress from core.nodes.ipaddress import IpAddress
from core.nodes.ipaddress import MacAddress from core.nodes.ipaddress import MacAddress
@ -176,8 +177,8 @@ class CoreTlvDataString(CoreTlvData):
:return: length of data packed and the packed data :return: length of data packed and the packed data
:rtype: tuple :rtype: tuple
""" """
if not isinstance(value, str): if not isinstance(value, basestring):
raise ValueError("value not a string: %s" % value) raise ValueError("value not a string: %s" % type(value))
value = value.encode("utf-8") value = value.encode("utf-8")
if len(value) < 256: if len(value) < 256:

View file

@ -3,6 +3,7 @@ Utilities for working with python struct data.
""" """
import logging import logging
from past.builtins import basestring
def pack_values(clazz, packers): def pack_values(clazz, packers):
@ -29,7 +30,7 @@ def pack_values(clazz, packers):
# only pack actual values and avoid packing empty strings # only pack actual values and avoid packing empty strings
# protobuf defaults to empty strings and does no imply a value to set # protobuf defaults to empty strings and does no imply a value to set
if value is None or (isinstance(value, str) and not value): if value is None or (isinstance(value, basestring) and not value):
continue continue
# transform values as needed # transform values as needed

View file

@ -4,8 +4,8 @@ commeffect.py: EMANE CommEffect model for CORE
import logging import logging
import os import os
from lxml import etree from lxml import etree
from past.builtins import basestring
from core.config import ConfigGroup from core.config import ConfigGroup
from core.emane import emanemanifest from core.emane import emanemanifest

View file

@ -10,6 +10,7 @@ import os
import shlex import shlex
import subprocess import subprocess
import sys import sys
from past.builtins import basestring
from core import CoreCommandError from core import CoreCommandError
@ -148,7 +149,7 @@ def split_args(args):
:rtype: list :rtype: list
""" """
logging.info("split args: %s - %s", args, type(args)) logging.info("split args: %s - %s", args, type(args))
if isinstance(args, str): if isinstance(args, basestring):
logging.info("splitting args") logging.info("splitting args")
args = shlex.split(args) args = shlex.split(args)
return args return args