Exemplo n.º 1
0
 def testonerror_noparam(self):
     summer.download_set_default (tmp_dir = ".", save_dir = ".")
     loop = glib.MainLoop ()
     i = summer.ItemData ()
     i.append_downloadable ('http://blubb')
     dl = summer.create_download (i)
     def error_cb (inner_dl, error):
         loop.quit ()
         self.assertEqual (inner_dl, dl)
         self.assertEqual (error.message, "Download failed: Cannot resolve hostname")
         self.assertEqual (inner_dl.get_property ('url'), 'http://blubb')
     dl.on_error (error_cb)
     dl.start ()
     loop.run ()
Exemplo n.º 2
0
def on_new_entries (feed, subscription):
    items = feed.get_items ()
    for item in items:
        dl = summer.create_download (item)
        if not dl:
            continue
        if subscription.get ('save_dir'):
            save_dir = subscription.get ('save_dir')
        else:
            save_dir = os.path.join (config.get ('save_dir'), subscription.get ('name'))
        dl.set_save_dir (save_dir)
        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, item)