Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PluginLoader class #9

Merged
merged 7 commits into from
May 26, 2013
Merged

Conversation

MostAwesomeDude
Copy link
Contributor

Factor out plugin loading and unloading, and general plugin management, to its own class. This is the first part of #7; this factoring has to happen before any alternative interaction with Hamper can be set up.

This kind of "iterate over the plugins" could probably be factored.

Refs hamperbot#7.
Not sure if this works for quotes, since that plugin appears to not register
commands correctly. What is up with that?

Refs hamperbot#7.
And update the plugin plugins to match.

...At some point, "plugin" starts to look like a very funny word.

Refs hamperbot#7.
At this point, we've pulled everything out. All that remains is to unknot some
of the execution.

Refs hamperbot#7.
@@ -218,6 +193,39 @@ def clientConnectionFailed(self, connector, reason):
print "Could not connect: %s" % (reason,)

def registerPlugin(self, plugin):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost completely unused now, only the CommanderFactor still uses it, and then the change should be trivial. Nix this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; patch incoming.

@mythmon
Copy link
Contributor

mythmon commented May 26, 2013

One small issue I ran into:

(hamper)1@seaborgium> PYTHONPATH=. python scripts/hamper
Loading db from config: sqlite:///hamper.db
Loading command <class 'QuitCommand'>
registered plugin quit as ['baseplugin', 'base_plugin', 'chat']
Loading command <class 'DiceCommand'>
dice setup
registered plugin dice as ['baseplugin', 'base_plugin', 'chat']
Traceback (most recent call last):
  File "scripts/hamper", line 7, in <module>
    main()
  File "/home/mythmon/src/hamper/hamper/commander.py", line 29, in main
    CommanderFactory(config))
  File "/home/mythmon/src/hamper/hamper/commander.py", line 185, in __init__
    self.registerPlugin(plugin)
  File "/home/mythmon/src/hamper/hamper/commander.py", line 200, in registerPlugin
    self.loader.registerPlugin(plugin)
  File "/home/mythmon/src/hamper/hamper/commander.py", line 254, in registerPlugin
    plugin.setup(self)
  File "/home/mythmon/src/hamper/hamper/plugins/bitly.py", line 42, in setup
    self.username = factory.config['bitly']['login']
AttributeError: 'PluginLoader' object has no attribute 'config'

This and the nit I had above are the only issues I see.

mythmon added a commit that referenced this pull request May 26, 2013
Separate plugin loader from commander.

Thanks Corbin!
@mythmon mythmon merged commit 7b62fc1 into hamperbot:master May 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants