How to use plugins..

Discussion in 'Python' started by Goekhan Bakir, Feb 27, 2004.

  1. 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
    Goekhan Bakir, Feb 27, 2004
    #1
    1. Advertising

  2. > 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
    Josiah Carlson, Feb 29, 2004
    #2
    1. Advertising

  3. Goekhan Bakir

    Jeff Epler Guest

    On Sun, Feb 29, 2004 at 12:44:17PM -0800, Josiah Carlson wrote:
    > use try and except liberally:


    bad bad bad bad idea

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

    Jeff
    Jeff Epler, Feb 29, 2004
    #3
  4. > 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
    Josiah Carlson, Mar 1, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ThunderMusic

    Plugins and Late Binding

    ThunderMusic, Jan 27, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    840
    Patrice
    Apr 12, 2005
  2. Philip Townsend

    detecting plugins / ServerVariables

    Philip Townsend, Feb 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    302
    Eric Lawrence [MSFT]
    Feb 22, 2004
  3. Laszlo Zsolt Nagy

    How to use DrPython plugins

    Laszlo Zsolt Nagy, Aug 6, 2005, in forum: Python
    Replies:
    3
    Views:
    1,887
    Franz Steinhaeusler
    Aug 8, 2005
  4. Replies:
    0
    Views:
    262
  5. Jason Dusek

    vim compiler plugins - how to use?

    Jason Dusek, Sep 18, 2006, in forum: Ruby
    Replies:
    0
    Views:
    94
    Jason Dusek
    Sep 18, 2006
Loading...

Share This Page