tweak plugins
This commit is contained in:
parent
629c1de8d5
commit
a2f815bedc
2 changed files with 20 additions and 13 deletions
|
|
@ -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,23 +226,28 @@ 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)
|
||||||
if hasattr(module, 'parse_path'):
|
module = importlib.util.module_from_spec(spec)
|
||||||
parse_path = module.parse_path
|
spec.loader.exec_module(module)
|
||||||
if hasattr(module, 'example_path'):
|
|
||||||
example_path = module.example_path
|
if hasattr(module, 'parse_path'):
|
||||||
if hasattr(module, 'ignore_file'):
|
parse_path = module.parse_path
|
||||||
ignore_file = module.ignore_file
|
if hasattr(module, 'example_path'):
|
||||||
if hasattr(module, 'sync_extensions'):
|
example_path = module.example_path
|
||||||
sync_extensions = module.sync_extensions
|
if hasattr(module, 'ignore_file'):
|
||||||
if hasattr(module, 'encode'):
|
ignore_file = module.ignore_file
|
||||||
encode = module.encode
|
if hasattr(module, 'sync_extensions'):
|
||||||
|
sync_extensions = module.sync_extensions
|
||||||
|
if hasattr(module, 'encode'):
|
||||||
|
encode = module.encode
|
||||||
|
|
||||||
def _conn(self):
|
def _conn(self):
|
||||||
db_conn = self._config['cache']
|
db_conn = self._config['cache']
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue