From edd60fa2d3c972932da7be1605fec2674069c31b Mon Sep 17 00:00:00 2001 From: lnu Date: Tue, 5 Apr 2005 14:40:15 +0000 Subject: git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@11 f70e237a-67f3-0310-a06c-d2b8a7116972 --- lib/feed2imap/config.rb | 1 + lib/feed2imap/feed2imap.rb | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb index 002db3e..a784b91 100644 --- a/lib/feed2imap/config.rb +++ b/lib/feed2imap/config.rb @@ -70,6 +70,7 @@ end # A configured feed. simple data container. class ConfigFeed attr_reader :name, :url, :imapaccount, :folder + attr_accessor :body def initialize(name, url, imapaccount, folder) @name, @url, @imapaccount, @folder = name, url, imapaccount, folder diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 92cab8f..3131587 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -69,22 +69,26 @@ class Feed2Imap exit(1) end end - # for each feed, fetch, upload to IMAP and cache + # check that IMAP folders exist + @logger.info("Checking IMAP folders") @config.feeds.each do |f| - @logger.info("Processing #{f.url}") begin - # check that folder exist f.imapaccount.create_folder(f.folder) if not f.imapaccount.folder_exist?(f.folder) rescue @logger.fatal("Error while creating IMAP folder #{f.folder}: #{$!}") exit(1) end + end + # for each feed, fetch, upload to IMAP and cache + @logger.info("Fetching feeds") + @config.feeds.each do |f| + @logger.info("Processing #{f.name}") begin - body = HTTPFetcher::fetch(f.url, @cache.get_last_check(f.name)) + f.body = HTTPFetcher::fetch(f.url, @cache.get_last_check(f.name)) # dump if requested if @config.dumpdir fname = @config.dumpdir + '/' + f.name + '-' + Time::now.xmlschema - File::open(fname, 'w') { |file| file.puts body } + File::open(fname, 'w') { |file| file.puts f.body } end rescue Timeout::Error @logger.fatal("Timeout::Error while fetching #{f.url}: #{$!}") @@ -93,17 +97,20 @@ class Feed2Imap @logger.fatal("Error while fetching #{f.url}: #{$!}") next end - next if body.nil? # means 304 + end + @logger.info("Parsing and uploading") + @config.feeds.each do |f| + next if f.body.nil? # means 304 begin - channel = Channel::new(body) + channel = Channel::new(f.body) rescue - @logger.fatal("Error while parsing #{f.url}: #{$!}") + @logger.fatal("Error while parsing #{f.name}: #{$!}") next end begin newitems, updateditems = @cache.get_new_items(f.name, channel.items) rescue - @logger.fatal("Exception caught when selecting new items for #{f.url}: #{$!}") + @logger.fatal("Exception caught when selecting new items for #{f.name}: #{$!}") puts $!.backtrace next end -- cgit v1.2.3-70-g09d2 ed2imaprc.xml (unfollow)
Commit message (Collapse)AuthorFilesLines
2016-03-25Use debug mode for testingRené 'Necoro' Neumann1-1/+1
2016-03-25Add mail to the dependenciesRené 'Necoro' Neumann1-0/+1
2015-06-09itemtomail: embed images using data: URLsHEADmasterAntonio Terceiro1-18/+2
2015-05-10Bump versionAntonio Terceiro1-1/+1
2015-05-10Fix regression in `include-images` optionAntonio Terceiro3-8/+16
test/tc_httpfetcher.rb can't still be re-enabled because it hits the network, and a hostname that is no longer valid.
2015-05-03Bump versionAntonio Terceiro1-1/+1
2015-05-03Fix usage of filtersAntonio Terceiro2-16/+24
- avoid accessing $? unless it is actually available - when calling a filter, make sure to release the mutex even if there is an exception during the filter handling. The long term solution is to drastically reorganize concurrency code.
2015-01-13Handle being given numbers as feed nameAntonio Terceiro2-0/+16
Force feed names to be strings because they will be handled as strings later.
2015-01-13Rakefile: remove wrong (and thus unused) flagAntonio Terceiro1-1/+0
2015-01-13Remove deprecated 'test suite' fileAntonio Terceiro1-12/+0
I want to always run all tests
2015-01-13Rakefile: re-indentAntonio Terceiro1-35/+35
2015-01-13Rakefile: run tests in verbose modeAntonio Terceiro1-1/+2
2014-10-071.2.3 releaseAntonio Terceiro1-1/+1
2014-10-07Fix cleanup of maildirsAntonio Terceiro3-1/+16
Thanks to Sylvain L. Sauvage for the bug report
2014-05-18feed2imap-test: reuse cache dir/protect configAntonio Terceiro1-1/+1
this reduces the noise in the output and helps testing feed updates
2014-02-13feed2imap-test: can now take a feed URL as argumentAntonio Terceiro1-3/+22
2014-02-13update .gitignoreAntonio Terceiro1-0/+2
2014-02-13fix dependency on ruby-feedparserAntonio Terceiro1-1/+1
2014-02-05Release 1.2.2Antonio Terceiro2-2/+2
2014-02-05config: fix regression with arrays as targetAntonio Terceiro2-1/+17
2013-08-28Fix teardown method nameAntonio Terceiro1-1/+1