From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PyMV0-00073b-FE for garchives@archives.gentoo.org; Sat, 12 Mar 2011 10:56:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CEEE7E07F7; Sat, 12 Mar 2011 10:56:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8DD9EE07F7 for ; Sat, 12 Mar 2011 10:56:35 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C998C1B40C0 for ; Sat, 12 Mar 2011 10:56:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by flycatcher.gentoo.org (Postfix) with ESMTP id DF8FE20060 for ; Sat, 12 Mar 2011 10:56:31 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <11454907181978b99c00db92949e046948aaee05.robbat2@gentoo> Subject: [gentoo-commits] proj/elections:master commit in: / X-VCS-Repository: proj/elections X-VCS-Files: countify listify votify X-VCS-Directories: / X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 11454907181978b99c00db92949e046948aaee05 Date: Sat, 12 Mar 2011 10:56:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 5459606de3d74af2cf50299d11fc8bda commit: 11454907181978b99c00db92949e046948aaee05 Author: Robin H. Johnson orbis-terrarum net> AuthorDate: Sat Mar 12 10:56:05 2011 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Sat Mar 12 10:56:05 2011 +0000 URL: http://sources.gentoo.org/gitweb/?p=3Dproj/elections.git;a=3D= commit;h=3D11454907 Alter *ify code to support an epoch value in a file instead of the mtime = of the file. --- countify | 17 +++++++++++++++-- listify | 17 +++++++++++++++-- votify | 17 +++++++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/countify b/countify index c882fc7..2de6ba8 100755 --- a/countify +++ b/countify @@ -24,13 +24,26 @@ use strict; (my $version =3D '$Revision: 1.3 $') =3D~ s/.*?(\d.*\d).*/$zero version = $1\n/; my %opt; =20 +sub grabfile_int { + my $f =3D shift; + open FILE, "<", $f; + $i =3D ; + close FILE; + chomp $i; + return $i + 0; +} + # Collect the open elections my (@open_elections, $usage_elections); opendir(D, "$Votify::datadir/") or die; @open_elections =3D sort grep { s/^start-// and do { - my ($starttime) =3D (stat _)[9] if stat("$Votify::datadir/start-= $_"); - my ($stoptime) =3D (stat _)[9] if stat("$Votify::datadir/stop-$_= "); + my ($startfile) =3D sprintf "%s/start-%s", $Votify::datadir, $_; + my ($stopfile) =3D sprintf "%s/stop-%s", $Votify::datadir, $_; + my ($starttime) =3D grabfile_int($startfile); + my ($stoptime) =3D grabfile_int($stopfile); + $starttime =3D (stat _)[9] if stat($startfile) and (!defined($st= arttime) or ($starttime <=3D 0)); + $stoptime =3D (stat _)[9] if stat($stopfile) and (!defined($stop= time) or ($stoptime <=3D 0)); ((not defined $starttime or $starttime < time) and (not defined $stoptime or $stoptime > time)) } diff --git a/listify b/listify index 641d473..632e444 100755 --- a/listify +++ b/listify @@ -24,14 +24,27 @@ use strict; (my $version =3D '$Revision: 1.5 $') =3D~ s/.*?(\d.*\d).*/$zero version = $1\n/; my (%opt, %elections); =20 +sub grabfile_int { + my $f =3D shift; + open FILE, "<", $f; + $i =3D ; + close FILE; + chomp $i; + return $i + 0; +} + # Collect the open elections my (@open_elections, $usage_elections); opendir(D, "$Votify::datadir/") or die; @open_elections =3D sort grep { s/^start-// and do { my ($name) =3D $_; - my ($starttime) =3D (stat _)[9] if stat("$Votify::datadir/start-= $_"); - my ($stoptime) =3D (stat _)[9] if stat("$Votify::datadir/stop-$_= "); + my ($startfile) =3D sprintf "%s/start-%s", $Votify::datadir, $_; + my ($stopfile) =3D sprintf "%s/stop-%s", $Votify::datadir, $_; + my ($starttime) =3D grabfile_int($startfile); + my ($stoptime) =3D grabfile_int($stopfile); + $starttime =3D (stat _)[9] if stat($startfile) and (!defined($st= arttime) or ($starttime <=3D 0)); + $stoptime =3D (stat _)[9] if stat($stopfile) and (!defined($stop= time) or ($stoptime <=3D 0)); my $valid =3D ((not defined $starttime or $starttime < time) and (not defined $stoptime or $stoptime > time)); if($valid) { diff --git a/votify b/votify index c8d4e40..2e295bc 100755 --- a/votify +++ b/votify @@ -24,13 +24,26 @@ use strict; (my $version =3D '$Revision: 1.5 $') =3D~ s/.*?(\d.*\d).*/$zero version = $1\n/; my (%opt); =20 +sub grabfile_int { + my $f =3D shift; + open FILE, "<", $f; + $i =3D ; + close FILE; + chomp $i; + return $i + 0; +} + # Collect the open elections my (@open_elections, $usage_elections); opendir(D, "$Votify::datadir/") or die; @open_elections =3D sort grep { s/^start-// and do { - my ($starttime) =3D (stat _)[9] if stat("$Votify::datadir/start-= $_"); - my ($stoptime) =3D (stat _)[9] if stat("$Votify::datadir/stop-$_= "); + my ($startfile) =3D sprintf "%s/start-%s", $Votify::datadir, $_; + my ($stopfile) =3D sprintf "%s/stop-%s", $Votify::datadir, $_; + my ($starttime) =3D grabfile_int($startfile); + my ($stoptime) =3D grabfile_int($stopfile); + $starttime =3D (stat _)[9] if stat($startfile) and (!defined($st= arttime) or ($starttime <=3D 0)); + $stoptime =3D (stat _)[9] if stat($stopfile) and (!defined($stop= time) or ($stoptime <=3D 0)); ((not defined $starttime or $starttime < time) and (not defined $stoptime or $stoptime > time)) }