1 # Copyright (c) 2011 Neal H. Walfield
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Don't fail if the Woodchuck modules are not available. Just disable
19 # Woodchuck's functionality.
21 # Whether we imported the woodchuck modules successfully.
22 woodchuck_imported = True
25 from pywoodchuck import PyWoodchuck
26 from pywoodchuck import woodchuck
27 except ImportError, exception:
28 print ("Unable to load Woodchuck modules: disabling Woodchuck support: %s"
29 % traceback.format_exc ())
30 woodchuck_imported = False
31 class PyWoodchuck (object):
36 # The default channel refresh interval: 6 hours.
37 refresh_interval = 6 * 60 * 60
39 class mywoodchuck (PyWoodchuck):
40 def __init__(self, listing, *args):
41 PyWoodchuck.__init__ (self, *args)
43 self.listing = listing
46 def stream_update_cb(self, stream):
47 print ("stream update called on %s (%s)"
48 % (stream.human_readable_name, stream.identifier,))
50 # Make sure no one else is concurrently updating this
53 self.listing.updateFeed(stream.identifier)
55 print ("Updating %s: %s"
56 % (stream.identifier, traceback.format_exc ()))
58 def object_transfer_cb(self, stream, object,
59 version, filename, quality):
60 log ("object transfer called on %s (%s) in stream %s (%s)"
61 % (object.human_readable_name, object.identifier,
62 stream.human_readable_name, stream.identifier))
69 _w = mywoodchuck (listing, "FeedingIt", "org.maemo.feedingit")
71 if not woodchuck_imported or not _w.available ():
72 print "Unable to contact Woodchuck server."
74 print "Woodchuck appears to be available."
77 """Connect to the woodchuck server and initialize any state."""