How to use plugins..

G

Goekhan Bakir

Hi!
This might be a newbie message but is there some example code to
write a generic plugin manager?

Particular problems:

1.)
Assume my package is installed on path x and has a subdirectory named
plugins.
If I import my package I want to scan automatically the plugin
directory.

2.)
Plugins should follow a common interface, is there a way to enforce
this?
(Actually I think this might be easy.)



Thanks for any help

gb
 
J

Josiah Carlson

1.)
Assume my package is installed on path x and has a subdirectory named
plugins.
If I import my package I want to scan automatically the plugin
directory.
os.listdir(path)

2.)
Plugins should follow a common interface, is there a way to enforce
this?
(Actually I think this might be easy.)

use try and except liberally:

try:
plugin.function(args...)
except:
#report plugin error


- Josiah
 
J

Josiah Carlson

bad bad bad bad idea
try hitting ctrl-c while plugin.function is running, for instance.

So you do:

try:
#stuff
except KeyboardInterrupt:
raise
except:
#report exception


- Josiah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top