summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2020-03-25 15:29:44 +0300
committerGitHub <noreply@github.com>2020-03-25 15:29:44 +0300
commit198b735f30d1bdbbb8ca87dc1f0b25f9091bfe3b (patch)
treea07030a0400a8d1cdd54b5403eb973c77a9565f2 /collectors
parent69a61fcd45166e640b0d1870ff3189e5cba49df5 (diff)
python.d.plugin: add prefix to the module name during loading s… (#8474)
auto format python.d.plugin code and add `pythond_` prefix to the modules name
Diffstat (limited to 'collectors')
-rw-r--r--collectors/python.d.plugin/python.d.plugin.in11
-rw-r--r--collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py3
2 files changed, 6 insertions, 8 deletions
diff --git a/collectors/python.d.plugin/python.d.plugin.in b/collectors/python.d.plugin/python.d.plugin.in
index 44b6671cba..b289def994 100644
--- a/collectors/python.d.plugin/python.d.plugin.in
+++ b/collectors/python.d.plugin/python.d.plugin.in
@@ -42,13 +42,11 @@ except ImportError:
PY_VERSION = sys.version_info[:2] # (major=3, minor=7, micro=3, releaselevel='final', serial=0)
-
if PY_VERSION > (3, 1):
from importlib.machinery import SourceFileLoader
else:
from imp import load_source as SourceFileLoader
-
ENV_NETDATA_USER_CONFIG_DIR = 'NETDATA_USER_CONFIG_DIR'
ENV_NETDATA_STOCK_CONFIG_DIR = 'NETDATA_STOCK_CONFIG_DIR'
ENV_NETDATA_PLUGINS_DIR = 'NETDATA_PLUGINS_DIR'
@@ -65,7 +63,6 @@ def add_pythond_packages():
add_pythond_packages()
-
from bases.collection import safe_print
from bases.loggers import PythonDLogger
from bases.loaders import load_config
@@ -173,7 +170,7 @@ def multi_path_find(name, *paths):
def load_module(name):
abs_path = os.path.join(DIRS.modules, '{0}{1}'.format(name, MODULE_SUFFIX))
- module = SourceFileLoader(name, abs_path)
+ module = SourceFileLoader('pythond_' + name, abs_path)
if isinstance(module, types.ModuleType):
return module
return module.load_module()
@@ -590,7 +587,7 @@ class Plugin:
job.init()
except Exception as error:
self.log.warning("{0}[{1}] : unhandled exception on init : {2}, skipping the job".format(
- job.module_name, job.real_name, repr(error)))
+ job.module_name, job.real_name, repr(error)))
job.status = JOB_STATUS_DROPPED
continue
@@ -598,7 +595,7 @@ class Plugin:
ok = job.check()
except Exception as error:
self.log.warning("{0}[{1}] : unhandled exception on check : {2}, skipping the job".format(
- job.module_name, job.real_name, repr(error)))
+ job.module_name, job.real_name, repr(error)))
job.status = JOB_STATUS_DROPPED
continue
if not ok:
@@ -611,7 +608,7 @@ class Plugin:
job.create()
except Exception as error:
self.log.warning("{0}[{1}] : unhandled exception on create : {2}, skipping the job".format(
- job.module_name, job.real_name, repr(error)))
+ job.module_name, job.real_name, repr(error)))
job.status = JOB_STATUS_DROPPED
continue
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
index 4dfd226b0f..42882d1768 100644
--- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
+++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
@@ -60,6 +60,7 @@ class SimpleService(PythonDLimitedLogger, object):
Prototype of Service class.
Implemented basic functionality to run jobs by `python.d.plugin`
"""
+
def __init__(self, configuration, name=''):
"""
:param configuration: <dict>
@@ -70,7 +71,7 @@ class SimpleService(PythonDLimitedLogger, object):
self.order = list()
self.definitions = dict()
- self.module_name = self.__module__
+ self.module_name = self.__module__.lstrip('pythond_')
self.job_name = configuration.pop('job_name')
self.override_name = configuration.pop('override_name')
self.fake_name = None