Skip to content

Commit

Permalink
Update to use recent summer features
Browse files Browse the repository at this point in the history
  • Loading branch information
ozamosi committed May 13, 2009
1 parent 969b7f8 commit be8c582
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 deletions.
3 changes: 3 additions & 0 deletions plugins/growl.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def download_started (pdata, dl, item):
def download_update (pdata, dl, downloaded, length, item):
pass

def download_error (pdata, dl, error, item):
pass

def init (pdata):
pdata['app'] = 'river'
pdata['addr'] = (pdata['config']['ip'], GROWL_UDP_PORT)
Expand Down
3 changes: 3 additions & 0 deletions plugins/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def download_started (pdata, dl, item):
def download_update (pdata, dl, downloaded, length, item):
print 'Status update: %s. Downloaded: %s/%s' % (item['title'], str(downloaded), str(length))

def download_error (pdata, dl, error, item):
print 'Error in %s: %s'% (item['title'], error.message)

def init (pdata):
print 'Loaded simple print plugin'

Expand Down
3 changes: 1 addition & 2 deletions river/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
nobase_pkgpython_PYTHON = \
river.py \
river_config.py \
river_plugins.py \
summer_util.py
river_plugins.py

clean-local:
rm -rf *.pyc *.pyo
Expand Down
13 changes: 8 additions & 5 deletions river/river.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
except ImportError:
import gobject as glib

import summer_util
import river_plugins

parser = OptionParser ()
Expand All @@ -35,13 +34,16 @@
plugins = river_plugins.Plugins(config['plugins'])

def on_download_complete (dl, item):
plugins.download_complete (dl, summer_util.flatten_item (item))
plugins.download_complete (dl, item)

def on_download_started (dl, item):
plugins.download_started (dl, summer_util.flatten_item (item))
plugins.download_started (dl, item)

def on_download_update (dl, downloaded, length, item):
plugins.download_update (dl, downloaded, length, summer_util.flatten_item (item))
plugins.download_update (dl, downloaded, length, item)

def on_download_error (dl, error, item):
plugins.download_error (dl, error, item)

def on_new_entries (feed, subscription):
items = feed.get_items ()
Expand All @@ -57,9 +59,10 @@ def on_new_entries (feed, subscription):
dl.connect ("download-complete", on_download_complete, item)
dl.connect ("download-started", on_download_started, item)
dl.connect ("download-update", on_download_update, item)
dl.on_error (on_download_error, item)
dl.start ()

plugins.new_entry (dl, summer_util.flatten_item (item))
plugins.new_entry (dl, item)

def main ():
for subscription in config.get ('subscriptions', []):
Expand Down
5 changes: 5 additions & 0 deletions river/river_plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import gobject
import imp
import xdg.BaseDirectory as bd

Expand All @@ -27,6 +28,9 @@ def download_update (self, dl, downloaded, length, item):
for p in self.plugins.keys ():
self.plugins[p]['download_update'] (self.plugins[p]['data'], dl, downloaded, length, item)

def download_error (self, dl, error, item):
for p in self.plugins.keys ():
self.plugins[p]['download_error'] (self.plugins[p]['data'], dl, error, item)

def load_plugins (self, config):
for p in config:
Expand All @@ -42,6 +46,7 @@ def load_plugins (self, config):
self.plugins[p['name']]['download_started'] = m.download_started
self.plugins[p['name']]['download_complete'] = m.download_complete
self.plugins[p['name']]['download_update'] = m.download_update
self.plugins[p['name']]['download_error'] = m.download_error
self.plugins[p['name']]['shutdown'] = m.shutdown

self.plugins[p['name']]['data'] = {'config': p['config']}
Expand Down
16 changes: 0 additions & 16 deletions river/summer_util.py

This file was deleted.

0 comments on commit be8c582

Please sign in to comment.