From 96015a4a509dc7feb622f97325e8eb39896cc5e3 Mon Sep 17 00:00:00 2001 From: "Tomaszewski, PawelX" Date: Wed, 13 Nov 2019 04:35:06 -0800 Subject: Python 2 to 3 migration fixes Change-Id: I487632435ae575c2507e58ee5682aa03934391b8 Signed-off-by: Pawel Tomaszewski Signed-off-by: Kamil Wiatrowski --- 3rd_party/collectd-ves-app/ves_app/normalizer.py | 11 +++++++---- 3rd_party/collectd-ves-app/ves_app/ves_app.py | 13 +++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to '3rd_party') diff --git a/3rd_party/collectd-ves-app/ves_app/normalizer.py b/3rd_party/collectd-ves-app/ves_app/normalizer.py index 0e92d1a5..95feead1 100644 --- a/3rd_party/collectd-ves-app/ves_app/normalizer.py +++ b/3rd_party/collectd-ves-app/ves_app/normalizer.py @@ -17,7 +17,7 @@ # Volodymyr Mytnyk # -from . import yaml +import yaml import logging import datetime import time @@ -28,12 +28,15 @@ import re # import YAML loader try: - from .yaml import CLoader as Loader + from yaml import CLoader as Loader except ImportError: - from .yaml import Loader + from yaml import Loader # import synchronized queue -import queue +try: + import queue +except ImportError: + import Queue as queue class Config(object): diff --git a/3rd_party/collectd-ves-app/ves_app/ves_app.py b/3rd_party/collectd-ves-app/ves_app/ves_app.py index fa4e9349..a8551239 100644 --- a/3rd_party/collectd-ves-app/ves_app/ves_app.py +++ b/3rd_party/collectd-ves-app/ves_app/ves_app.py @@ -15,17 +15,26 @@ import json import sys import base64 -import configparser import logging import argparse +try: + import configparser +except ImportError: + import ConfigParser as configparser + from distutils.util import strtobool from kafka import KafkaConsumer from .normalizer import Normalizer from .normalizer import CollectdValue -import urllib.request as url +try: + # For Python 3.0 and later + import urllib.request as url +except ImportError: + # Fall back to Python 2's urllib2 + import urllib2 as url class VESApp(Normalizer): """VES Application""" -- cgit 1.2.3-korg