Cannot import module in new plugin

Asked by Nicolas Chachereau

I'm trying to create a Kupfer plugin for the Hamster Time Tracking applet [1].

In order to avoid recreating a client class doing the D-Bus messaging, I wanted to import a module already existing in Hamster. However, I can't import this client class into my Kupfer plugin which fails because of this [2].

However, it works perfectly inside Python [3], which means Kupfer's custom import somehow restricts valid imports. Is this a feature (i.e. wanted behaviour) or a bug? If it isn't a bug, why can't I import this file, and what can I do instead? Do I really need to rewrite my own client class?

[1]: http://projecthamster.wordpress.com/
[2]: http://paste2.org/p/1512498
[3]: http://paste2.org/p/1512500

Question information

Language:
English Edit question
Status:
Solved
For:
kupfer Edit question
Assignee:
No assignee Edit question
Solved by:
Karol Będkowski
Solved:
Last query:
Last reply:
Revision history for this message
Best Karol Będkowski (karol-bedkowski) said :
#1

Your plugin also have name "hamster" so importing "client" from "hamster" you try to import client from plugin module.
Simplest solution - please rename your plugin to - in example - "hamster_client.py"

Revision history for this message
Nicolas Chachereau (nicolas-chachereau) said :
#2

Thanks Karol Będkowski, that solved my question.

Revision history for this message
Nicolas Chachereau (nicolas-chachereau) said :
#3

Thanks a lot, that should have been obvious. My python skills are obviously rusty!

Revision history for this message
teranex (teranex) said :
#4

Would it be possible to post the code somewhere online? I'm interested in this plugin, but the links to paste2.org are not valid anymore... Thx!