mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-06-10 23:30:03 +02:00
Replace imp module use with importlib Remove unfinished code block for loading shared lib plugins Bug: https://bugs.gentoo.org/941872 Signed-off-by: Paul Healy <lmiphay@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/39059 Signed-off-by: Sam James <sam@gentoo.org>
37 lines
1.7 KiB
Diff
37 lines
1.7 KiB
Diff
diff --git a/dstat b/dstat
|
|
index 9359965..541fe95 100755
|
|
--- a/dstat
|
|
+++ b/dstat
|
|
@@ -2613,28 +2613,19 @@ def main():
|
|
pluginfile = 'dstat_' + mod.replace('-', '_')
|
|
try:
|
|
if pluginfile not in globals():
|
|
- import imp
|
|
- fp, pathname, description = imp.find_module(pluginfile, pluginpath)
|
|
- fp.close()
|
|
+ import importlib.machinery
|
|
+ spec = importlib.machinery.PathFinder().find_spec(pluginfile, pluginpath)
|
|
|
|
### TODO: Would using .pyc help with anything ?
|
|
### Try loading python plugin
|
|
- if description[0] in ('.py', ):
|
|
- exec(open(pathname).read())
|
|
+ if spec.origin.endswith('.py'):
|
|
+ exec(open(spec.origin).read())
|
|
#execfile(pathname)
|
|
exec('global plug; plug = dstat_plugin(); del(dstat_plugin)')
|
|
plug.filename = pluginfile
|
|
plug.check()
|
|
plug.prepare()
|
|
|
|
- ### Try loading C plugin (not functional yet)
|
|
- elif description[0] == '.so':
|
|
- exec('import %s; global plug; plug = %s.new()' % (pluginfile, pluginfile))
|
|
- plug.check()
|
|
- plug.prepare()
|
|
-# print(dir(plug))
|
|
-# print(plug.__module__)
|
|
-# print(plug.name)
|
|
else:
|
|
print('Module %s is of unknown type.' % pluginfile, file=sys.stderr)
|
|
|