griffith plugin development

167 views
Skip to first unread message

James Miller

unread,
Jan 20, 2012, 10:03:44 AM1/20/12
to griffit...@googlegroups.com
Hi, I am developing some extensions for griffith and have checked out the code to work on.  I wondered if I might be able to get some feedback and maybe join your group.  I am an experienced developer of sorts, I have no experience of working with other developers, having worked alone for the last ten years and being self taught.
Also, the last six weeks of development on this plugin have seen me learn python, gtk, sqlalchemy (my first use of sql in general) and regular expressions,  a rewarding if steep learning curve (I am used to strongly typed languages with pattern enforcement so python has had me pulling my hair out once or twice).

The extensions adds a dialog that allows the user to choose a directory, this directory is then scanned for movie files which are then added to griffith one at a time with the information downloaded from the current plugin (I have only tested IMDB).

The finished extension adds a watch movie item to the context menu (although I haven't begun to test this yet) and will change the colour of the number column of the main treeview to reflect whether the film is viewable (whether the film is resident and the file permissions are met)
During the development of this plugin, I have added to the preferences.py a test for bool datatype so I can use checkboxes that seems to work ok.  I have also added a callback function to initialise.py that allows the user to check/uncheck the seen it checkboxes with the mouse.  I have also changed the imdb plugin slightly to obtain classification data (this wasn't working for me as the source code for IMDB has changed a little since publication of Griffith)  I am wondering if all that string manipulation in the plugin wouldn't be better served by DOM traversal.  You may want to diff the files so I include a working copy of all the files I have changed/created.
I am also planning a file permission plugin, that opens a dialog that sets the file permissions of all the scanned movies to certain groups (defined in the dialog).  It will take me a little explanation as to how this works, so I will explain it in a later communication, if that's cool.

I have also developed a variation of the mark as seen extension that works as I would expect it to.

Please excuse the state of the code and any weird print statements that I have left in.  I am using Geany to develop with and don't have any debug facility with stack tracing etc as I would normally have, stani's python ide has debugging (I think) but i'm kind of used to geany now.

You may get a sql alchemy integrity error (foreignkey constraint violation) on the database table that I have added.  I haven't worked out how to deal with this yet and it is still intermittent.  This is my first time with sql, and I am not certain about the need to define a relationship with a primary join and a few other bits and pieces.   The error may only occur when I haven't emptied the database after messing it up the last time!  You should be able to get an idea of what I am on about though.  I think it will help a lot of people with their movie collections.

Cheers,


James


--
James Stewart Miller Bsc(hons) Psych.

griffith files.tar.gz

Piotr Ożarowski

unread,
Jan 23, 2012, 5:36:29 PM1/23/12
to griffit...@googlegroups.com
Hi James,

[James Miller, 2012-01-20]


> Hi, I am developing some extensions for griffith and have checked out the
> code to work on. I wondered if I might be able to get some feedback and
> maybe join your group.

great to hear that :)

about on_toggle and _on_toggle in initialise.py (i.e. changes outside
extensions directory): I added new pref. type (bool) which should make
it easier to move on_toggle and _on_toggle to extension's file (imagine
what would happen with seen flag if some other extension would use type_
= bool)

> I am an experienced developer of sorts, I have no
> experience of working with other developers, having worked alone for the
> last ten years and being self taught.

svn (or even better: git - I will convert the repo from svn to git
right after moving some other Griffith stuff to a new host sponsored by
gplhost.com) or any other VCS is a must these days. Please learn these
tools and send patches against latest versions in the repo (one per
feature/bug fix) instead of complete files. Version control systems make
collaboration a lot easier, I use git even for projects that I work on
alone.

Please also try to follow PEP8¹. Yeah, I know a lot of our code is not
compatible with PEP8 (a lot of our code is crap actually²), but we want
to change that.

[¹] http://www.python.org/dev/peps/pep-0008/
[²] I even started writing Griffith 2.0 from scratch, didn't have much
time to continue, though (but it's still on my TODO :)

> The extensions adds a dialog that allows the user to choose a directory,
> this directory is then scanned for movie files which are then added to
> griffith one at a time with the information downloaded from the current
> plugin (I have only tested IMDB).

I don't feel comfortable with extension adding new tables in the
database, maybe creating a new (sqlite) database would be a better
idea?

few other comments:
* extension doesn't work for me - my libglade doesn't recognize
"swapped" attribute, please also try to avoid glade, it's deprecated,
use gtk.builder instead (yeah, we didn't convert our .glade files
yet)
* exit() outside main script is a bad idea
* why _filename and all these setters, getters and synonyms? Why not a
public "filename" column? (the same for other proxy setters/getters)
* `foo != ""` can be replaced with `not foo` in most cases

[...]

> I am wondering if all that string manipulation in
> the plugin wouldn't be better served by DOM traversal

we already added lxml to the dependencies and all movies plugins will
use it... but I have to design a new API fist (the old one is not that
nice)
--
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl www.griffith.cc www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645

signature.asc

James Miller

unread,
Jan 24, 2012, 9:35:23 AM1/24/12
to griffit...@googlegroups.com
Thanks Piotr, I will make all the changes you suggest and commit to the repo as soon as you have the new repo address.  The code that I submitted was very scrappy as a lot of it is new to me and I am hacking a little to learn quickly (learn by doing), so I haven't cleaned it up yet.  I am reading the pep 8 style reference now and will stick to it.

I would be very interested in working on griffith 2.0, if you have any code, I'd love to collaborate.  Although the code I submitted so far is not the best example of this, I have quite a rigorous approach to design and good practice particularly with reference to oop principles.

Let me know as soon as you have a repo address for git, and I will commit my changes.

Many thanks

James


James Miller

unread,
Jan 24, 2012, 10:18:20 AM1/24/12
to griffit...@googlegroups.com
btw, I had to overwrite the _on_toolbar_icon_clicked method of the extension base class, as no movie is necessary to be selected, and to deal with situations where the user has no existing movies in the database.
Reply all
Reply to author
Forward
0 new messages