removed circular dependency causing issues in python2

This commit is contained in:
Blake Harnden 2019-10-04 12:36:15 -07:00
parent 70bb1598e1
commit bb98a4a77f
6 changed files with 16 additions and 23 deletions

View file

@ -16,7 +16,6 @@ import sys
from past.builtins import basestring
from core import constants
from core.errors import CoreCommandError
DEVNULL = open(os.devnull, "wb")
@ -451,16 +450,13 @@ def load_classes(path, clazz):
return classes
def load_logging_config(config_path=None):
def load_logging_config(config_path):
"""
Load CORE logging configuration file.
:param str config_path: path to logging config file,
when None defaults to /etc/core/logging.conf
:param str config_path: path to logging config file
:return: nothing
"""
if not config_path:
config_path = os.path.join(constants.CORE_CONF_DIR, "logging.conf")
with open(config_path, "r") as log_config_file:
log_config = json.load(log_config_file)
logging.config.dictConfig(log_config)

View file

@ -3,6 +3,7 @@
# Example CORE Python script that attaches N nodes to an EMANE 802.11abg network.
import datetime
import logging
import parser
from builtins import range
@ -10,9 +11,6 @@ from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes
from core.utils import load_logging_config
load_logging_config()
def example(options):
@ -52,6 +50,7 @@ def example(options):
def main():
logging.basicConfig(level=logging.INFO)
options = parser.parse_options("emane80211")
start = datetime.datetime.now()
print(

View file

@ -6,15 +6,13 @@
# nodestep
import datetime
import logging
import parser
from builtins import range
from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes, NodeTypes
from core.utils import load_logging_config
load_logging_config()
def example(options):
@ -56,8 +54,8 @@ def example(options):
def main():
logging.basicConfig(level=logging.INFO)
options = parser.parse_options("switch")
start = datetime.datetime.now()
print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time))
example(options)

View file

@ -4,13 +4,11 @@
# n nodes are connected to a virtual wlan; run test for testsec
# and repeat for minnodes <= n <= maxnodes with a step size of
# nodestep
import logging
from builtins import range
from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes, NodeTypes
from core.utils import load_logging_config
load_logging_config()
def example(nodes):
@ -38,4 +36,5 @@ def example(nodes):
if __name__ in {"__main__", "__builtin__"}:
logging.basicConfig(level=logging.INFO)
example(2)

View file

@ -6,6 +6,7 @@
# nodestep
import datetime
import logging
import parser
from builtins import range
@ -13,9 +14,6 @@ from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes, NodeOptions
from core.emulator.enumerations import EventTypes, NodeTypes
from core.location.mobility import BasicRangeModel
from core.utils import load_logging_config
load_logging_config()
def example(options):
@ -60,6 +58,7 @@ def example(options):
def main():
logging.basicConfig(level=logging.INFO)
options = parser.parse_options("wlan")
start = datetime.datetime.now()

View file

@ -7,6 +7,7 @@ message handlers are defined and some support for sending messages.
import argparse
import logging
import os
import sys
import threading
import time
@ -96,7 +97,7 @@ def get_merged_config(filename):
"numthreads": "1",
"grpcport": "50051",
"grpcaddress": "localhost",
"logfile": ""
"logfile": os.path.join(constants.CORE_CONF_DIR, "logging.conf")
}
parser = argparse.ArgumentParser(
@ -125,9 +126,6 @@ def get_merged_config(filename):
cfg = ConfigParser(defaults)
cfg.read(filename)
# load logging configuration
load_logging_config(args.logfile)
section = "core-daemon"
if not cfg.has_section(section):
cfg.add_section(section)
@ -149,6 +147,10 @@ def main():
"""
# get a configuration merged from config file and command-line arguments
cfg = get_merged_config("%s/core.conf" % constants.CORE_CONF_DIR)
# load logging configuration
load_logging_config(cfg["logfile"])
banner()
try: