From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (cm-84.215.81.34.getinternet.no [84.215.81.34]) by mx.google.com with ESMTPS id 28sm275431eye.9.2009.11.13.16.12.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 13 Nov 2009 16:12:10 -0800 (PST) Subject: Re: [sup-talk] offlineimap before-poll.rb undefined method 'usual_sources' From: Gaute Hope To: sup-talk In-reply-to: <877htul8us.fsf@pond.riseup.net> References: <877htul8us.fsf@pond.riseup.net> Date: Sat, 14 Nov 2009 01:12:04 +0100 Message-Id: <1258157447-sup-5782@dolk> User-Agent: Sup/git Content-Transfer-Encoding: 8bit Content-Type: multipart/signed; micalg="pgp-sha1"; boundary="=-1258157526-817979-14204-4610-1-="; protocol="application/pgp-signature" MIME-Version: 1.0 --=-1258157526-817979-14204-4610-1-= Content-Type: text/plain; charset=UTF-8 Excerpts from Micah Anderson's message of fr. nov. 13 16:53:15 +0100 2009: > > The before-poll.rb wiki example[0] seems to be what I am interested in, > however it doesn't work and provides a traceback. It reads as follows: > > def offlineimap(*folders) > cmd = "offlineimap -q -u Noninteractive.Basic" > cmd << " -f #{folders * ','}" unless folders.compact.empty? > `#{cmd}` > end > > def folder_names(sources) > sources.map { |s| s.uri.split('/').last } > end > > def inbox_sources(sources = Index.usual_sources) > sources.find_all { |s| !s.archived? }.sort_by {|s| s.id } > end > > if (@last_fetch || Time.at(0)) < Time.now - 120 > say "Running offlineimap..." > # only check non-auto-archived sources on the first run > log offlineimap(@last_fetch ? nil : folder_names(inbox_sources)) > say "Finished offlineimap run." > end > @last_fetch = Time.now Im using this modified version; and I filter the folders in offlineimaprc. def offlineimap(*folders) cmd = "offlineimap -u Noninteractive.Basic 2>&1" #cmd << " -f #{folders * ','}" unless folders.compact.empty? `#{cmd}` end def folder_names(sources) sources.map { |s| s.uri.split('/').last } end def inbox_sources(sources = SourceManager.sources) sources.find_all { |s| !s.archived? }.sort_by {|s| s.id } end if (@last_fetch || Time.at(0)) < Time.now - 20 say "Running offlineimap..." # only check non-auto-archived sources on the first run log offlineimap(@last_fetch ? nil : folder_names(inbox_sources)) say "Finished offlineimap." end @last_fetch = Time.now - gaute --=-1258157526-817979-14204-4610-1-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkr99dQACgkQCLbddHnmqqabTgCbBNSWR+C1tiq0qDo0xprQZzhJ rWAAoIak0+eKzAkHdMcXuc1etqIa1//J =5Hkf -----END PGP SIGNATURE----- --=-1258157526-817979-14204-4610-1-=--