tweak plugins

This commit is contained in:
j 2023-03-11 12:30:51 +01:00
parent 629c1de8d5
commit a2f815bedc
2 changed files with 20 additions and 13 deletions

View file

@ -6,7 +6,7 @@ from __future__ import division, with_statement, print_function, absolute_import
import getpass import getpass
from glob import glob from glob import glob
import imp import importlib.util
import json import json
import math import math
import os import os
@ -226,13 +226,18 @@ class Client(object):
def load_plugins(self, base=os.path.join(utils.basedir(), 'client.d')): def load_plugins(self, base=os.path.join(utils.basedir(), 'client.d')):
global parse_path, example_path, ignore_file, sync_extensions, encode global parse_path, example_path, ignore_file, sync_extensions, encode
base = os.path.expanduser(base) base = os.path.expanduser(base)
if not os.path.exists(base):
return
for name in sorted(os.listdir(base)): for name in sorted(os.listdir(base)):
if not name.endswith('.py'): if not name.endswith('.py'):
continue continue
path = os.path.join(base, name) path = os.path.join(base, name)
with open(path) as fp: module_name = os.path.basename(path).split('.')[0]
module = imp.load_source(os.path.basename(path).split('.')[0], base, fp) spec = importlib.util.spec_from_file_location(module_name, path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
if hasattr(module, 'parse_path'): if hasattr(module, 'parse_path'):
parse_path = module.parse_path parse_path = module.parse_path
if hasattr(module, 'example_path'): if hasattr(module, 'example_path'):

View file

@ -40,6 +40,8 @@ class DistributedClient:
def __init__(self, url, name, threads): def __init__(self, url, name, threads):
self.url = url self.url = url
while self.url and self.url[-1] == '/':
self.url = self.url[:-1]
self.name = name self.name = name
self.threads = threads self.threads = threads
self.supported_formats = extract.supported_formats() self.supported_formats = extract.supported_formats()